Ubuntu14.04中的Tensorflow安装

时间:2017-09-03 09:17:38

标签: python tensorflow

我在我的Ubuntu14.04上安装了tensorflow,我用Anaconda安装了它。我按照官方安装指南。安装后,我一步一步地运行这个代码。出错了。

[2, 2, 150, 150, 150, 70, 70, 70, 150]

当我跑步时

import tensorflow as tf
hello = tf.constant('Hello, TensorFlow!')
sess = tf.Session()
print(sess.run(hello))

它说:

sess = tf.Session()

1 个答案:

答案 0 :(得分:0)

这不是真正的"错误"。 informing you如果您从源代码安装了支持所提到的指令,例如SSE4.1,SSE4.2等,那么计算可能会更快。

你可以继续使用Tensorflow,虽然它不会像从源代码编译那么快。

如果要在启用这些说明的情况下安装Tensorflow,则必须:

  1. 安装Bazel
  2. 从其中一个可用的releases下载,例如0.5.2。 解压缩,进入目录并进行配置:bash ./compile.sh。 将可执行文件复制到/usr/local/binsudo cp ./output/bazel /usr/local/bin

    1. 安装Tensorflow
    2. 克隆张量流:git clone https://github.com/tensorflow/tensorflow.git 转到克隆目录进行配置:./configure

      它会提示您几个问题,下面我建议您回答每个问题,当然,您可以根据自己的喜好选择自己的答案:

      Using python library path: /usr/local/lib/python2.7/dist-packages
      Do you wish to build TensorFlow with MKL support? [y/N] y
      MKL support will be enabled for TensorFlow
      Do you wish to download MKL LIB from the web? [Y/n] Y
      Please specify optimization flags to use during compilation when bazel option "--config=opt" is specified [Default is -march=native]: 
      Do you wish to use jemalloc as the malloc implementation? [Y/n] n
      jemalloc disabled
      Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] N
      No Google Cloud Platform support will be enabled for TensorFlow
      Do you wish to build TensorFlow with Hadoop File System support? [y/N] N
      No Hadoop File System support will be enabled for TensorFlow
      Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] N
      No XLA JIT support will be enabled for TensorFlow
      Do you wish to build TensorFlow with VERBS support? [y/N] N
      No VERBS support will be enabled for TensorFlow
      Do you wish to build TensorFlow with OpenCL support? [y/N] N
      No OpenCL support will be enabled for TensorFlow
      Do you wish to build TensorFlow with CUDA support? [y/N] N
      No CUDA support will be enabled for TensorFlow
      
      1. 最终构建将是一个pip包,为了构建它,你必须描述你想要的指令(你知道,那些Tensorflow告诉你缺少)。
      2. 构建pip脚本:bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-mfpmath=both --copt=-msse4.1 --copt=-msse4.2 -k //tensorflow/tools/pip_package:build_pip_package

        构建pip包:bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

        安装刚刚构建的Tensorflow pip包:sudo pip install /tmp/tensorflow_pkg/tensorflow-1.2.1-cp27-cp27mu-linux_x86_64.whl

        现在下次启动Tensorflow时,它不会再抱怨丢失说明了。