Skip to content

Instantly share code, notes, and snippets.

@kbeathanabhotla
Last active November 10, 2018 09:08
Show Gist options
  • Save kbeathanabhotla/6ea09f6c094a23c3aaf4b8b8311c76ce to your computer and use it in GitHub Desktop.
Save kbeathanabhotla/6ea09f6c094a23c3aaf4b8b8311c76ce to your computer and use it in GitHub Desktop.
Steps to install:
------------------
Following steps
- Install Nvidia GPU drivers
- Install Cuda
- Install CudNN
- Install Anaconda
- Install tensorflow
- Run sample program to test
Install Nvidia GPU drivers
---------------------------
/sbin/lspci // See if Nvidia graphic card is installed on machine
nvidia-smi // See if Nvidia drivers are installed
// Installing kernel modules which are used to build CUDA related libraires during installation
yum install -y gcc kernel-devel-`uname -r`
yum install -y kernel-devel
yum install -y kernel-xen-devel
// getting drivers
wget -O /tmp/NVIDIA-Linux-x86_64-367.48.run https://go.microsoft.com/fwlink/?linkid=836899
chmod +x NVIDIA-Linux-x86_64-367.48.run
// Installing drivers
sudo sh ./NVIDIA-Linux-x86_64-367.48.run
- This is a wizard and after completion the drivers would have been installed
// verifying NVIDIA drivers are installed
nvidia-smi
-- NVIDIA DRIVERS ARE INSTALLED --
Install Cuda
--------------
// Necessary modules required for cuda installation
wget ftp://ftp.pbone.net/mirror/ftp5.gwdg.de/pub/opensuse/repositories/home:/Kenzy:/modified:/C7/CentOS_7/noarch/dkms-2.2.0.3-31.1.noarch.rpm
rpm -ivh dkms-2.2.0.3-31.1.noarch.rpm
yum install gcc
yum install xorg-x11-drv-nvidia.x86_64
// Download cuda repo rpm install that would add cuda repos to the system repo
wget http://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-repo-rhel7-8.0.44-1.x86_64.rpm
rpm -ivh cuda-repo-rhel7-8.0.44-1.x86_64.rpm
// installing cuda
yum install cuda
yum install cuda-drivers
// verifying installation
nvidia-smi -q | head
cat /proc/driver/nvidia/version
sudo nvidia-smi -pm 1
-- CUDA is Installed --
Install CudNN
--------------
// Download CudNN from nvidia website
// You can obtain link after you register on their website
// Below link is just an example which was obtained during installation
wget http://developer.download.nvidia.com/compute/machine-learning/cudnn/secure/v5.1/prod_20161129/8.0/cudnn-8.0-linux-x64-v5.1.tgz?autho=1488453489_8e6ecf227b9e6d3304327dd530ebda3a&file=cudnn-8.0-linux-x64-v5.1.tgz
// Extract, copy and grant necessary permissions to CudNN libraries
tar -xvzf cudnn-8.0-linux-x64-v5.1.tgz
cp cuda/include/cudnn.h /usr/local/cuda/include/
cp cuda/lib64/* /usr/local/cuda/lib64/
chmod a+r /usr/local/cuda/lib64/libcudnn*
// Update LD_LIBRARY_PATH on bashrc to add Cuda to classpath
vi ~/.bashrc
add the following lines at the end of file
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
export CUDA_HOME=/usr/local/cuda
-- CUDNN is installed --
Install Anaconda
----------------
wget https://repo.continuum.io/archive/Anaconda2-4.3.0-Linux-x86_64.sh
chmod +x Anaconda2-4.3.0-Linux-x86_64.sh
./Anaconda2-4.3.0-Linux-x86_64.sh
-- Anaconda is installed --
Install Tensorflow
------------------
conda create -n tensorflow
source activate tensorflow
// this URL has to be lookedat from tensorflow website
pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.0-cp27-none-linux_x86_64.whl
-- Tensorflow is installed --
Run sample program to test
--------------------------
open python shell and run the following program to verify if 'Hello World' program os tensorflow is running
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))
print(sess.run(hello))
-- From logs you can see if tenaorflow was installed properly --
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment