Skip to content

Instantly share code, notes, and snippets.

@zendobk
Last active November 14, 2022 08:08
Show Gist options
  • Save zendobk/3585d71cf6247d6a8b3c8452dd57b151 to your computer and use it in GitHub Desktop.
Save zendobk/3585d71cf6247d6a8b3c8452dd57b151 to your computer and use it in GitHub Desktop.
Steps to install CUDA 10.1 on Ubuntu 18.04
#!/bin/bash
set -eo pipefail
# Purge existing drivers first if needed
sudo apt-get purge --auto-remove -y "nvidia*"
sudo ubuntu-drivers autoinstall
sudo apt-mark manual nvidia-prime nvidia-settings libnvidia-compute-440:i386 libnvidia-decode-440:i386 libnvidia-encode-440:i386 libnvidia-gl-440:i386
sudo apt autoremove
#!/bin/bash
set -eo pipefail
# Purge existing pkgs first
sudo apt-get purge --auto-remove -y "*cublas*" "cuda*" "nvidia-cuda*"
sudo rm -rf /usr/local/cuda*
# Fix unmet deps for cuda-toolkit-10-1
sudo apt-get install -y --allow-downgrades mesa-common-dev=19.0.8-0ubuntu0~18.04.3
sudo apt-mark hold mesa-common-dev=19.0.8-0ubuntu0~18.04.3
wget -N https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-repo-ubuntu1804_10.1.105-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1804_10.1.105-1_amd64.deb
sudo apt-mark hold cuda-repo-ubuntu1804
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub
sudo apt-get update
# Install CUDA Toolkit pkg only, DONOT install CUDA pkg
sudo apt-get install -y cuda-toolkit-10-1
# Make alias
sudo rm -rf /usr/local/cuda
sudo ln -sf /usr/local/cuda-10.1 /usr/local/cuda
# PATHs
echo 'PATH="/usr/local/cuda/bin:$PATH"' | sudo tee /etc/profile.d/02-cuda.sh
echo 'LD_LIBRARY_PATH="/usr/local/cuda/lib64:$LD_LIBRARY_PATH"' | sudo tee -a /etc/profile.d/02-cuda.sh
sudo apt autoremove
#!/bin/bash
set -eo pipefail
# # Install CuDNN 7 and NCCL 2
sudo apt install -y --allow-downgrades --allow-change-held-packages libcudnn7=7.6.5.32-1+cuda10.1 libcudnn7-dev=7.6.5.32-1+cuda10.1 libnccl2=2.5.6-1+cuda10.1 libc-ares-dev
sudo apt-mark hold libcudnn7=7.6.5.32-1+cuda10.1 libcudnn7-dev=7.6.5.32-1+cuda10.1 libnccl2=2.5.6-1+cuda10.1
# # Link libraries to standard locations
sudo mkdir -p /usr/local/cuda/nccl/lib
sudo ln -sf /usr/lib/x86_64-linux-gnu/libnccl.so.2 /usr/local/cuda/nccl/lib/
sudo ln -sf /usr/lib/x86_64-linux-gnu/libcudnn.so.7 /usr/local/cuda/lib64/
sudo apt autoremove
#!/bin/bash
set -eo pipefail
sudo apt-get install -y nvidia-container-runtime
sudo tee /etc/docker/daemon.json <<EOF
{
"runtimes": {
"nvidia": {
"path": "/usr/bin/nvidia-container-runtime",
"runtimeArgs": []
}
}
}
EOF
sudo systemctl restart docker
sudo apt-get autoremove
Package: *
Pin: origin ppa.launchpad.net
Pin-Priority: 700
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment