zoukankan      html  css  js  c++  java
  • TensorFlow入门:mac 安装 TensorFlow

    开发环境:
    mac os 10.12.5
    Python 2.7.10
    GCC 4.2.1

    mac默认是不带pip的,安装pip。

    sudo easy_install pip

    1.安装virtualenv

    sudo pip install virtualenv --upgrade

    创建一个工作目录:

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

    进行该目录,激活沙箱

    cd ~/tensorflow

    source bin/activate

    2.virtualenv里安装TensorFlow

    进入沙箱后,执行下面的命令来安装TensorFlow:

    (tensorflow)$ sudo pip install tensorflow==1.2.1

    3.运行TensorFlow

     ...

    environment /Users/***/tensorflow

    Successfully installed backports.weakref-1.0rc1 bleach-1.5.0 funcsigs-1.0.2 html5lib-0.9999999 markdown-2.6.8 mock-2.0.0 numpy-1.13.0 pbr-3.1.1 protobuf-3.3.0 six-1.10.0 tensorflow-1.2.1 werkzeug-0.12.

    hello world测试一下:

    $ python
    Python 2.7.10 (default, Feb  7 2017, 00:08:15) 
    [GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.34)] on darwin
    Type "help", "copyright", "credits" or "license" for more information.
    >>> 
    >>> import tensorflow as tf
    >>> hello =tf.constant('hello world!')
    >>> sess = tf.Session()
    2017-07-05 23:58:34.771619: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
    2017-07-05 23:58:34.771654: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
    2017-07-05 23:58:34.771663: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
    2017-07-05 23:58:34.771671: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
    >>> print sess.run(hello)
    hello world!

    恭喜,TensorFlow安装成功了。

    *每次运行TensorFlow程序时,都需要进入tensorflow目录,然后执行source bin/activate 命令来激活沙箱。

    *Ubuntu/Linux也可以按Mac os准备。TensorFlow安装版本分为CPU版和GPU版,区别在于:

    (tensorflow)$ sudo pip install tensorflow==1.2.1

    (tensorflow)$ sudo pip install tensorflow-gpu==1.2.1

  • 相关阅读:
    已知用经纬度表示的两点,求两点之间的直线距离
    linux 管道--转
    Five ways to maximize Java NIO and NIO.2--reference
    java获取当前方法
    事务策略: 了解事务陷阱--转
    实例详解 EJB 中的六大事务传播属性--转
    全面分析 Spring 的编程式事务管理及声明式事务管理--转
    Spring 事务管理高级应用难点剖析--转
    Java NIO——Selector机制源码分析---转
    Java NIO类库Selector机制解析--转
  • 原文地址:https://www.cnblogs.com/gsyun/p/7124065.html
Copyright © 2011-2022 走看看