Introduction
$ cd ~/Downloads
$ sudo dpkg -i lantern-installer-64-bit.deb
Content
Install tensorflow has 7 steps:
- install CUDA
- install cnDNN
- install Anaconda
- set environment variables
- create virtual environment of Python
- install Tensorflow
- validate the installation
1. install CUDA 9.0
- . For details, see . Ensure that you append the relevant CUDA pathnames to the
LD_LIBRARY_PATH
environment variable as described in the NVIDIA documentation.
Details:
(a) install Base Installer: sudo sh cuda_9.0.176_384.81_linux.run
(b) install Patch 1: sudo sh cuda_9.0.176.1_linux.run
(c) install Patch 2: sudo sh cuda_9.0.176.2_linux.run
Validation:
$ cd /usr/local/cuda-9.0/samples/5_Simulations/nbody
$ sudo make
$ ./nbody
If you can see a new window popped up with animation, you install CUDA 9.0 success!
We add the environment variable after cuDNN installed.
2. install cuDNN
- . For details, see . Ensure that you create the
CUDA_HOME
environment variable as described in the NVIDIA documentation.
Details:
(a) install cuDNN deb package: sudo dpkg -i libcudnn7_7.1.3.16-1+cuda9.0_amd64.deb
3. install Anaconda
Anaconda is the python environment. We can install tensorflow in Anaconda virtual environment as it is install and uninstall easliy. Besides, Anaconda contains most common python packages, so that we need not install by ourselves.
4. set environment variables
We should put the cuda, cudnn and anaconda path to the environment variables.
Steps:
(1) open the environment variable file.
$ sudo gedit ~/.bashrc
(2) copy the below 4 lines to the end of .bashrc
file (Please replace the your_name
in the path).
. /home/your_name/anaconda2/etc/profile.d/conda.sh
export CUDA_HOME=/usr/local/cuda
export PATH="$PATH:/usr/local/cuda-9.0/bin"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64:/usr/local/cuda/extras/CUPTI/lib64"
5. create virtual environment of Python
Create a conda environment named "xxx" (e.g. tensorflow) to run a version of Python by invoking the following command:
$ conda create -n tensorflow python=2.7[or python=3.3, etc.]
Then you can go into the virtual environment by commands below:
# Activate the conda environment by issuing the following command:
$ source activate tensorflow
(tensorflow)$
# If you want go out of current prompt
$ source deactivate
6. install Tensorflow
Issue a command of the following format to install TensorFlow inside your conda environment:
(tensorflow)$ pip install --ignore-installed --upgrade [tfBinaryURL]
7. validate the installation
Run a short TensorFlow program
Invoke python from your shell as follows:
$ python
Enter the following short program inside the python interactive shell:
# Python
import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))
If the system outputs the following, then you are ready to begin writing TensorFlow programs:
Hello, TensorFlow!