Installation Problem

Hi, I am here to ask some questions regarding cuda toolkit installation and libraries.
While I was using cuda file, I tried to upgrade from 12-3 to 12-4 and I found that the old version is not removed and the new version seems not installed well.
I want to keep only one version for safety.
I tried removing things but it prevents due to many reasons.
Firstly, it says me to run apt --fix-broken install ,but when I try that command, an error occurs saying
dpkg-query: no packages found matching libnvidia-gl-535
Then, I tried the below link,

Then, it says
dpkg: error processing archive /var/cache/apt/archives/libnvidia-gl-550_550.54.15-0ubuntu1_amd64.deb (–unpack):

When I try something new, different errors come out continuously.
I think it is better to remove all and re-install.
Please help me to solve this issue.
Thank you.

This depends greatly on the exact way you installed cuda and the driver the first time. So I guess it’s better to remove anything cuda and nvidia first.