ramdisk
Your ramdisk file is not current for your new CPU.
From the GRUB menu, boot to Recovery Mode...
And type:
sudo update-initramfs -c -k $(uname -r)
reboot
BIOS
HP ProDesk 400 G4 Small Form Factor PC
You currently have BIOS version P08 2.15, from Jan 30, 2018.
There's a newer BIOS available, version P08 02.35 Rev.A, from May 11, 2020, and can be downloaded here.
Note: Confirm that I have the correct web page for your model #.
Note: Have good backups before updating the BIOS.
memtest
Go to https://www.memtest86.com/ and download/run their free memtest
to test your memory. Get at least one complete pass of all the 4/4 tests to confirm good memory. This may take many hours to complete.
Update #1:
memtest
fails at test #6 [Block Move], with i7, and either 8G or 32G RAM installed. Same address range. Suspect CPU or motherboard problem.
Update #2:
It was determined that the (used) i7 CPU was defective. The i5 CPU was reinstalled, and memtest ran fine again.