tensorflow的安装

  1. binary安装(推荐)

注意需要能访问外网

Install pip (or pip3 for python3) if it is not already installed:

# Ubuntu/Linux 64-bit
$ sudo apt-get install python-pip python-dev

# Mac OS X
$ sudo easy_install pip

Install TensorFlow:

# Ubuntu/Linux 64-bit, CPU only:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.7.0-py2-none-linux_x86_64.whl

# Ubuntu/Linux 64-bit, GPU enabled:
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.7.0-py2-none-linux_x86_64.whl

# Mac OS X, CPU only:
$ sudo easy_install --upgrade six
$ sudo pip install --upgrade https://storage.googleapis.com/tensorflow/mac/tensorflow-0.7.0-py2-no

来自 <https://www.tensorflow.org/versions/r0.7/get_started/os_setup.html>

  1. 源代码安装

    注意也是需要能访问外网,bazel编译tensorflow时候也需要访问外网

    2.1 下载最新的bazel(tensorflow采用bazel进行编译)

    https://github.com/bazelbuild/bazel/releases

    https://github.com/bazelbuild/bazel/releases/download/0.1.5/bazel-0.1.5-installer-linux-x86_64.sh

    2.2 下载最新的tensorflow代码

    git clone --recurse-submodules https://github.com/tensorflow/tensorflow

    一些编译依赖的python库安装(wheel安装.whl需要)

    $ sudo apt-get install python-numpy swig python-dev wheel

    cd tensorflow

    #CPU版本

    $ bazel build -c opt //tensorflow/tools/pip_package:build_pip_package

    #GPU版本

    $bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package

    编译大概需要10-15分钟

    #生成binary安装的whl

    $rm -rf /tmp/tensorflow_pkg

    $ ./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

    # The name of the .whl file will depend on your platform.
    $ sudo pip install /tmp/tensorflow_pkg/tensorflow*.whl

    cd ..

    ipython:

    import tensorflow as tf

    print tf.__version__

    另外在 https://www.tensorflow.org/versions/r0.7/get_started/os_setup.html>介绍了 使用 Virtualenv install 以及 Docker install

  2. 如果是GPU机器建议可以直接pip install 一个GPU版本,然后用virtualevn安装一个CPU版本,这样方便对比实验。

上一篇:提取肤色信息原理及操作——opencv


下一篇:关联容器(map):支持高效查找的容器,一种键值对的集合。