Installing Cuda 10.1 on Ubuntu 16.04 and 18.04
Published:
Installing Cuda 10.1 on Ubuntu 18.04
Updated based on Ubuntu 18.04 (CUDA 10.1)
After following these instructions you’ll have Cuda 10.1 drivers installed on Ubuntu 18.04
.
Step 0: Uninstall every NVIDIA related softwares:
sudo apt --purge remove "cublas*" "cuda*"
sudo apt-get purge nvidia*
sudo reboot
Installation steps
1. Add NVIDIA package repositories
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.243-1_amd64.deb
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo dpkg -i cuda-repo-ubuntu1804_10.1.243-1_amd64.deb
sudo apt-get update
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt install ./nvidia-machine-learning-repo-ubuntu1804_1.0.0-1_amd64.deb
sudo apt-get update
2. Install NVIDIA driver
sudo apt-get install --no-install-recommends nvidia-driver-430
3. Check that GPUs are visible
- reboot Ubuntu
sudo reboot
- check nvidia driver install
nvidia-smi
You should see a list of GPUs printed. If not, the previous steps failed.
4. Install development and runtime libraries (~4GB)
sudo apt-get install --no-install-recommends \
cuda-10-1 \
libcudnn7=7.6.4.38-1+cuda10.1 \
libcudnn7-dev=7.6.4.38-1+cuda10.1
5. Install TensorRT. Requires that libcudnn7 is installed above
sudo apt-get install -y --no-install-recommends libnvinfer6=6.0.1-1+cuda10.1 \
libnvinfer-dev=6.0.1-1+cuda10.1 \
libnvinfer-plugin6=6.0.1-1+cuda10.1
6. Link libraries to standard locations
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
7. Add these lines to end of ~/.bashrc
:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda
export PATH="$PATH:/usr/local/cuda/bin"
**Reload bashrc**
source ~/.bashrc
Installing Cuda 10.1 on Ubuntu 16.04
Refer to Ubuntu 16.04 (CUDA 10.1)
After following these instructions you’ll have Cuda 10.1 drivers installed on Ubuntu 16.04
.
Step 0: Uninstall every NVIDIA related software:
sudo apt-get purge nvidia*
sudo reboot
Installation steps
1. update apt-get
sudo apt-get update
2. Install apt-get deps
sudo apt-get install openjdk-8-jdk git python-dev python3-dev python-numpy python3-numpy build-essential python-pip python3-pip python-virtualenv swig python-wheel libcurl3-dev curl
3. install nvidia drivers
**download drivers**
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_10.1.243-1_amd64.deb
**download key to allow installation**
sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub
**install actual package**
sudo dpkg -i ./cuda-repo-ubuntu1604_10.1.243-1_amd64.deb
**install cuda (we try to install twice with a dep update in between)**
sudo apt-get update
sudo apt-get install cuda-10-1
- reboot Ubuntu
sudo reboot
- check nvidia driver install
nvidia-smi
You should see a list of GPUs printed. If not, the previous steps failed.
4. Install cudnn
wget https://www.dropbox.com/s/29k5p6tho44acvz/cudnn-10.1-linux-x64-v7.6.3.30.tgz
sudo tar -xzvf cudnn-10.1-linux-x64-v7.6.3.30.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
5. Add these lines to end of ~/.bashrc:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda
export PATH="$PATH:/usr/local/cuda/bin"
source ~/.bashrc