1. Install NVIDIA Graphics Driver
Determine the latest version of Nvidia driver available for your graphics cardDetecting NVIDIA card model
lspci -vnn | grep VGA Visit the graphics drivers PPA homepage here and determine the latest versions of Nvidia drivers availableRemove Previous Installations (Important)
Search what packages from nvidia you have installed.
dpkg -l | grep -i nvidia
except the package nvidia-common
all other packages should be purged.sudo apt-get remove --purge nvidia-*
sudo apt-get autoremove
sudo reboot
Update gcc-6 g++6
sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-6 g++-6
sudo ln -s /usr/bin/gcc-6 /usr/bin/gcc -f sudo ln -s /usr/bin/g++-6 /usr/bin/g++ -f
checking
gcc -v
Add the graphics drivers PPAsudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
Install
sudo apt-get install nvidia-390 nvidia-390-dev
sudo reboot
lsmod | grep nvidia
or
nvidia-smi
If there is no output, then your installation has probably failed. It is also possible that the driver is not available in your system's driver database. You can run the following command to check if your system is running on the open source driver nouveau. If the output is negative for nouveau, then all is well with your installation.lsmod | grep nouveau
Prevent automatic updates that might break the driverssudo apt-mark hold nvidia-390
2. Install CUDA
Preparation for installing of CUDA 9 + SDKWe 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 and set the corresponding sym-links:sudo apt install gcc-6
sudo apt install g++-6
sudo ln -s /usr/bin/gcc-6 /usr/local/cuda/bin/gcc
sudo ln -s /usr/bin/g++-6 /usr/local/cuda/bin/g++
Note that the default gcc version is still 7.2
; can be checked by running gcc -v
again.Installation of CUDA 9 + SDK
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.1.85_387.26_linux.run
sudo ./cuda_cuda_9.1.85_387.26_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]
Test the CUDA 9 installation using the SDKBuild your favorite CUDA sample and run it:
cd ~/NVIDIA_CUDA-9.0_Samples/5_Simulations/smokeParticles
make
../../bin/x86_64/linux/release/smokeParticles
After the installation finishes, configure runtime library.sudo bash -c "echo /usr/local/cuda/lib64/ > /etc/ld.so.conf.d/cuda.conf"
sudo ldconfig
It is also recommended for Ubuntu users to append string /usr/local/cuda/bin
to system file /etc/environments
so that nvcc
will be included in $PATH
. This will take effect after reboot.Install cuDNN
The recommended way for installing cuDNN is to first copy thetgz
file to /usr/local
and then extract it, and then remove the tgz
file if necessary. This method will preserve symbolic links. At last, execute sudo ldconfig
to update the shared library cache.** References:
1) How can I install CUDA 9 on Ubuntu 17.10
2) Install NVIDIA Driver and CUDA on Ubuntu / CentOS / Fedora Linux OS
3) Install Nvidia CUDA-7.5 environment in CentOS 6
4) Things to know when installing NVIDIA drivers
5) Install the latest NVIDIA driver on Linux
6) GTX 1070 on Ubuntu 16.04 with Cuda 8.0 and Theano