使用虚拟沙箱安装Tensorflow

来源:互联网 发布:淘宝813 编辑:程序博客网 时间:2024/06/08 07:33

—————多用户环境中,使用虚拟沙箱隔离安装—————-
1,安装虚拟沙箱包

sudo apt-get install python-pip python-dev python-virtualenv 

2,创建虚拟沙箱

virtualenv --system-site-packages targetDirectory

3,激活虚拟沙箱

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

4,在虚拟沙箱中安装tensorflow

 (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

5,(可选)如果第四步失败了,那么使用如下命令安装tensorflow:

(tensorflow)$ pip install --upgrade TF_PYTHON_URL   # Python 2.7 (tensorflow)$ pip3 install --upgrade TF_PYTHON_URL  # Python 3.N 

这里具体的URL请参考如下链接:https://www.tensorflow.org/install/install_linux#the_url_of_the_tensorflow_python_package

验证步骤:
1,每次使用TensorFlow的时候都需要激活虚拟沙箱,使用如下命令:

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

每次使用完,需要去激活操作:
deactivate

激活虚拟沙箱后,在 virtualenv 内, 安装 TensorFlow:

(tensorflow)$ pip install --upgrade <$url_to_binary.whl>

接下来, 使用类似命令运行 TensorFlow 程序:

(tensorflow)$ cd tensorflow/models/image/mnist(tensorflow)$ python convolutional.py
0 0
原创粉丝点击