This article describes TensorFlow source code mode installation. The installed system is Ubuntu 15.04.
Get TensorFlow Source code
git clone--recurse-submodules Https://github.com/tensorflow/tensorflow
Use --recurse-submodules the options to get the Protobuf library file that TensorFlow needs to rely on.
Installing Bazel
Follow the instructions below to install Bazel dependencies. Bazel installation files:
Bazel default needs to use JDK1.8, if you use JDK1.7, please download the appropriate installation package.
Install Bazel other required dependencies:
sudo apt-get install pkg-config zip g++ zlib1g-dev Unzip
Execute the following command to install Bazel:
chmod +x Path_to_install.sh./path_to_install. SH--user
Remember to put Path_to_install. SH is replaced with the Bazel installation file name you downloaded, such as:
./bazel-0.1.4-installer-linux-x86_64.sh --user
Install other dependencies
sudo apt-get install python-numpy swig Python-dev
Configure the installation
Run the script under the TensorFlow root directory configure . This script will ask you to enter the installation path of the Python interpreter and allow you to choose to install the Cuda library.
If you do not install CUDA, this step is primarily to locate the Python and NumPy header files:
./configureplease specify the location of Python. [Default Is/usr/bin/python]:
If you are installing CUDA, you need to specify the CUDA installation location in addition to Python:
./configureplease specify the location of Python. [Default Is/usr/bin/python]:D o wish to build TensorFlow with GPU support? [y/n] YGPU support would be-enabled for Tensorflowplease specify, where CUDA 7.0 toolkit is installed. Refer toreadme.md for more details. [Default is:/usr/local/cuda]:/usr/local/cudaplease Specify the location where the CuDNN V2 library is installed. Refer toreadme.md for more details. [Default is:/usr/local/cuda]:/usr/local/cudasetting to Cuda includesetting up Cuda lib64setting to Cuda binsetting up Cu Da Nvvmconfiguration finished
Building a GPU-enabled TensorFlow
Execute the following command in the TensorFlow root directory:
$ Bazel build-c opt--config=cuda--spawn_strategy=standalone//tensorflow/cc:tutorials_example_trainer$ bazel-bin/ Tensorflow/cc/tutorials_example_trainer--use_gpu# Lots of output. This tutorial iteratively calculates the major eigenvalueof # a 2×2 matrix, on GPU. The last few lines look like this.000009/000005 lambda = 2.000000 x = [0.894427-0.447214] y = [1.788854-0.894427]000006/ 000001 lambda = 2.000000 x = [0.894427-0.447214] y = [1.788854-0.894427]000009/000009 lambda = 2.000000 x = [0.894427-0 .447214] y = [1.788854-0.894427]
Note that '--config=cuda ' is needed to enable the GPU support.
TensorFlow Source Code mode installation