Last active
July 18, 2018 17:46
-
-
Save GzuPark/2f6ce4c16522763ab2e0156b8492704b to your computer and use it in GitHub Desktop.
CUDA, NCCL, CUDNN, TensorFlow, and PyTorch
This file contains 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 | |
# Check for CUDA and try to install. | |
# https://gitlab.com/nvidia/cuda/blob/ubuntu16.04/9.0/base/Dockerfile | |
apt-get update && apt-get install -y --no-install-recommends ca-certificates apt-transport-https gnupg-curl && \ | |
rm -rf /var/lib/apt/lists/* && \ | |
NVIDIA_GPGKEY_SUM=d1be581509378368edeec8c1eb2958702feedf3bc3d17011adbf24efacce4ab5 && \ | |
NVIDIA_GPGKEY_FPR=ae09fe4bbd223a84b2ccfce3f60f4b3d7fa2af80 && \ | |
apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/7fa2af80.pub && \ | |
apt-key adv --export --no-emit-version -a $NVIDIA_GPGKEY_FPR | tail -n +5 > cudasign.pub && \ | |
echo "$NVIDIA_GPGKEY_SUM cudasign.pub" | sha256sum -c --strict - && rm cudasign.pub && \ | |
echo "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/cuda.list && \ | |
echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64 /" > /etc/apt/sources.list.d/nvidia-ml.list | |
CUDA_VERSION=9.0.176 | |
CUDA_PKG_VERSION=9-0=$CUDA_VERSION-1 | |
apt-get update && apt-get install -y --no-install-recommends \ | |
cuda-cudart-$CUDA_PKG_VERSION | |
curl -O http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_${CUDA_VERSION}-1_amd64.deb | |
dpkg -i ./cuda-repo-ubuntu1604_${CUDA_VERSION}-1_amd64.deb | |
apt-get update && apt-get install -y --no-install-recommends cuda=${CUDA_VERSION}-1 | |
rm ./cuda-repo-ubuntu1604_${CUDA_VERSION}-1_amd64.deb | |
ln -s cuda-9.0 /usr/local/cuda | |
echo "/usr/local/nvidia/lib" >> /etc/ld.so.conf.d/nvidia.conf | |
echo "/usr/local/nvidia/lib64" >> /etc/ld.so.conf.d/nvidia.conf | |
PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH} | |
LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64 | |
# Check CUDA | |
nvidia-smi | |
# NCCL install | |
# https://gitlab.com/nvidia/cuda/blob/ubuntu16.04/9.0/runtime/Dockerfile | |
NCCL_VERSION=2.2.13 | |
apt-get update && apt-get install -y --no-install-recommends \ | |
cuda-libraries-$CUDA_PKG_VERSION \ | |
cuda-cublas-9-0=9.0.176.3-1 \ | |
libnccl2=$NCCL_VERSION-1+cuda9.0 | |
# CUDNN install | |
# https://gitlab.com/nvidia/cuda/blob/ubuntu16.04/9.0/runtime/cudnn7/Dockerfile | |
CUDNN_VERSION=7.1.4.18 | |
apt-get update && apt-get install -y --no-install-recommends \ | |
libcudnn7=$CUDNN_VERSION-1+cuda9.0 | |
rm -rf /var/lib/apt/lists/* | |
# Tensorflow | |
# https://github.com/tensorflow/tensorflow/blob/master/tensorflow/tools/docker/Dockerfile.gpu | |
apt-get update && apt-get install -y --no-install-recommends \ | |
build-essential \ | |
cuda-command-line-tools-9-0 \ | |
cuda-cublas-9-0 \ | |
cuda-cufft-9-0 \ | |
cuda-curand-9-0 \ | |
cuda-cusolver-9-0 \ | |
cuda-cusparse-9-0 \ | |
curl \ | |
libcudnn7=7.1.4.18-1+cuda9.0 \ | |
libnccl2=2.2.13-1+cuda9.0 \ | |
libfreetype6-dev \ | |
libhdf5-serial-dev \ | |
libpng12-dev \ | |
libzmq3-dev \ | |
pkg-config \ | |
rsync \ | |
software-properties-common \ | |
unzip && \ | |
apt-get clean && \ | |
rm -rf /var/lib/apt/lists/* | |
# If E: something occured, please try it like below | |
# https://itsfoss.com/fix-ubuntu-install-error/ | |
# sudo killall apt-get | |
# sudo rm /var/lib/apt/lists/lock | |
# sudo rm /var/cache/apt/archives/lock | |
# sudo rm /var/lib/dpkg/lock | |
# sudo dpkg --configure -a | |
# Default: python3 | |
ln -s -f /usr/bin/python3 /usr/bin/python | |
curl -O https://bootstrap.pypa.io/get-pip.py && \ | |
python get-pip.py && \ | |
rm get-pip.py | |
pip --no-cache-dir install \ | |
Pillow \ | |
h5py \ | |
ipykernel \ | |
jupyter \ | |
matplotlib \ | |
numpy \ | |
pandas \ | |
scipy \ | |
sklearn \ | |
tensorflow-gpu==1.9.0 | |
python -m ipykernel.kernelspec | |
# jupyter notebook | |
jupyter notebook --generate-config | |
wget 'https://gist.githubusercontent.com/GzuPark/b70ee9a3fb47ae9598065ac20b5c9743/raw/1ce659f5f9327d1f6da0b85d2baf8170d8a4f67a/jupyter_notebook_config.py' | |
mv jupyter_notebook_config.py .jupyter/ | |
LD_LIBRARY_PATH=/usr/local/cuda/extras/CUPTI/lib64:$LD_LIBRARY_PATH | |
# PyTorch | |
pip install http://download.pytorch.org/whl/cu90/torch-0.4.0-cp35-cp35m-linux_x86_64.whl | |
pip install torchvision | |
# Screen setting | |
wget 'https://gist.githubusercontent.com/GzuPark/6411fee45ee81add9f00925275232074/raw/ca6900be3381e4ac1290959d4687d52d694cebd1/.screenrc' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment