簡體   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