CUDA – Troubleshooting CUDA Problems with Nvidia Driver Versions

bashcudadriversgpunvidia

Coming from
How do I install NVIDIA and CUDA drivers into Ubuntu?

I'm trying the CUDA 9.2 and drivers 396 configuration but the drivers that sudo apt install cuda-9-2 installs are the 410. How can avoid that?

<code>sudo apt install cuda-9-2</code> output

Best Answer

Unfortunately with the NVIDIA repo, it installs the newest driver that is in that repo. At the time I wrote the answer that was the newest one there, then they recently changed it. So, to do the older driver you will have to download and install the CUDA 9.2 manually.

This site has a pretty good layout of the installation of CUDA 9.2: https://www.pugetsystems.com/labs/hpc/How-to-install-CUDA-9-2-on-Ubuntu-18-04-1184/

You do have to follow those instructions very closely.

First thing, I recommend that you remove the NVIDIA repository first:

sudo rm /etc/apt/sources.list.d/cuda*

Then update again

sudo apt update

Make sure the graphics-driver ppa is setup

sudo add-apt-repository ppa:graphics-drivers/ppa

Then install the 396 driver

sudo apt install nvidia-driver-396

Download the CUDA run file for the install from https://developer.nvidia.com/cuda-92-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1710&target_type=runfilelocal

Then run the CUDA installer:

sudo sh cuda_9.2.148_396.37_linux.run

Step through the installation follow carefully so you don't install the wrong driver:

You are attempting to install on an unsupported configuration. Do you wish to continue?
(y)es/(n)o [ default is no ]: y

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 396.37?
(y)es/(n)o/(q)uit: n

Install the CUDA 9.2 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
 [ default is /usr/local/cuda-9.2 ]:

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y

Install the CUDA 9.2 Samples?
(y)es/(n)o/(q)uit: y

Enter CUDA Samples Location
 [ default is /home/terrance ]: /usr/local/cuda-9.2

Then add the following to the bottom of your ~/.profile file:

# set PATH for cuda 9.2 installation
if [ -d "/usr/local/cuda-9.2/bin/" ]; then
    export PATH=/usr/local/cuda-9.2/bin${PATH:+:${PATH}}
    export LD_LIBRARY_PATH=/usr/local/cuda-9.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
fi

Reboot your system.