使用Virtualenv安装TensorFlow

Install pip and Virtualenv:

$ sudo easy_install pip
$ sudo pip install --upgrade virtualenv

Create a Virtualenv environment in the directory ~/tensorflow:

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

Activate the environment:

$ source ~/tensorflow/bin/activate  # If using bash
$ source ~/tensorflow/bin/activate.csh  # If using csh
(tensorflow)$  # Your prompt should change

Now, install TensorFlow just as you would for a regular Pip installation. First select the correct binary to install:

# Mac OS X, GPU enabled, Python 2.7:
(tensorflow)$ export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/mac/gpu/tensorflow_gpu-0.12.0-py2-none-any.whl

Finally install TensorFlow:

(tensorflow)$ pip install --upgrade $TF_BINARY_URL

When you are done using TensorFlow, deactivate the environment.

(tensorflow)$ deactivate
$  # Your prompt should change back

To use TensorFlow later you will have to activate the Virtualenv environment again:

$ source ~/tensorflow/bin/activate  # If using bash.
$ source ~/tensorflow/bin/activate.csh  # If using csh.
(tensorflow)$  # Your prompt should change.
# Run Python programs that use TensorFlow
....
# When you are done using TensorFlow, deactivate the environment.
(tensorflow)$ deactivate
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

友情链接更多精彩内容