We assume that you have already Python 2+ (or 3+) and pip (or pip3) are installed on your system. If so, the following are the steps to install TensorFlow:
- Create a virtualenv environment as follows:
$ virtualenv --system-site-packages targetDirectory
The targetDirectory signifies the root of the virtualenv tree. By default it is ~/tensorflow (however, you may choose any directory).
- Activate the virtualenv environment as follows:
$ source ~/tensorflow/bin/activate # bash, sh, ksh, or zsh
$ source ~/tensorflow/bin/activate.csh # csh or tcsh
If the command succeeds in Step 2, then you should see following on your terminal:
(tensorflow)$
- Install TensorFlow:
Use one of the following commands to install TensorFlow in the active virtualenv environment. For Python 2.7 with CPU only support, use the following command:
(tensorflow)$ pip install --upgrade tensorflow
- For Python 3.x with CPU only supports, use the following command:
(tensorflow)$ pip3 install --upgrade tensorflow
- For Python 2.7 with GPU support, use the following command:
(tensorflow)$ pip install --upgrade tensorflow-gpu
- For Python 3.x with GPU supports, use the following command:
(tensorflow)$ pip3 install --upgrade tensorflow-gpu
If the preceding command succeeds, skip Step 5. If the preceding command fails, perform Step 5.
If Step 3 failed, try to install TensorFlow in the active virtualenv environment by issuing a command in the following format. For Python 2.7 (select appropriate URL with CPU or GPU support).
(tensorflow)$ pip install --upgrade TF_PYTHON_URL
For Python 3.x (select appropriate URL with CPU or GPU support).
(tensorflow)$ pip3 install --upgrade TF_PYTHON_URL
For Python 2.7 with CPU/GPU support, select the appropriate value of TF_PYTHON_URL. For both cases, TF_PYTHON_URL signifies the URL of the TensorFlow Python package presented at this URL: https://www.tensorflow.org/install/install_linux#the_url_of_the_tensorflow_python_package.
For example, to install the latest version with CPU only support (currently v1.0.1), use the following command:
(tensorflow)$ pip3 install --upgrade
https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp34-cp34m-linux_x86_64.whl
To validate the installation in Step 3, you must activate the virtual environment. If the virtualenv environment is not currently active, issue one of the following commands:
$ source ~/tensorflow/bin/activate # bash, sh, ksh, or zsh
$ source ~/tensorflow/bin/activate.csh # csh or tcsh
To uninstall TensorFlow, simply remove the tree you created. For example:
$ rm -r targetDirectory