Created
December 25, 2018 02:48
-
-
Save kbeathanabhotla/4eb8791713d2a567bb011fc45601eb5d 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
Tensorrflow installation on Ubuntu | |
---------------------------------------- | |
Required Steps: | |
------------------ | |
- Install Nvidia GPU drivers | |
- Install Cuda | |
- Install CudNN | |
- Install Anaconda | |
- Install tensorflow | |
- Run sample program to test | |
Install Nvidia GPU drivers | |
--------------------------- | |
lspci | grep NVIDIA // to see if graphic card is connected to the machine | |
Add the drivers repository using the following command | |
sudo add-apt-repository ppa:graphics-drivers/ppa | |
Update and install NVIDIA drivers using the following two commands | |
sudo apt update | |
sudo apt install nvidia-390 | |
Restart the machine | |
After restart type in the following command to verify if graphic drivers are installed | |
nvidia-smi | |
-- NVIDIA DRIVERS ARE INSTALLED -- | |
Install Cuda | |
-------------- | |
As Tensorflow currently support CUDA 9.0 only we are going to install CUDA 9.0 thought the latest version of CUDA is 10.0 | |
Download appropriate CUDA distribution run file from the following link suitable for your operaing system | |
https://developer.nvidia.com/cuda-90-download-archive | |
chmod +x cuda_9.0.176_384.81_linux.run | |
to install CUDA, run the .run file using the following command and follow the steps in the wizard | |
./cuda_9.0.176_384.81_linux.run | |
After the installation is complete, add the following lines to ~/.bashrc at the end | |
export CUDA_HOME=/usr/local/cuda | |
export PATH=$CUDA_HOME/bin:$PATH | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64 | |
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64 | |
Open /etc/ld.so.conf and add the following line at the end | |
/usr/local/cuda-9.0/lib64 | |
run the following command | |
sudo ldconfig | |
Once this command runs successfully, verify CUDA installation using the following command | |
nvcc --version | |
This command should print out CUDA version | |
Now enable persistence mode for the GPU using the following command | |
sudo nvidia-smi -pm 1 | |
-- CUDA is Installed -- | |
Install CudNN | |
-------------- | |
As we are using CUDA 9.0 download CUDNN version that matches CUDA-9.0 and download a generic Linux distribution from the following link | |
https://developer.nvidia.com/rdp/cudnn-download | |
Extract and copy the files to respective locations using the following commands | |
tar -xvzf cudnn-9.0-linux-x64-v7.4.2.24.tgz | |
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/ | |
sudo cp cuda/lib64/* /usr/local/cuda/lib64/ | |
sudo chmod a+r /usr/local/cuda/lib64/libcudnn* | |
-- CUDNN is installed -- | |
Install Anaconda | |
---------------- | |
Download Anaconda Python version that Tensorflow supports, here we have downloaded Python 3.6 from the following link | |
https://repo.anaconda.com/archive/ | |
chmod +x Anaconda3-5.1.0-Linux-x86_64 | |
Install Anaconda Python using the following command and follow the wizard | |
./Anaconda3-5.1.0-Linux-x86_64 | |
Once the installation is done, open a new terminal and verify python installation using | |
python --version | |
-- Anaconda Python is installed -- | |
Install Tensorflow | |
------------------ | |
Install Tensorflow using the following command | |
pip install tensorflow-gpu | |
-- Tensorflow is installed -- | |
Sample program to Test | |
-------------------------- | |
Once the installation completes, verify the installation using the following command | |
python -c "import tensorflow as tf; tf.enable_eager_execution(); print(tf.reduce_sum(tf.random_normal([1000, 1000])))" | |
From the logs you can see that Tensorflow using GPU to compute | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment