Skip to content

Instantly share code, notes, and snippets.

@ziyan0302
Last active May 8, 2024 16:06
Show Gist options
  • Save ziyan0302/e1bf52ef5b77524d2605369828411389 to your computer and use it in GitHub Desktop.
Save ziyan0302/e1bf52ef5b77524d2605369828411389 to your computer and use it in GitHub Desktop.
cuda11.3, cudnn11.3, Tensorflow2.8.0, Pytorch1.10.2, ubuntu20.04.txt
#!/bin/bash
## check nvidia driver version
nvidia-smi
# 510
## to uninstall cuda
# sudo apt-get --purge remove "*cublas*" "cuda*" "nsight*"
# sudo apt-get --purge remove "*nvidia*"
# or
# /usr/local/cuda-11.3/bin/cuda-uninstaller
## cuda 11.3
## head to link:
## https://developer.nvidia.com/cuda-11-3-1-download-archive?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=runfile_local
wget https://developer.download.nvidia.com/compute/cuda/11.3.1/local_installers/cuda_11.3.1_465.19.01_linux.run
sudo sh cuda_11.3.1_465.19.01_linux.run
# continue -> accept -> no driver
# setup your paths
echo 'export PATH=/usr/local/cuda-11.3/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
sudo ldconfig
## cudnn_ubuntu20.04
## for tar install: download tar link:
## https://developer.nvidia.com/rdp/cudnn-archive
tar -zxvf cudnn-11.3-linux-x64-v8.2.0.53.tgz
sudo cp cuda/lib64/* /usr/local/cuda/lib64/
sudo cp cuda/include/* /usr/local/cuda/include/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
# Finally, to verify the installation, check
nvidia-smi
nvcc -V
## TensorRT
## https://developer.nvidia.com/nvidia-tensorrt-8x-download
sudo dpkg -i nv-tensorrt-repo-ubuntu2004-cuda11.4-trt8.2.0.6-ea-20210922_1-1_amd64.deb
sudo apt-key add /var/nv-tensorrt-repo-ubuntu2004-cuda11.4-trt8.2.0.6-ea-20210922/7fa2af80.pub
# install tnesorflow(2.8.0)
# tensorflow list: https://www.tensorflow.org/install/source#linux
pip3 install tensorflow
## check if tf can read GPU: tf.config.list_physical_devices("GPU")
# install Pytorch (an open source machine learning framework)
# I choose version 1.8.0 because it is stable and compatible with CUDA 11.3 Toolkit and cuDNN 8.1
# pip3 install pytorch==1.10.2 torchvision==0.1.3
pip3 install torch==1.10.2+cu113 torchvision==0.11.3+cu113 torchaudio==0.10.2+cu113 -f https://download.pytorch.org/whl/cu113/torch_stable.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment