#! /bin/bash # Refer to https://gist.github.com/lyastro/26e0cd8245bcf64914857dd5e8445724 # Preliminary requirement: # CUDA GPU(s) is (are) present # gcc gcc-c++ python-pip python-devel atlas atlas-devel gcc-gfortran openssl-devel libffi-devel are present # NVIDIA CUDA toolkit and driver are installed. For CentOS 7, it is found out that only nvidia cuda version 9.0 will work. 9.2 or 10 don't. # To this end, use http://comsics.usm.my/tlyoon/configrepo/howto/customise_centos/nvidia_cuda/inst_cuda_centos_localrunfile.txt to first install cuda 9.2 (if you not have already done so). # Then download and install cuda-9.0 using local runfile, but choose not to install the graphic card driver. Install only the 9.0 toolkit. This is done via the following lines: cd /share/apps/configrepo wget -O cuda_9.0.176_384.81_linux-run https://developer.nvidia.com/compute/cuda/9.0/Prod/local_installers/cuda_9.0.176_384.81_linux-run chmod +x cuda_9.0.176_384.81_linux-run ./cuda_9.0.176_384.81_linux-run ## patch 1 wget -O cuda_9.0.176.1_linux-run https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/cuda_9.0.176.1_linux-run chmod +x cuda_9.0.176.* ./cuda_9.0.176.1_linux-run ## patch 2 wget -O cuda_9.0.176.2_linux-run https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/cuda_9.0.176.2_linux-run chmod +x cuda_9.0.176.* ./cuda_9.0.176.2_linux-run ## patch 3 wget -O cuda_9.0.176.3_linux-run https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/cuda_9.0.176.3_linux-run chmod +x cuda_9.0.176.* ./cuda_9.0.176.3_linux-run ## patch 4 wget -O cuda_9.0.176.4_linux-run https://developer.nvidia.com/compute/cuda/9.0/Prod/patches/1/cuda_9.0.176.4_linux-run chmod +x cuda_9.0.176.* ./cuda_9.0.176.4_linux-run # Once cuda-9.0 is installed, proceed to install cudnn. This step has to be done manually. # Go to https://developer.nvidia.com/rdp/cudnn-download to download the latest cudnn for linux version in a new directory /share/apps/configurepo/cudnn-download. Need to register manually before downloading. mkdir cudnn-download cd cudnn-download ### download cudnn-10.0-linux-x64-v7.3.1.20.solitairetheme8 to here tar -zxf cudnn-10.0-linux-x64-v7.3.1.20.solitairetheme8 ### or any newer version cd cuda cp include/cudnn.h /usr/local/cuda/include/ cp lib64/libcudnn* /usr/local/cuda/lib64/. chmod a+x /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn* pip install --upgrade pip pip install tensorflow-gpu pip install ipython # Check Tensorflow with ipython ipython ## In [1]: import tensorflow as tf ## In [2]: sess = tf.Session(config=tf.ConfigProto(log_device_placement=True)) ## check nvidia-smi to see GPU status. ## If the tensorflow test fails to run, try to link /usr/local/cuda to /usr/local/cuda-9.0 in your ~/.bashrc.