How to install CUDA on Ubuntu 20.04 Focal Fossa Linux - LinuxConfig.org

The Nvidia CUDA toolkit is an extension of the GPU parallel computing platform and programming model. The Nvidia CUDA installation consists of inclusion of the official Nvidia CUDA repository followed by the installation of relevant meta package and configuring path the the executable CUDA binaries.
This is a companion discussion topic for the original entry at https://linuxconfig.org/how-to-install-cuda-on-ubuntu-20-04-focal-fossa-linux

Unfortunately it did not yet work for me you documented. I get the warning

dpkg: error processing archive /var/cache/apt/archives/libcublas10_10.2.2.89-1_amd64.deb (–unpack):
trying to overwrite ‘/usr/lib/x86_64-linux-gnu/libnvblas.so.10’, which is also in package libnvblas10:amd64 10.1.243-3
Errors were encountered while processing:
/var/cache/apt/archives/libcublas10_10.2.2.89-1_amd64.deb
E: Sub-process /usr/bin/dpkg returned an error code (1)

Did I miss a step?

I had this happen as well. It may be related to an older version of CUDA being installed, but possibly not. Either way I was able to get past the error by running

  $ sudo dpkg -i --force-overwrite  /var/cache/apt/archives/libcublas10_10.2.2.89-1_amd64.deb

  $ sudo apt --fix-broken install

You will get some warnings after running the first command but the --fix-broken-install clears that right up.

Cheers!

sudo apt install nvidia-cuda-toolkit
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-cuda-toolkit : Depends: nvidia-cuda-dev (= 10.1.243-3) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

1 Like

Hi, the installation worked well.

But when I run the sample hello.cu code, it get the output as:

Max error: 2.000000

I suppose it should be 0.000000. Is this fine? if so what is the reason for this difference?

I’m not sure what the difference is, but when I was getting Max error:2.000000 something was wrong with my nvidia-driver (maybe due to SecureBoot) but running sudo dpkg --configure -a and then running sudo apt install nvidia-cuda-toolkit . This fixed the driver issue and then I got the error of 0.000

These instructions install the latest cuda version which at this time is cuda 11. There is a serious version mismatch with the 440 driver and version 11. Before installing this when I ran nvidia-smi it indicated that is used cuda 10.2. After installing cuda nvidia-smi returns

Failed to initialize NVML: Driver/library version mismatch

I read somewhere that Cuda 11 was required when running the 5.3 kernel, so it’s not clear that I could downgrade to cuda 10.2. Maybe I need a version 440 driver written with cuda 11, if such a thing exists.

Doing

sudo apt remove cuda

does not remove the cuda installation so nvidia-smi still errors.

Nvidia has created a terrible mess with this.

Here’s what I did to get things to work.

After running sudo apt remove cuda I had to run sudo apt autoremove to actually remove the cuda installation. After rebooting I checked the Additional Drivers tab in Software & Updates and noticed that the 440 driver was gone and my system was not using the xorg nouveau driver. Apparently the cuda installation overwrites your driver and removing cuda removes the overwritten driver leaving you running the xorg driver.

I did sudo apt install cuda and rebooted. The Additional Drivers tab in Software & Updates shows a manually installed driver in use. The nvidia-smi shows a driver version 450 and cuda version 11.0. My other cuda binaries now run too.

It looks like the one thing that needs to be added to the installation instructions is to be sure you are running the xorg nouveau driver when you install cuda. If you are running an Nvidia driver it will be overwritten by the cuda install leaving you with driver and library version mismatches.

1 Like

I did this:

  1. Followed “How to install CUDA toolkit from Ubuntu Repository” (I could not run hello.cu)
  2. Followed “How to install the NVIDIA drivers on Ubuntu 20.04 Focal Fossa Linux.”
  3. When I ran the hello.cu ($nvcc -o hello hello.cu), I got the same max error: 2.000
  4. Restart Linux.
  5. Ran hello.cu again and got max error: 0.0000

Cheers.

1 Like

A plea to the ether to assist. This page is very helpful, but I can get no combination of ubuntu 18/20 and available drivers/toolkit to work for a Grid K1 card. Consistently getting the “error 2.0000”. The catch is this is a vm where the GPU is PCI passed thru, with apparent success. I see the device in “lshw”, with the nvidia driver applied. Is there any chance it’s due to there also being a Cirrus Logic VGA on display:0, which I can’t seem to get rid of? I don’t see anywhere in the test code that it’s telling it which device to use for cuda.

Hi, thanks for all the info. I followed all the instructions to a tee on both linuxconfig dot org/ethereum-mining-on-ubuntu-18-04-and-debian and linuxconfig dot org/how-to-install-cuda-on-ubuntu-20-04-focal-fossa-linux but all I get when attempting to run either -
./ethminer -U -P stratum1+tcp://YOUR_ETHEREUM_ADDRESS_HERE@us1.ethpool.org:3333
or
./ethminer -U -P stratum1+tcp://0xb67440E02D5aA019248DF50E672695C87616EBc9@us1.ethpool.org:3333
is
"ethminer 0.18.0
Build: linux/release/gnu

CUDA Error : unknown error
Error: No usable mining devices found"

And yes I changed the mining crypto address…

Thank you!

Ivan

I too got the error max 2.000 as well.