摘抄自https://www.tensorflow.org/install/install_sources
其实没必要写本文的,安装比caffe简单多了。
Installing Bazel on Ubuntu
1. Install JDK 8
Install JDK 8 by using:
sudo apt-get install openjdk-8-jdk
2. Add Bazel distribution URI as a package source (one time setup)
echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
3. Install and update Bazel
sudo apt-get update && sudo apt-get install bazel
Once installed, you can upgrade to a newer version of Bazel with:
sudo apt-get upgrade bazel
Install python dependencies
sudo apt-get install python-numpy python-dev python-pip python-wheelOptional: install TensorFlow for GPU prerequisites
sudo apt-get install libcupti-devClone the TensorFlow repository
git clone https://github.com/tensorflow/tensorflowcd tensorflowgit checkoutBuild the pip package
To build a pip package for TensorFlow with CPU-only support,you would typically invoke the following command:
$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_packageTo build a pip package for TensorFlow with GPU support,invoke the following command:
$ bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_package$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkgInstall the pip package
sudo pip install /tmp/tensorflow_pkg/tensorflow-1.4.0-cp27-cp27mu-linux_x86_64.whlValidate your installation
Change directory (
cd
) to any directory on your system other than thetensorflow
subdirectory from which you invoked theconfigure
command.Invoke python:
$ pythonEnter 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 writingTensorFlow programs:
Hello, TensorFlow!