最近,項目團隊需要研究並應用AI的技術,在具體的產品實施環節中使用。之前的幾個項目,是委托武漢大學給做的,基於keras框架,實現了一些圖像識別的項目。
這不,上方希望自己能夠掌握一些常用且成熟的AI算法,並能夠運用於項目技術關鍵環節,要我將tensorflow作為入口,手頭的項目,架構已經不存在問題的,可以交出去,讓團隊成員代為管理,關鍵問題,我可以給出指導意見。不多說閑話了,進入正題。
今天,這篇作為tensorflow的處女篇博文,就以環境搭建為主吧。介紹我在部署tensorflow遇到的問題,以及如何處置的。
起初,我是想用源碼安裝的,因為google的技術資源,擔心有依賴找不到,畢竟我大天朝,對google的屏蔽還是比較不錯的嘛。
1. 走起,源碼安裝tensorflow。
因為google的源碼,編譯是基於bazel的,一個類似make的工具,也可以類比ant,maven等等,大家知道這個bazel是用於編譯打包之類的一個工具即可。
1.1 安裝bazel。
在github上下載了一個0.4.5.tar.gz的源碼安裝包,執行.compile.sh的時候,報了錯,什么要指定源碼路徑,必須要指定protoc指令之類,建議用dist的版本,但是我這破網,壓根下不動,算了,本來這個編譯工具就第一次用,諸多不熟悉,轉戰其他方案,選擇bazel-0.4.2-installer-linux-x86_64.sh,這個安裝比較簡單。
[root@bogon tool]# ./bazel-0.4.2-installer-linux-x86_64.sh Bazel installer --------------- Bazel is bundled with software licensed under the GPLv2 with Classpath exception. You can find the sources next to the installer on our release page: https://github.com/bazelbuild/bazel/releases # Release 0.4.2 (2016-12-02) Baseline: 6331a94 Cherry picks: + 7b835d9: Do not patch WORKSPACE in the release process Incompatible changes: - Callback functions in Skylark no longer support the cfg parameter. This is a cleanup and only affects the signatures of callbacks, since the parameter hasn't been set since September 2016. Important changes: - Alias proto_library's produce a descriptor set that contains all srcs of its dependencies. - proto_library supports strict proto deps. - Top level @androidsdk support library targets have been replaced by @androidsdk//<group id>:<artifact id>-<version> for Android SDK Support and Google Play Services libraries. ## Build informations - [Build log](http://ci.bazel.io/job/Bazel/JAVA_VERSION=1.8,PLATFORM_NAME=linux-x86_64/1080/) - [Commit](https://github.com/bazelbuild/bazel/commit/ba94a7b) Uncompressing....... Bazel is now installed! Make sure you have "/usr/local/bin" in your path. You can also activate bash completion by adding the following line to your : source /usr/local/lib/bazel/bin/bazel-complete.bash See http://bazel.build/docs/getting-started.html to start a new project!
看看,安裝的如何,檢查一下bazel的命令。
[root@bogon tool]# bazel --help Warning: ignoring http_proxy in environment. [bazel release 0.4.2] Usage: bazel <command> <options> ... Available commands: analyze-profile Analyzes build profile data. build Builds the specified targets. canonicalize-flags Canonicalizes a list of bazel options. clean Removes output files and optionally stops the server. coverage Generates code coverage report for specified test targets. dump Dumps the internal state of the bazel server process. fetch Fetches external repositories that are prerequisites to the targets. help Prints help for commands, or the index. info Displays runtime info about the bazel server. mobile-install Installs targets to mobile devices. query Executes a dependency graph query. run Runs the specified target. shutdown Stops the bazel server. test Builds and runs the specified test targets. version Prints version information for bazel. Getting more help: bazel help <command> Prints help and options for <command>. bazel help startup_options Options for the JVM hosting bazel. bazel help target-syntax Explains the syntax for specifying targets. bazel help info-keys Displays a list of keys used by the info command.
也不錯,說明安裝一切正常了。
1.2 安裝protobuf
點擊此處即可下載
wget https://pypi.python.org/packages/0f/53/e43b226f83a5a542c16695e9624b7bd2bde4ad016776c7c3233901bcf5b4/protobuf-3.2.0-cp27-cp27mu-manylinux1_x86_64.whl#md5=a1a807fee3a7df784e171837853cc29d #下載指令 pip install protobuf-3.2.0-cp27-cp27mu-manylinux1_x86_64.whl #安裝指令 [root@bogon tool]# pip install protobuf-3.2.0-cp27-cp27mu-manylinux1_x86_64.whl Processing ./protobuf-3.2.0-cp27-cp27mu-manylinux1_x86_64.whl Requirement already satisfied: setuptools in /usr/lib/python2.7/site-packages (from protobuf==3.2.0) Requirement already satisfied: six>=1.9 in /usr/lib/python2.7/site-packages (from protobuf==3.2.0) Requirement already satisfied: appdirs>=1.4.0 in /usr/lib/python2.7/site-packages (from setuptools->protobuf==3.2.0) Requirement already satisfied: packaging>=16.8 in /usr/lib/python2.7/site-packages (from setuptools->protobuf==3.2.0) Requirement already satisfied: pyparsing in /usr/lib/python2.7/site-packages (from packaging>=16.8->setuptools->protobuf==3.2.0) Installing collected packages: protobuf Successfully installed protobuf-3.2.0
本出安裝的版本是最新的版本,3.2.0,本地的python是2.7的,所以,選擇的是cp27。
1.3 安裝setuptools
這個安裝包,是python的一套便於下載,安裝,更新和卸載軟件包的套件。本地的安裝版本是34.3.2,可以在此處下載
wget https://pypi.python.org/packages/de/b2/b63accae9aa1a4cf02e03c7522102f686a1bd9b8b1b847716198152d2c63/setuptools-34.3.2-py2.py3-none-any.whl#md5=0d9c6a1da32797da04bde303e4d623d9 #下載指令 pip install setuptools-34.3.2-py2.py3-none-any.whl #安裝指令
[root@bogon tool]# pip install setuptools-34.3.2-py2.py3-none-any.whl Processing ./setuptools-34.3.2-py2.py3-none-any.whl Requirement already satisfied: six>=1.6.0 in /usr/lib/python2.7/site-packages (from setuptools==34.3.2) Collecting appdirs>=1.4.0 (from setuptools==34.3.2) Downloading appdirs-1.4.3-py2.py3-none-any.whl Collecting packaging>=16.8 (from setuptools==34.3.2) Downloading packaging-16.8-py2.py3-none-any.whl Requirement already satisfied: pyparsing in /usr/lib/python2.7/site-packages (from packaging>=16.8->setuptools==34.3.2) Installing collected packages: appdirs, packaging, setuptools Found existing installation: setuptools 0.9.8 Uninstalling setuptools-0.9.8: Successfully uninstalled setuptools-0.9.8 Successfully installed appdirs-1.4.3 packaging-16.8 setuptools-34.3.2
1.4 安裝six
six套件,是用於python2和python3的兼容性服務的軟件包。本處使用的版本是1.10,點擊此處下載。
wget https://pypi.python.org/packages/c8/0a/b6723e1bc4c516cb687841499455a8505b44607ab535be01091c0f24f079/six-1.10.0-py2.py3-none-any.whl#md5=3ab558cf5d4f7a72611d59a81a315dc8 #下載指令 pip install six-1.10.0-py2.py3-none-any.whl #安裝指令
除了six套件之外,比如python-devel,swig等都可以參照上述類似方法進行安裝,就不再重述。
1.5 tensorflow源碼安裝
[root@bogon source_code]# git clone https://github.com/tensorflow/tensorflow.git
在Github上clonetensorflow的源碼,然后切換到指定分支r1.0上。
[root@bogon tensorflow]# git branch r1.0
接下來,就進行對tensorflow的配置工作。當然了,我的機器上是有GPU支持的,所以要安裝cuda以及cudnn來進行運算速度提速。
[root@bogon source_code]# nvidia-smi Tue Mar 21 09:26:38 2017 +-----------------------------------------------------------------------------+ | NVIDIA-SMI 367.57 Driver Version: 367.57 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 1080 Off | 0000:82:00.0 Off | N/A | | 0% 35C P0 39W / 180W | 0MiB / 8113MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | No running processes found | +-----------------------------------------------------------------------------+
安裝cuda,其實很簡單,去nvidia的官網,下載所需的版本,我這里,下載安裝的是8.0的cuda,5.1的cudnn。
安裝完cuda后,cudnn的安裝,其實比較簡單,將下載的壓縮包解壓,並將include下面的文件copy到cuda安裝路徑下的include下,將lib64下面的so文件copy到cuda安裝路徑下的lib64下面,另外,so文件要建軟連接,因為版本號可能是3位數字,但是后面tensorflow需要用到的地方可能是兩位數字,比如這里,真是版本號是5.1.10,就要建立軟連接,將5.1指向5.1.10.
最后,需要配置機器的環境變量。
#下面三行指定了cuda以及cudnn的環境
export PATH=/usr/local/cuda-8.0/bin:/usr/local/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH export CUDA_ROOT=/usr/local/cuda-8.0
#下面的三行指定環境變量是JAVA8 export JAVA_HOME=/usr/java/jdk1.8.0_121 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
切記一點,tensorflow源碼安裝,有一點,官方要求的是JDK必須是java8.
下面,進入真正源碼配置准備安裝。
[root@bogon tensorflow]# ./configure /usr/bin/python Please specify the location of python. [Default is /usr/bin/python]: 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] y jemalloc enabled 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 Found possible Python library paths: /usr/lib/python2.7/site-packages /usr/lib64/python2.7/site-packages Please input the desired Python library path to use. Default is [/usr/lib/python2.7/site-packages] Using python library path: /usr/lib/python2.7/site-packages 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] y CUDA support will be enabled for TensorFlow Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]: Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to use system default]: 8.0 Please specify the location where CUDA 8.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda-8.0 Please specify the Cudnn version you want to use. [Leave empty to use system default]: 5.1 Please specify the location where cuDNN 5.1 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda-8.0]: /usr/local/cudnn/lib64 Invalid path to cuDNN toolkit. Neither of the following two files can be found: /usr/local/cudnn/lib64/lib64/libcudnn.so.5.1 /usr/local/cudnn/lib64/libcudnn.so.5.1 .5.1 Please specify the Cudnn version you want to use. [Leave empty to use system default]: 5.1.5 Please specify the location where cuDNN 5.1.5 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda-8.0]: /usr/local/cudnn/lib64 Please specify a list of comma-separated Cuda compute capabilities you want to build with. You can find the compute capability of your device at: https://developer.nvidia.com/cuda-gpus. Please note that each additional compute capability significantly increases your build time and binary size. [Default is: "3.5,5.2"]: Warning: ignoring http_proxy in environment. ........ INFO: Starting clean (this may take a while). Consider using --expunge_async if the clean takes more than several minutes. Warning: ignoring http_proxy in environment. ........ ERROR: com.google.devtools.build.lib.packages.BuildFileContainsErrorsException: error loading package '': Encountered error while reading extension file 'closure/defs.bzl': no such package '@io_bazel_rules_closure//closure': Error downloading [http://bazel-mirror.storage.googleapis.com/github.com/bazelbuild/rules_closure/archive/5ca1dab6df9ad02050f7ba4e816407f88690cf7d.tar.gz, https://github.com/bazelbuild/rules_closure/archive/5ca1dab6df9ad02050f7ba4e816407f88690cf7d.tar.gz] to /root/.cache/bazel/_bazel_root/3a66f6079c893d4123754fa0783e0a83/external/io_bazel_rules_closure/5ca1dab6df9ad02050f7ba4e816407f88690cf7d.tar.gz: All mirrors are down: [Proxy address 10.90.1.101:8080 is not a valid URL].
上面的configure過程中,提示用戶,需要指定相關的配置參數信息,需要哪些信息,上面可以看得到,有很詳細的描述信息。
只是,源碼安裝,我折騰了很久,大半天過去了,都提示各種錯誤,主要原因是我們單位的網絡原因,很多資源都無法下載,就好比上述錯誤日志信息中最后面一行提到的各種軟件包下載不了。
到此,我決定放棄源碼安裝,走另外一條路線,套件安裝。 雖然源碼安裝沒有成功,但是,到這一步,基本的流程算是清楚了。基於源碼安裝邏輯,需要補充一點知識,就是去學習下bazel的使用。
2. tensorflow的套件安裝。
2.1 下載tensorflow套件。
當然,還是基於上述各種准備工作之后,進行的tensorflow的whl套件安裝。下載地址,這個是比較重要的信息。
上面的地址,不是一個HTML的頁面,而是一個XML文件,從中找到自己需要的版本。我下載的就是0.11的cp27版本,如下圖:
在瀏覽器地址欄中輸入: https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow-0.11.0rc1-cp27-none-linux_x86_64.whl 即可下載。
2.2 安裝套件
[root@bogon tensorflow]# pip install tensorflow-0.11.0rc1-cp27-none-linux_x86_64.whl Processing ./tensorflow-0.11.0rc1-cp27-none-linux_x86_64.whl Requirement already satisfied: six>=1.10.0 in /usr/lib/python2.7/site-packages (from tensorflow==0.11.0rc1) Requirement already satisfied: wheel in /usr/lib/python2.7/site-packages (from tensorflow==0.11.0rc1) Collecting mock>=2.0.0 (from tensorflow==0.11.0rc1) Downloading mock-2.0.0-py2.py3-none-any.whl (56kB) 100% |████████████████████████████████| 61kB 17kB/s Requirement already satisfied: numpy>=1.11.0 in /usr/lib64/python2.7/site-packages (from tensorflow==0.11.0rc1) Collecting protobuf==3.0.0 (from tensorflow==0.11.0rc1) Downloading protobuf-3.0.0-cp27-cp27mu-manylinux1_x86_64.whl (5.2MB) 19% |██████▎ | 1.0MB 594bytes/s eta 1:57:17^C Operation cancelled by user [root@bogon tensorflow]#
由於之前,我按照的protobuf版本是3.2.0的,而這里需要的是3.0.0的,所以就進行了再次下載,這個源速度太慢。 去python的資源庫進行下載吧,這個python的資源庫,有點類似maven的倉庫,基本所有的資源都有。點擊地址,進入選擇所需版本。
安裝所需的3.0.0的protobuf后,再次進行tensorflow的安裝:
[root@bogon tensorflow]# pip install tensorflow-0.11.0rc1-cp27-none-linux_x86_64.whl Processing ./tensorflow-0.11.0rc1-cp27-none-linux_x86_64.whl Requirement already satisfied: six>=1.10.0 in /usr/lib/python2.7/site-packages (from tensorflow==0.11.0rc1) Requirement already satisfied: wheel in /usr/lib/python2.7/site-packages (from tensorflow==0.11.0rc1) Collecting mock>=2.0.0 (from tensorflow==0.11.0rc1) Using cached mock-2.0.0-py2.py3-none-any.whl Requirement already satisfied: numpy>=1.11.0 in /usr/lib64/python2.7/site-packages (from tensorflow==0.11.0rc1) Requirement already satisfied: protobuf==3.0.0 in /usr/lib64/python2.7/site-packages (from tensorflow==0.11.0rc1) Collecting funcsigs>=1; python_version < "3.3" (from mock>=2.0.0->tensorflow==0.11.0rc1) Downloading funcsigs-1.0.2-py2.py3-none-any.whl Collecting pbr>=0.11 (from mock>=2.0.0->tensorflow==0.11.0rc1) Downloading pbr-2.0.0-py2.py3-none-any.whl (98kB) 100% |████████████████████████████████| 102kB 36kB/s Requirement already satisfied: setuptools in /usr/lib/python2.7/site-packages (from protobuf==3.0.0->tensorflow==0.11.0rc1) Requirement already satisfied: appdirs>=1.4.0 in /usr/lib/python2.7/site-packages (from setuptools->protobuf==3.0.0->tensorflow==0.11.0rc1) Requirement already satisfied: packaging>=16.8 in /usr/lib/python2.7/site-packages (from setuptools->protobuf==3.0.0->tensorflow==0.11.0rc1) Requirement already satisfied: pyparsing in /usr/lib/python2.7/site-packages (from packaging>=16.8->setuptools->protobuf==3.0.0->tensorflow==0.11.0rc1) Installing collected packages: funcsigs, pbr, mock, tensorflow Successfully installed funcsigs-1.0.2 mock-2.0.0 pbr-2.0.0 tensorflow-0.11.0rc1
哈哈,這次是不是安裝成功了,的確,這次安裝成功,顯示了需要的插件的版本等信息。
2.3 測試是否安裝成功
下面,測試下吧,看看tensorflow是否安裝好了呢,起碼tensorflow的資源,在python編程中可以使用吧。
[root@bogon tensorflow]# python Python 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcublas.so locally I tensorflow/stream_executor/dso_loader.cc:105] Couldn't open CUDA library libcudnn.so. LD_LIBRARY_PATH: /usr/local/cuda-8.0/lib64:/usr/local/cuda-8.0/lib64: I tensorflow/stream_executor/cuda/cuda_dnn.cc:3448] Unable to load cuDNN DSO I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcufft.so locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader.cc:111] successfully opened CUDA library libcurand.so locally Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module> from tensorflow.python import * File "/usr/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 53, in <module> from tensorflow.core.framework.graph_pb2 import * File "/usr/lib/python2.7/site-packages/tensorflow/core/framework/graph_pb2.py", line 6, in <module> from google.protobuf import descriptor as _descriptor File "/usr/lib64/python2.7/site-packages/google/protobuf/__init__.py", line 37, in <module> __import__('pkg_resources').declare_namespace(__name__) File "/usr/lib/python2.7/site-packages/pkg_resources/__init__.py", line 72, in <module> import packaging.requirements File "/usr/lib/python2.7/site-packages/packaging/requirements.py", line 59, in <module> MARKER_EXPR = originalTextFor(MARKER_EXPR())("marker") TypeError: __call__() takes exactly 2 arguments (1 given)
上面的錯誤,顯示的是兩個方面的信息,一個是CUDA中libcudnn.so文件找不到,查找了一下,是因為cudnn的lib64中的so文件復制到cuda/lib64的時候,發生了typo,修改后,就可以了。 但是后面這個錯誤,貌似就不是那么好處理,感覺是版本沖突的問題,因為最后提示參數的個數不對,這種問題,通常是程序的API變了,往往就是發生在版本兼容的問題上。
處於這個分析,我通過pip指令,將tensorflow進行了upgrade的操作,如下:
[root@bogon tool]# pip install --upgrade tensorflow Collecting tensorflow Downloading tensorflow-1.0.1-cp27-cp27mu-manylinux1_x86_64.whl (44.1MB) 100% |████████████████████████████████| 44.1MB 20kB/s Collecting protobuf>=3.1.0 (from tensorflow) Downloading protobuf-3.2.0-cp27-cp27mu-manylinux1_x86_64.whl (5.6MB) 100% |████████████████████████████████| 5.6MB 53kB/s Collecting wheel (from tensorflow) Downloading wheel-0.29.0-py2.py3-none-any.whl (66kB) 100% |████████████████████████████████| 71kB 75kB/s Requirement already up-to-date: mock>=2.0.0 in /usr/lib/python2.7/site-packages (from tensorflow) Collecting numpy>=1.11.0 (from tensorflow) Downloading numpy-1.12.1-cp27-cp27mu-manylinux1_x86_64.whl (16.5MB) 100% |████████████████████████████████| 16.5MB 32kB/s Requirement already up-to-date: six>=1.10.0 in /usr/lib/python2.7/site-packages (from tensorflow) Requirement already up-to-date: setuptools in /usr/lib/python2.7/site-packages (from protobuf>=3.1.0->tensorflow) Requirement already up-to-date: funcsigs>=1; python_version < "3.3" in /usr/lib/python2.7/site-packages (from mock>=2.0.0->tensorflow) Requirement already up-to-date: pbr>=0.11 in /usr/lib/python2.7/site-packages (from mock>=2.0.0->tensorflow) Requirement already up-to-date: appdirs>=1.4.0 in /usr/lib/python2.7/site-packages (from setuptools->protobuf>=3.1.0->tensorflow) Requirement already up-to-date: packaging>=16.8 in /usr/lib/python2.7/site-packages (from setuptools->protobuf>=3.1.0->tensorflow) Collecting pyparsing (from packaging>=16.8->setuptools->protobuf>=3.1.0->tensorflow) Downloading pyparsing-2.2.0-py2.py3-none-any.whl (56kB) 100% |████████████████████████████████| 61kB 77kB/s Installing collected packages: protobuf, wheel, numpy, tensorflow, pyparsing Found existing installation: protobuf 3.0.0 Uninstalling protobuf-3.0.0: Successfully uninstalled protobuf-3.0.0 Found existing installation: wheel 0.24.0 Uninstalling wheel-0.24.0: Successfully uninstalled wheel-0.24.0 Found existing installation: numpy 1.11.2 Uninstalling numpy-1.11.2: Successfully uninstalled numpy-1.11.2 Found existing installation: tensorflow 0.11.0rc1 Uninstalling tensorflow-0.11.0rc1: Successfully uninstalled tensorflow-0.11.0rc1 Found existing installation: pyparsing 1.5.6 DEPRECATION: Uninstalling a distutils installed project (pyparsing) has been deprecated and will be removed in a future version. This is due to the fact that uninstalling a distutils project will only partially uninstall the project. Uninstalling pyparsing-1.5.6: Successfully uninstalled pyparsing-1.5.6 Successfully installed numpy-1.12.1 protobuf-3.2.0 pyparsing-2.2.0 tensorflow-1.0.1 wheel-0.29.0 [root@bogon tool]#
喲呵,看來分析是對的,沒錯,這么升級之后,tensorflow現在是最新版本1.0.1的版本了。其他相關的依賴包也被更新到了所需版本。
再來測試下,看看tensorflow是否能運行hello world吧。
[root@bogon tool]# python Python 2.7.5 (default, Nov 6 2016, 00:28:07) [GCC 4.8.5 20150623 (Red Hat 4.8.5-11)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> >>> hello = tf.constant('Hello, tensorflow!') >>> sess = tf.Session() W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations. 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. 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. 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. 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. 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, tensorflow! >>> a = tf.constant(10) >>> b = tf.constant(32) >>> print sess.run(a+b) 42 >>>
從上面的輸出信息看,tensorflow在被import的過程中,沒有報錯了,說明tensorflow的資源安裝已經沒有問題了。后續的操作,輸出都是對的,也沒有問題了,到此,說明,tensorflow安裝成功。
總結,tensorflow的安裝:
1. 源碼安裝,需要面對的問題比較多,但是可以接觸到更多的實現上的技術細節,掌握的技術也會多很多。但是,條件不允許的情況下,要學會平衡選擇。
2. python的資源,通過yum或pip,非常容易獲取,基於套件的安裝,要善於分析日志輸出信息,善於利用python的資源。
上述兩個方面,其實,對其他任何技術問題,都可以觸類旁通的。