This answer is now a duplicate of How do I install NVIDIA and CUDA drivers into Ubuntu?
NOTE: I have only verified this works with 16.04 and 17.10. Just tried 18.04 and it does not work.
Try installing the Cuda by doing the repo installation instead of the .deb
installation.
First, remove any cuda PPAs that may be setup and also remove the nvidia-cuda-toolkit
if installed:
sudo rm /etc/apt/sources.list.d/cuda*
sudo apt remove nvidia-cuda-toolkit
Might also want to remove all nvidia drivers too before installing new drivers:
sudo apt remove nvidia-*
Then update the system:
sudo apt update
Install the key:
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
Add the repo:
16.04
sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/cuda.list'
17.10
sudo bash -c 'echo "deb http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1710/x86_64 /" > /etc/apt/sources.list.d/cuda.list'
Update the system again:
sudo apt update
Now you should be able to install the cuda-9-1:
sudo apt install cuda-9-1
There are CUDA 9.0 and CUDA 9.2 as well, and they are listed at the bottom.
It should be installing the nvidia-396 (396.44) drivers with it as those are what are listed in the repo. See: http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/
Verify that Cuda 9.1 was installed:
~$ ls /usr/local/cuda-9.1/
bin include libnvvp nvml samples targets
doc lib64 LICENSE nvvm share tools
extras libnsight nsightee_plugins README src version.txt
Now, add the following to your ~/.profile
for the PATH
and LD_LIBRARY
. You can use the command gedit ~/.profile
for editing:
# set PATH for cuda 9.1 installation
if [ -d "/usr/local/cuda-9.1/bin/" ]; then
export PATH=/usr/local/cuda-9.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
fi
Reboot your system.
sudo reboot
Once the system is up, you can verify the installation by typing in the following:
nvcc -V
You should see the following:
~$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Nov__3_21:07:56_CDT_2017
Cuda compilation tools, release 9.1, V9.1.85
And you should see the 396.44
drivers installed:
~$ nvidia-smi
Thu May 17 07:38:54 2018
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 396.44 Driver Version: 396.44 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
|===============================+======================+======================|
| 0 GeForce GTX 760 Off | 00000000:02:00.0 N/A | N/A |
| 49% 53C P0 N/A / N/A | 187MiB / 1999MiB | N/A Default |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 Not Supported |
+-----------------------------------------------------------------------------+
EDIT 05/28/2018: The following steps work fine for Cuda 9.2
as well. Just change the installation to
sudo apt install cuda-9-2
and make sure you change the .profile
section to:
# 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
EDIT 07/11/2018: The following steps work fine for Cuda 9.0
as well. Just change the installation to
sudo apt install cuda-9-0
and make sure you change the .profile
section to:
# set PATH for cuda 9.0 installation
if [ -d "/usr/local/cuda-9.0/bin/" ]; then
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
fi
Hope this helps!