SOLVED, the initial question and all of the error messages and attempts are below.
For those visiting this page in the future:
- the accepted answer worked after all of the attempts I made and that you need to reconstruct from the comments
- After the installation as indicated in the accepted answer, I had a problem with nvcc, that stayed at version 10.1. In order to get the most recent version (or the one corresponding to the CUDA version you installed) REMEMBER TO PERFORM THE MANDATORY POST-INSTALLATION ACTIONS.
ORIGINAL QUESTION AND ATTEMPTS SUGGESTED IN THE COMMENTS
Yesterday, my Ubuntu 20.04 machine realized it had CUDA conflicts. I was not able to fix them, so I decided to uninstall it using the instruction on the nvidia web-site :
sudo apt-get --purge remove <package_name> # Ubuntu
it is possible that I made some wrong choices, but I couldn't tell which.
Then I followed the instructions here, for Ubuntu. I ended up on this page and followed the instructions.
Here it is what I have:
sudo apt-get -y install cuda
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
cuda : Depends: cuda-11-6 (>= 11.6.0) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Then:
sudo apt-get -y install cuda
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
cuda : Depends: cuda-11-6 (>= 11.6.0) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Then,
sudo apt-get install cuda-runtime-11-6
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
cuda-runtime-11-6 : Depends: cuda-drivers (>= 510.39.01) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Then,
sudo apt-get install cuda-drivers
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
cuda-drivers : Depends: cuda-drivers-510 (= 510.47.03-1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Then,
sudo apt-get install cuda-drivers-510
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
cuda-drivers-510 : Depends: nvidia-driver-510 (>= 510.47.03) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
Then,
sudo apt-get install nvidia-driver-510
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nvidia-driver-510 : Depends: nvidia-dkms-510 (= 510.47.03-0ubuntu1)
Depends: nvidia-kernel-source-510 (= 510.47.03-0ubuntu1) but it is not going to be installed
Depends: libnvidia-compute-510 (= 510.47.03-0ubuntu1) but it is not going to be installed
Depends: libnvidia-extra-510 (= 510.47.03-0ubuntu1) but it is not going to be installed
Depends: nvidia-compute-utils-510 (= 510.47.03-0ubuntu1) but it is not going to be installed
Depends: libnvidia-decode-510 (= 510.47.03-0ubuntu1) but it is not going to be installed
Depends: libnvidia-encode-510 (= 510.47.03-0ubuntu1) but it is not going to be installed
Depends: nvidia-utils-510 (= 510.47.03-0ubuntu1) but it is not going to be installed
Recommends: libnvidia-compute-510:i386 (= 510.47.03-0ubuntu1)
Recommends: libnvidia-decode-510:i386 (= 510.47.03-0ubuntu1)
Recommends: libnvidia-encode-510:i386 (= 510.47.03-0ubuntu1)
E: Unable to correct problems, you have held broken packages.
sudo apt-get install nvidia-dkms-510
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nvidia-dkms-510 : Depends: nvidia-kernel-source-510 but it is not going to be installed
Depends: nvidia-kernel-common-510 (= 510.47.03-0ubuntu1) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.
and so on.
I am not a system manager: I just need to install nvidia on this linux machine. I promise I made quite a lot of web searches, but cannot find a source with clear and working instructions.
Is there anyone who is able to understand the reason of this mess and can suggest a solution/web page with clear instructions? I would rather not re-install the OS, let me know if that is the only solution.
https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#pre-installation-actions
As requested in the comments:
ls -al /etc/apt/preferences.d/cuda-repository-pin-600
4 -rw-rw-r-- 1 user user 190 Jun 29 2020 /etc/apt/preferences.d/cuda-repository-pin-600
cat /etc/apt/preferences.d/cuda-repository-pin-600
Package: nsight-compute
Pin: origin *ubuntu.com*
Pin-Priority: -1
Package: nsight-systems
Pin: origin *ubuntu.com*
Pin-Priority: -1
Package: *
Pin: release l=NVIDIA CUDA
Pin-Priority: 600
apt-cache policy cuda cuda-drivers nvidia-dkms-510
cuda:
Installed: (none)
Candidate: 11.6.0-1
Version table:
11.6.0-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
600 file:/var/cuda-repo-ubuntu2004-11-6-local Packages
11.5.2-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.5.1-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.5.0-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.4.4-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.4.3-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.4.2-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.4.1-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.4.0-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.3.1-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
600 file:/var/cuda-repo-ubuntu2004-11-3-local Packages
11.3.0-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.2.2-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.2.1-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.2.0-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.1.1-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.1.0-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.0.3-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
11.0.2-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
cuda-drivers:
Installed: (none)
Candidate: 510.47.03-1
Version table:
510.47.03-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
510.39.01-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
600 file:/var/cuda-repo-ubuntu2004-11-6-local Packages
495.29.05-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
470.103.01-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
470.82.01-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
470.57.02-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
470.42.01-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
465.19.01-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
600 file:/var/cuda-repo-ubuntu2004-11-3-local Packages
460.106.00-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
460.91.03-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
460.73.01-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
460.32.03-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
460.27.04-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
455.45.01-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
455.32.00-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
455.23.05-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
450.172.01-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
450.156.00-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
450.142.00-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
450.119.04-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
450.119.03-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
450.102.04-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
450.80.02-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
450.51.06-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
450.51.05-1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
nvidia-dkms-510:
Installed: (none)
Candidate: 510.47.03-0ubuntu1
Version table:
510.47.03-0ubuntu1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
510.47.03-0ubuntu0.20.04.1 500
500 http://it.archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages
500 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages
510.39.01-0ubuntu1 600
600 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64 Packages
600 file:/var/cuda-repo-ubuntu2004-11-6-local Packages
Output of: ls -al /var/cuda-repo-ubuntu2004-11-6-local/
4 -rw-r
4 -rw-r
4 -rw-r
1020 -rw-r
4 -rw-r
15044 -rw-r
4 -rw-r
160 -rw-r
740 -rw-r
116 -rw-r
12752 -rw-r
2444 -rw-r
184 -rw-r
3888 -rw-r
52 -rw-r
28 -rw-r
4 -rw-r
4 -rw-r
4 -rw-r
4 -rw-r
4008 -rw-r
58716 -rw-r
4 -rw-r
4 -rw-r
140 -rw-r
4 -rw-r
115832 -rw-r
4 -rw-r
4 -rw-r
34948 -rw-r
32044 -rw-r
76 -rw-r
1904 -rw-r
60 -rw-r
14628 -rw-r
73704 -rw-r
52 -rw-r
109924 -rw-r
4 -rw-r
16 -rw-r
8328 -rw-r
4 -rw-r
16 -rw-r
16 -rw-r
16 -rw-r
4 -rw-r
4 -rw-r
4 -rw-r
37980 -rw-r
210464 -rw-r
214852 -rw-r
66720 -rw-r
148744 -rw-r
456 -rw-r
7516 -rw-r
40568 -rw-r
40896 -rw-r
46640 -rw-r
30376 -rw-r
96244 -rw-r
96376 -rw-r
80636 -rw-r
79012 -rw-r
8 -rw-r
80 -rw-r
8 -rw-r
12 -rw-r
8 -rw-r
8 -rw-r
30704 -rw-r
24524 -rw-r
8 -rw-r
8 -rw-r
1224 -rw-r
1208 -rw-r
8 -rw-r
8 -rw-r
44 -rw-r
44 -rw-r
48 -rw-r
52 -rw-r
8 -rw-r
8 -rw-r
48 -rw-r
52 -rw-r
8 -rw-r
8 -rw-r
164588 -rw-r
22460 -rw-r
316 -rw-r
1764 -rw-r
1444 -rw-r
24 -rw-r
92 -rw-r
402492 -rw-r
231040 -rw-r
8 -rw-r
344 -rw-r
8 -rw-r
32 -rw-r
8 -rw-r
432 -rw-r
1360 -rw-r
352 -rw-r
4 -rw-r
72 -rw-r
4 -rw-r
4 -rw-r
8 -rw-r
8 -rw-r
8 -rw-r
8 -rw-r
8 -rw-r
19992 -rw-r
8 -rw-r
28468 -rw-r
20 -rw-r
912 -rw-r
8 -rw-r
380 -rw-r
36 -rw-r
4 -rw-r
4 -rw-r
8 -rw-r
1364 -rw-r
dpkg -l *nvidia*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-================================-==================-============-=======================================================
un libgldispatch0-nvidia <none> <none> (no description available)
ii libnvidia-compute-510:i386 510.47.03-0ubuntu1 i386 NVIDIA libcompute package
un libnvidia-decode <none> <none> (no description available)
ii libnvidia-decode-510:i386 510.47.03-0ubuntu1 i386 NVIDIA Video Decoding runtime libraries
un libnvidia-encode <none> <none> (no description available)
ii libnvidia-encode-510:i386 510.47.03-0ubuntu1 i386 NVENC Video Encoding runtime library
un libnvidia-fbc1 <none> <none> (no description available)
ii libnvidia-fbc1-510:i386 510.47.03-0ubuntu1 i386 NVIDIA OpenGL-based Framebuffer Capture runtime library
un libnvidia-ml1 <none> <none> (no description available)
un nvidia-common <none> <none> (no description available)
un nvidia-legacy-304xx-vdpau-driver <none> <none> (no description available)
un nvidia-legacy-340xx-vdpau-driver <none> <none> (no description available)
un nvidia-libopencl1-dev <none> <none> (no description available)
un nvidia-opencl-icd <none> <none> (no description available)
un nvidia-prime <none> <none> (no description available)
un nvidia-vdpau-driver <none> <none> (no description available)