一种比较简洁安装tensorflow的方法

virtualenv安装

1.Install pip and virtualenv by issuing one of the following commands:

sudo apt-get install python-pip python-dev python-virtualenv # for Python 2.7
sudo apt-get install python3-pip python3-dev python-virtualenv # for Python 3.n

2.Create a virtualenv environment by issuing one of the following commands:

virtualenv --system-site-packages targetDirectory # for Python 2.7
virtualenv --system-site-packages -p python3 targetDirectory # for Python 3.n

where targetDirectory specifies the top of the virtualenv tree. Our instructions assume that targetDirectoryis ~/tensorflow, but you may choose any directory.
for an instance:

virtualenv --system-site-packages ~/Code/tensorflow

3.Activate the virtualenv environment by issuing one of the following commands:

source ~/tensorflow/bin/activate # bash, sh, ksh, or zsh
source ~/tensorflow/bin/activate.csh  # csh or tcsh

NOTE: First activation is better
The preceding source command should change your prompt to the following:

(tensorflow)$ 

4.Ensure pip ≥8.1 is installed:

(tensorflow)$ easy_install -U pip

5.Issue one of the following commands to install TensorFlow in the active virtualenv environment:

(tensorflow)$ pip install --upgrade tensorflow      # for Python 2.7
(tensorflow)$ pip3 install --upgrade tensorflow     # for Python 3.n
(tensorflow)$ pip install --upgrade tensorflow-gpu  # for Python 2.7 and GPU
(tensorflow)$ pip3 install --upgrade tensorflow-gpu # for Python 3.n and GPU

If the preceding command succeeds, skip Step 6. If the preceding command fails, perform Step 6.
6. (Optional) If Step 5 failed (typically because you invoked a pip version lower than 8.1), install TensorFlow in the active virtualenv environment by issuing a command of the following format:

(tensorflow)$ pip install --upgrade tfBinaryURL   # Python 2.7
(tensorflow)$ pip3 install --upgrade tfBinaryURL  # Python 3.n

where tfBinaryURL identifies the URL of the TensorFlow Python package. The appropriate value oftfBinaryURLdepends on the operating system, Python version, and GPU support. Find the appropriate value fortfBinaryURL for your system here. For example, if you are installing TensorFlow for Linux, Python 3.4, and CPU-only support, issue the following command to install TensorFlow in the active virtualenv environment:

(tensorflow)$ pip3 install --upgrade \
 https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-1.0.0-cp35-cp35m-linux_x86_64.whl

NOTE: you can pick up URL of the different version tensorflow on the official website

猜你喜欢

转载自blog.csdn.net/zbzb1000/article/details/81154446