Skip to content

Instantly share code, notes, and snippets.

@jaassoon
Created July 1, 2018 01:43
Show Gist options
  • Save jaassoon/866484b3d13be387911223d7c27ff841 to your computer and use it in GitHub Desktop.
Save jaassoon/866484b3d13be387911223d7c27ff841 to your computer and use it in GitHub Desktop.
# cuda.sh
# check if GPU ready
lspci | grep -i nvidia
# If NVIDIA driver was installed via the *.run file:
# sudo nvidia-uninstall
yum install -y gcc gcc-c++ kernel-devel kernel-headers
yum install -y libXmu libXmu-devel mesa-libGLU mesa-libGLU-devel \
libX11-common.noarch libX11-devel libX11 \
libXi libXi-devel
yum -y update
yum -y upgrade
uname -r
# 3.10.0-693.21.1.el7.centos.plus
NV_VERSION=375.66
# curl http://us.download.nvidia.com/XFree86/Linux-x86_64/${NV_VERSION}/NVIDIA-Linux-x86_64-${NV_VERSION}.run -o NVIDIA-Linux-x86_64-${NV_VERSION}.run
chmod +x NVIDIA-Linux-x86_64-${NV_VERSION}.run
NV_VERSION=375.66
./NVIDIA-Linux-x86_64-${NV_VERSION}.run --kernel-source-path /usr/src/kernels/3.10.0-693.21.1.el7/
pwd
# curl http://developer.download.nvidia.com/.../cuda_9.1.85_387.26_linux.run? -o cuda_9.1.85_387.26_linux.run
chmod +x cuda_9.1.85_387.26_linux.run
./cuda_9.1.85_387.26_linux.run --kernel-source-path /usr/src/kernels/3.10.0-693.21.1.el7
./cuda_9.1.85_387.26_linux.run --silent --toolkit --toolkitpath=/mycuda/toolkit \
--samples --samplespath=/mycuda/kitsamples --tmpdir=/mycuda/kittmp
pwd
export CUDA_HOME=/usr/local/cuda-9.1
# export CUDA_HOME=/mycuda/toolkit
export PATH=/usr/local/cuda-9.1/bin/:$PATH
# export PATH=/mycuda/toolkit/bin/:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64/:$LD_LIBRARY_PATH
# export LD_LIBRARY_PATH=/mycuda/toolkit/lib64/:$LD_LIBRARY_PATH
source ~/.bashrc
nvcc --version
# CUDA Version 9.1.85
cat /usr/local/cuda-9.1/version.txt
# cat /mycuda/toolkit/version.txt
nvidia-smi
pwd
Please make sure that
- PATH includes /usr/local/cuda-9.1/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-9.1/lib64, or, add /usr/local/cuda-9.1/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-9.1/bin
To uninstall the NVIDIA Driver, run nvidia-uninstall
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-9.1/doc/pdf for detailed information on setting up CUDA.
Logfile is /tmp/cuda_install_1615.log
# -------cuda-ready------▲▲▲▲▲▲▲▲▲▲▲▲▲
Amazon is making two of these new GPU instance types available for now.
The g2.2xlarge version comes with 15 GiB memory, 60 GB of local storage,
26 EC2 Compute Units ( an Intel Sandy Bridge processor running at 2.6 GHz)
and a single NVIDIA Kepler GK104 graphics card (with 1536 CUDA cores).
curl \
https://us.download.nvidia.com/XFree86/Linux-x86_64/390.48/NVIDIA-Linux-x86_64-390.48.run \
-o NVIDIA-Linux-x86_64-390.48.run
# -------cudnn.sh-------vvvvvvvvvvvv
https://docs.nvidia.com/deeplearning/sdk/cudnn-install/index.html
curl \
http://developer.download.nvidia.com/compute/machine-learning/cudnn/secure/v7.1.3/prod/9.1_20180414/cudnn-9.1-linux-x64-v7.1.tgz?nnjwKXbPgS-lE38vC3K8rAO8QzfArwYZlCsRkk1VZoqtapEiMJOn2ZZ_xx8ipjwX1aVHu0dKfzFxLNUiJ1Mo708TutthEk1qMP0JQH--zGs0ayKeC4g8Id62lCHxGy2Q1w1PoJGRpOmDTtUgiLqxAaq8QwF7hh4yEppZ4vvW3w7xfS06xzsjXiNm56U2-wN923i4hFlGJffmLQ \
-o cudnn-9.1-linux-x64-v7.1.tgz
tar -xzvf cudnn-9.1-linux-x64-v7.1.tgz
# Copy the following files into the CUDA Toolkit directory.
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*
# check if ready
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
# export -p
declare -x CUDA_HOME="/usr/local/cuda-9.1"
declare -x LD_LIBRARY_PATH="/usr/local/cuda-9.1/lib64/:"
declare -x PATH=/usr/local/cuda-9.1/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbi
vi ~/.bashrc
export CUDNN_INCLUDE_DIR=/usr/local/cuda/include
export CUDNN_LIB_DIR=/usr/local/cuda/lib64
source ~/.bashrc
python -c 'import torch;print torch.backends.cudnn.version()'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment