How can I install CUDA 9 on Ubuntu 17.10
Installation of NVIDIA driver 384
First we install a fresh Ubuntu 17.10 on a computer with an NVIDIA GPU and select "Install third-party software" during the process. Alternatively, we can add the graphics drivers repository manually:
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
Then we install the most recent NVIDIA driver using apt:
sudo apt install nvidia-384 nvidia-384-dev
We verify the installation by running:
nvidia-smi
We should see an output which lists the NVIDIA 384 driver and our discrete NVIDIA GPU - similar to summarized table below:
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 384.90 Driver Version: 384.90 |
| |
|-------------------------------+----------------------+----------------------+
| 0 Quadro M500M Off | 00000000:06:00.0 Off | N/A |
| N/A 48C P0 N/A / N/A | 943MiB / 2002MiB | 26% Default |
+-------------------------------+----------------------+----------------------+
Preparation for installing of CUDA 9 + SDK
We install a number of build/dev packages which we require later:
sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
We notice that the default gcc/g++ version on 17.10 is 7.2.0 (Ubuntu 7.2.0-8ubuntu3)
:
gcc -v
CUDA 9 requires gcc 6. Thus, we install it:
sudo apt install gcc-6
sudo apt install g++-6
Note that the default gcc version is still 7.2
; can be checked by running gcc -v
again.
Installation of CUDA 9 + SDK
From the CUDA Toolkit Archive, select one of the "runfile (local)" installation packages to download a version of CUDA 9, such as
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run
Make the downloaded file executable and run it using sudo:
chmod +x cuda_9.0.176_384.81_linux-run
sudo ./cuda_9.0.176_384.81_linux-run --override
We install CUDA with the following configurations:
You are attempting to install on an unsupported configuration. Do you wish to continue?
y
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
n
Install the CUDA 9.0 Toolkit?
y
Enter Toolkit Location
[default location]
Do you want to install a symbolic link at /usr/local/cuda?
y
Install the CUDA 9.0 Samples?
y
Enter CUDA Samples Location
[default location]
Set up symlinks for gcc/g++:
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++
Test the CUDA 9 installation using the SDK
Build your favorite CUDA sample and run it:
cd ~/NVIDIA_CUDA-9.0_Samples/5_Simulations/smokeParticles
make
../../bin/x86_64/linux/release/smokeParticles
You may like to set up gcc/g++ symlinks after the cuda install.
Getting this installed took more time than I would like to admit, and while the above answer is a good template, I had some additional steps required for my fresh install of Ubuntu 17.10:
blacklist nouveau
sudo vim /etc/modprobe.d/blacklist.conf
Add the following:
# this one might not be required for x86 32 bit users.
blacklist amd76x_edac
blacklist vga16fb
blacklist nouveau
blacklist rivafb
blacklist nvidiafb
blacklist rivatv
Update initramfs disk
sudo update-initramfs -u
Stop gdm3
sudo /etc/init.d/gdm3 stop
sudo init 3
Get content
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt install nvidia-384 nvidia-384-dev
sudo apt-get install g++ freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libglu1-mesa libglu1-mesa-dev
nvidia-smi
Get the package
wget https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run
Run with --override to override compiler choice
chmod +x cuda_9.0.176_384.81_linux-run
sudo ./cuda_9.0.176_384.81_linux-run --override
After installing the package, I would get errors with nvidia-smi, so I suggest running the command again to verify it works. When I had issues, I would purge nvidia* and re-get it.
nvidia-smi