Last active
September 9, 2021 14:00
-
-
Save scionoftech/47d8fb458f0a27910e7861e1f01bb631 to your computer and use it in GitHub Desktop.
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
# Deeplearning Environment Setup for tensorflow_2.3.1 with CUDA 10.1 and cuDNN 7.6.0 | |
### If you have previous installation remove it first. | |
sudo apt-get purge nvidia* | |
sudo apt remove nvidia-* | |
sudo apt remove --autoremove nvidia-cuda-toolkit | |
sudo rm /etc/apt/sources.list.d/cuda* | |
sudo apt-get autoremove && sudo apt-get autoclean | |
sudo rm -rf /usr/local/cuda* | |
# Get latest nvidia driver | |
apt-cache search nvidia-driver | |
sudo apt install nvidia-driver-470 | |
# check nvidia driver version | |
nvidia-smi | |
# install cuda 10.1 method-1 | |
# https://developer.nvidia.com/cuda-10.1-download-archive-base?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=runfilelocal | |
wget https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run | |
# run below command and follow the command-line prompts | |
sudo sh cuda_10.1.105_418.39_linux.run | |
# install cuda 10.1 method-2 | |
# https://developer.nvidia.com/cuda-10.1-download-archive-base?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=deblocal | |
wget https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39_1.0-1_amd64.deb | |
sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.105-418.39_1.0-1_amd64.deb | |
sudo apt-key add /var/cuda-repo-10-1-local-10.1.105-418.39/7fa2af80.pub | |
sudo apt-get update | |
sudo apt-get install cuda | |
# install cuDNN(CUDA® Deep Neural Network library) 7.6.0 version (CUDA 10.1 is compatable with cuDNN 7.5.1 - 7.6.2) | |
# source https://anaconda.org/anaconda/cudnn/files | |
wget https://anaconda.org/anaconda/cudnn/7.6.0/download/linux-64/cudnn-7.6.0-cuda10.1_0.tar.bz2 | |
tar -xvf cudnn-7.6.0-cuda10.1_0.tar.bz2 -C cuda | |
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* | |
echo 'export PATH=/usr/local/cuda-10.1/bin${PATH:+:${PATH}}' >> ~/.bashrc | |
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc | |
echo 'export CUDA_HOME=/usr/local/cuda' >> ~/.bashrc | |
source ~/.bashrc | |
# test cuDNN | |
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2 | |
#Should see something like below: | |
#define CUDNN_MAJOR 6 | |
#define CUDNN_MINOR 0 | |
#define CUDNN_PATCHLEVEL 21 | |
-- | |
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL) | |
#include "driver_types.h" | |
# check driver with cuda | |
lspci | grep -i nvidia | |
# install tensorflow 2.3.1 and pytorch 1.7.1 | |
pip install tensorflow==2.3.1 | |
pip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html | |
# Test tensorflow_2 | |
import tensorflow as tf | |
print(tf.config.list_physical_devices('GPU')) | |
# install nvidia-docker | |
# first install docker-ce | |
sudo apt-get update | |
sudo apt-get install -y nvidia-docker2 | |
sudo pkill -SIGHUP dockerd | |
# Test environment and to make sure everything is installed correctly | |
sudo docker run --runtime=nvidia --rm nvidia/cuda:10.1-base nvidia-smi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment