ubuntu16.04安装tensorflow

Take the following steps to install TensorFlow with 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 targetDirectory is ~/tensorflow, but you may choose any directory.

  3. 创建 Virtualenv 虚拟环境:

      进入你想安装tensorflow的父目录下,然后执行下面命令建立虚拟环境:

    1
    virtualenv --system-site-packages tensorflow
  4. 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

    The preceding source command should change your prompt to the following:

    (tensorflow)$ 
    1. 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.

    1. (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 of tfBinaryURLdepends on the operating system, Python version, and GPU support. Find the appropriate value for tfBinaryURL 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/cpu/tensorflow-1.4.0-cp34-cp34m-linux_x86_64.whl

    If you encounter installation problems, seeCommon Installation Problems.

 测试安装:

  在终端执行如下命令进入python shell环境:

1
python

   在python shell环境中测试:

1
2
3
4
5
6
7
8
9
10
>>>  import  tensorflow as tf
>>> hello  =  tf.constant( 'Hello, TensorFlow!' )
>>> sess  =  tf.Session()
>>>  print (sess.run(hello))
Hello, TensorFlow!
>>> a  =  tf.constant( 10 )
>>> b  =  tf.constant( 32 )
>>>  print (sess.run(a  +  b))
42
>>>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值