Install Required Packages
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java8-installer git python-dev python3-dev build-essential python-pip python3-pip python-virtualenv swig python-wheel libcurl3-dev
sudo apt-get install libcupti-dev
Install Bazel
Instructions also onBazelwebsite
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add -
sudo apt-get update
sudo apt-get install bazel
sudo apt-get upgrade bazel
Option 2: Building from source
In case you prefer building from source, it's unfortunately not as easy as cloning the Git repository and typing make. Recent versions of Bazel can only be built with Bazel, unless one downloads a distribution source build, which contains some already pre-generated files. With one such installation in place, one could build Bazel straight from the repository source, but that's probably not necessary.
So we will go with building a distribution build, which is reasonably straightforward:
1. Install required packages
sudo apt-get install pkg-config zip g++ zlib1g-dev unzip python
2. Download Bazel
Go to Bazel's GitHub releases page.
Download the binary installer bazel-0.5.2-installer-linux-x86_64.sh. This installer contains the Bazel binary and the required JDK, and can be used even if JDK is already installed.
Note that bazel-0.5.2-without-jdk-installer-linux-x86_64.sh also exist. It is a version without embedded JDK 8. Only use this installer if you already have JDK 8 installed.
3. Run the installer
Run the installer:
chmod +x bazel-0.5.2-installer-linux-x86_64.sh
./bazel-0.5.2-installer-linux-x86_64.sh --user
The --user flag installs Bazel to the $HOME/bin directory on your system and sets the .bazelrc path to $HOME/.bazelrc. Use the --help command to see additional installation options.
4. Set up your environment
If you ran the Bazel installer with the --user flag as above, the Bazel executable is installed in your $HOME/bin directory. It's a good idea to add this directory to your default paths, as follows:
export PATH="$PATH:$HOME/bin"
You can also add this command to your ~/.bashrc file.
Download a distribution package from the releases page. The current version at the time of writing was 0.5.3.
$ mkdir bazel && cd bazel wget https://github.com/bazelbuild/bazel/releases/download/0.5.4/bazel-0.5.4-dist.zip $ wget https://github.com/bazelbuild/bazel/releases/download/0.5.4/bazel-0.5.4-dist.zipUnzip the sources. This being a zip file, the files are stored without containing folder. Glad we already put it in its own directory...
$ unzip bazel-0.5.3-dist.zipCompile Bazel
$ bash ./compile.shThe output executable is now located in
output/bazel. Add aPATHentry to your.bashrc, or just export it in your current shell:$ export PATH=`pwd`/output:$PATH
You should now be able to call the bazel executable from anywhere on your filesystem.
Install Nvidia Toolkit 8 & CudNN6
To install the Nvidia Toolkit download .deb file from Nvidia website
cuda8.0 https://developer.nvidia.com/cuda-80-download-archive
sudo dpkg -i cuda-repo-ubuntu1404-*amd64.deb
sudo apt-get update
sudo apt-get install cuda
This will install cuda into: /usr/local/cuda
To install CudNN
download cudNN v6 for Cuda 8.0 from Nvidia website and extract into /usr/local/cuda via:
tar xvzf cudnn-7.5-linux-x64-v5.0-ga.tgz
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*
update your bash file:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64"
export CUDA_HOME=/usr/local/cuda
export DYLD_LIBRARY_PATH="$DYLD_LIBRARY_PATH:$CUDA_HOME/lib"
export PATH="$CUDA_HOME/bin:$PATH"
Configure TensorFlow Installation
git clone https://github.com/tensorflow/tensorflow
cd ~/tensorflow
./configure
Use defaults by pressing enter for all except:
Please specify the location of python. [Default is /usr/bin/python]: [enter]
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] n
No Google Cloud Platform support will be enabled for TensorFlow
Do you wish to build TensorFlow with GPU support? [y/N] y
GPU support will be enabled for TensorFlow
Please specify which gcc nvcc should use as the host compiler. [Default is /usr/bin/gcc]: [enter]
Please specify the Cuda SDK version you want to use, e.g. 7.0. [Leave empty to use system default]: 8.0
Please specify the location where CUDA 8.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: [enter]
Please specify the Cudnn version you want to use. [Leave empty to use system default]: 5
Please specify the location where cuDNN 5 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: [enter]
Please specify a list of comma-separated Cuda compute capabilities you want to build with.
You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus.
Please note that each additional compute capability significantly increases your build time and binary size.
[Default is: "3.5,5.2"]: 5.2,6.1 [see https://developer.nvidia.com/cuda-gpus]
Setting up Cuda include
Setting up Cuda lib64
Setting up Cuda bin
Setting up Cuda nvvm
Setting up CUPTI include
Setting up CUPTI lib64
Configuration finished
Build TensorFlow
bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package