(Tensorflow学习)- 安装

Linux 平台下的安装:

如果是在Fedora下安装,又想使用Python3.5,建议使用pip安装。

1.CUDA和CUDNN安装(如果想用NVIDIA显卡加速的话):

运行这个脚本,然后更觉提示来就可以了。默认安装目录在/usr/local/cuda-8.0。Fedora自带了NVIDIA的驱动,所以也可以不用安装脚本中推荐的驱动

下载的tgz用tar zxvf cudnn-8.0-linux-x64-v5.1.tgz解压缩,把其中的文件按照目录复制到cuda安装目录的lib64或include文件夹下。

  • 把以下的文件保存在.bashrc这样每次充气就可以自动添加CUDA需要的变量。source更新一下。
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

2.TF1.0的安装:

  • PIP(Python3.5)安装(推荐哦):如果嫌pip下载速度慢的话,可以打开https://storage.googleapis.com/tensorflow/名为linux/gputensorflow-0.11.0rc0-cp35-cp35m-linux_x86_64的key,把key加到url的后面就是下载链接了。下在之后用pip3安装就可以了,他会自动下载对应版本的setuptools、protobuf、python3-devel、python3-wheel等等。如果出了问题,可以用dnf install安装。注意安装之后还是不能用的,要安装更新。使用pip install tensorflow --upgrade。或者可以下载适用于Python3.5的TF1.1更新
  • Bazel(0.4.5)编译安装。我试过一次,但是用Python3.5就无法编译TF1.0的代码。使用Python2.7是可以编译。具体的方法可以google以下。注意要安装python-devel 、numpy,不然会出错。

当TF1.0的配置如下:

[root@shulinux tensorflow-master]# ./configure
Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python3  
Found possible Python library paths:
  /usr/lib64/python3.5/site-packages
  /usr/lib/python3.5/site-packages
Please input the desired Python library path to use.  Default is [/usr/lib64/python3.5/site-packages]

Using python library path: /usr/lib64/python3.5/site-packages
Do you wish to build TensorFlow with MKL support? [y/N] N
No MKL support will be enabled for TensorFlow
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] y
CUDA support will be enabled for TensorFlow
Do you want to use clang as CUDA compiler? [y/N] N
nvcc will be used as CUDA compiler
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 which gcc should be used by nvcc as the host compiler. [Default is /opt/rh/devtoolset-3/root/usr/bin/gcc]: 
Please specify the cuDNN version you want to use. [Leave empty to use system default]: 6
Please specify the location where cuDNN 6 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda-8.0]: 
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"]:
INFO: Starting clean (this may take a while). Consider using --async if the clean takes more than several minutes.
Configuration finished

Bazel的编译出现的问题:

ERROR: /root/.cache/bazel/_bazel_root/3f98b28eee39625b9d1679c2d401a4cb/external/local_config_python/BUILD:51:1: Executing genrule @local_config_python//:python_include failed: bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
ln: failed to create symbolic link 'bazel-out/local_linux-py3-opt/genfiles/external/local_config_python/python_include/python_include/pyconfig-64.h': No such file or directory
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 116.095s, Critical Path: 115.34s
[root@shulinux tensorflow-master]# bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
WARNING: /root/下载/tensorflow-master/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': Use SavedModel Builder instead.
WARNING: /root/下载/tensorflow-master/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': Use SavedModel instead.
INFO: Found 1 target...
ERROR: /root/.cache/bazel/_bazel_root/3f98b28eee39625b9d1679c2d401a4cb/external/local_config_python/BUILD:51:1: Executing genrule @local_config_python//:python_include failed: bash failed: error executing command /bin/bash -c ... (remaining 1 argument(s) skipped): com.google.devtools.build.lib.shell.BadExitStatusException: Process exited with status 1.
ln: failed to create symbolic link 'bazel-out/local_linux-py3-opt/genfiles/external/local_config_python/python_include/python_include/pyconfig-64.h': No such file or directory
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 18.948s, Critical Path: 18.46s

希望知道的dalao能够提醒我一下,谢谢。:)

提交了一份issue,希望能有帮助:Github issue

 

参考:http://www.cnblogs.com/shihuc/p/6593041.html