繁体   English   中英

Ubuntu14.04中的Tensorflow安装

[英]Tensorflow Installation in Ubuntu14.04

我在Ubuntu14.04上安装了tensorflow,并与Anaconda一起安装了它。我遵循官方的安装指南。安装后,逐步执行此代码时出错。

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

当我跑步

sess = tf.Session()

它说:

2017-09-03 17:04:11.220320: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-09-03 17:04:11.220355: 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-09-03 17:04:11.220363: 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-09-03 17:04:11.220369: 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-09-03 17:04:11.220374: 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.

这不是实际的“错误”。 通知您 ,如果从源安装并支持上述说明,例如SSE4.1,SSE4.2等,则计算可能会更快。

您可以继续使用Tensorflow,尽管它的速度不如从源代码编译的速度快。

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

  1. 安装挡板

从其可用版本之一下载它,例如0.5.2 解压缩它,进入目录并配置它: bash ./compile.sh 将可执行文件复制到/usr/local/binsudo cp ./output/bazel /usr/local/bin

  1. 安装Tensorflow

克隆tensorflow: 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通知您丢失了)。

构建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时,它将不再抱怨缺少指令。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM