Last active
August 31, 2023 12:50
-
-
Save fonylew/561a1cfe4bad62c17e6f6a324d23b96f to your computer and use it in GitHub Desktop.
A bunch of script to install Nvidia with CUDA10, CUDNN 7.4 and so on.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# First sudo command | |
sudo whoami | |
# Update and upgrade | |
sudo apt update | |
sudo apt upgrade -y | |
# Utility | |
# Essential | |
sudo apt install -y git python3-pip gcc cmake | |
# Networking tools | |
sudo apt install -y curl net-tools | |
# Networking tools (optional) | |
sudo apt install -y openssh-server nmap | |
## For CUDA | |
sudo apt-get install -y freeglut3 freeglut3-dev libxi-dev libxmu-dev gcc-6 g++-6 | |
## VMware Tools (In case of VM) | |
sudo apt-get install -y open-vm-tools open-vm-tools-desktop | |
# Nvidia | |
sudo add-apt-repository ppa:graphics-drivers/ppa | |
sudo apt update | |
# Latest | |
sudo apt install -y nvidia-driver-415 | |
# Install CUDA | |
# echo "*** for Xubuntu, it is recommended to do this in TTY using `sudo service lightdm stop` ***" | |
wget https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux | |
sudo sh cuda_10.0.130_410.48_linux | |
# add PATH and LD_CONFIG variables | |
echo 'export PATH=$PATH:/usr/local/cuda/bin' >> ~/.bashrc | |
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64' >> ~/.bashrc | |
source ~/.bashrc | |
# Install CUDNN | |
# (use my private cache) | |
wget https://storage.googleapis.com/public-fony/cudnn-10.0-linux-x64-v7.4.2.24.tgz | |
tar xvf cudnn-10.0-linux-x64-v7.4.2.24.tgz | |
sudo cp -P cuda/include/cudnn.h /usr/local/cuda/include | |
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda/lib64 | |
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* | |
# Docker | |
sudo apt-get install -y \ | |
apt-transport-https \ | |
ca-certificates \ | |
curl \ | |
software-properties-common | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - | |
sudo add-apt-repository \ | |
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \ | |
$(lsb_release -cs) \ | |
stable" | |
sudo apt-get update | |
sudo apt-get install -y docker-ce | |
# Fix docker permission | |
sudo groupadd docker | |
sudo gpasswd -a $USER docker | |
newgrp docker | |
# Docker compose | |
sudo curl -L "https://github.com/docker/compose/releases/download/1.23.1/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose | |
sudo chmod +x /usr/local/bin/docker-compose | |
# Nvidia-docker | |
# Add the package repositories | |
curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | \ | |
sudo apt-key add - | |
distribution=$(. /etc/os-release;echo $ID$VERSION_ID) | |
curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | \ | |
sudo tee /etc/apt/sources.list.d/nvidia-docker.list | |
sudo apt-get update | |
# Install nvidia-docker2 and reload the Docker daemon configuration | |
sudo apt-get install -y nvidia-docker2 | |
sudo pkill -SIGHUP dockerd | |
# Test nvidia-smi with the latest official CUDA image | |
docker run --runtime=nvidia --rm nvidia/cuda:10.0-base nvidia-smi | |
# Node | |
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash | |
source ~/.bashrc | |
nvm install --lts | |
npm i -g npm | |
npm i -g yarn | |
npm i -g pm2 | |
# Nginx | |
sudo apt install -y nginx | |
# OpenSSL | |
sudo apt install -y openssl | |
openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate. | |
openssl x509 -text -noout -in certificate.pem | |
openssl pkcs12 -inkey key.pem -in certificate.pem -export -out certificate.p12 | |
openssl pkcs12 -in certificate.p12 -noout -info | |
https://www.tensorflow.org/install/docker
docker run --runtime=nvidia -it tensorflow/tensorflow:latest-gpu bash
Note: Required CUDA10 and nvidia-docker v2
Resolve the blank screen problem (VMware)
https://askubuntu.com/questions/1081973/ubuntu-18-04-1-hangs-at-booting-smp-configuration-on-vmware
--> Boot with 1 CPU, run the command and then shutdown and re-configure to maximum CPU.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Reference:
https://hub.docker.com/r/nvidia/cuda/
10.0-cudnn7-devel, 10.0-cudnn7-devel-ubuntu18.04 (10.0/devel/cudnn7/Dockerfile)
https://developer.nvidia.com/cuda-zone
https://developer.nvidia.com/rdp/cudnn-download