Installing CUDA 8.0 + cuDNN 5.1 + TensorFlow with Ubuntu 14.04 (下)
2017-03-19 10:20
387 查看
这篇文章因为篇幅原因分为上下两篇,此为下篇,上篇链接为:
Installing CUDA 8.0 + cuDNN 5.1 + TensorFlow with Ubuntu 14.04 (上)
Step 2. Install NVIDIA cuDNN
Once the CUDA Toolkit is installed, download cuDNN v5.1 Library(或者从百度云下载) for Linux (note that you will need to register
for the Accelerated Computing Developer Program).
Once downloaded, uncompress the files and copy them into the CUDA Toolkit directory (assumed here to be in /usr/local/cuda/)
Configure the Environment
Finally we need to configure the environment to work with CUDA and cuDNN. Add to the following lines to your ~/.profile file.
TensorFlow itself can be installed using the pip package manager. First, make sure that your system has pip installed and updated: - See more at: http://www.nvidia.com/object/gpu-accelerated-applications-tensorflow-installation.html#sthash.5lFpw96U.dpuf TensorFlow itself can be installed using the pip package manager. First, make sure that your system has pip installed and updated: - See more at: http://www.nvidia.com/object/gpu-accelerated-applications-tensorflow-installation.html#sthash.5lFpw96U.dpuf TensorFlow itself can be installed using the pip package manager. First, make sure that your system has pip installed and updated
Step 4. Install Bazel
To build TensorFlow from source, the Bazel build system must first be installed as follows. Full details are available here.
Installing CUDA 8.0 + cuDNN 5.1 + TensorFlow with Ubuntu 14.04 (上)
Step 2. Install NVIDIA cuDNN
Once the CUDA Toolkit is installed, download cuDNN v5.1 Library(或者从百度云下载) for Linux (note that you will need to register
for the Accelerated Computing Developer Program).
Once downloaded, uncompress the files and copy them into the CUDA Toolkit directory (assumed here to be in /usr/local/cuda/)
sudo tar -xvf cudnn-8.0-linux-x64-v5.1.tgz -C /usr/local
Configure the Environment
Finally we need to configure the environment to work with CUDA and cuDNN. Add to the following lines to your ~/.profile file.
export CUDA_HOME=/usr/local/cuda export CUDA_ROOT=/usr/local/cuda export PATH=$PATH:$CUDA_ROOT/bin export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_ROOT/lib64Step 3. Install and upgrade PIP
TensorFlow itself can be installed using the pip package manager. First, make sure that your system has pip installed and updated: - See more at: http://www.nvidia.com/object/gpu-accelerated-applications-tensorflow-installation.html#sthash.5lFpw96U.dpuf TensorFlow itself can be installed using the pip package manager. First, make sure that your system has pip installed and updated: - See more at: http://www.nvidia.com/object/gpu-accelerated-applications-tensorflow-installation.html#sthash.5lFpw96U.dpuf TensorFlow itself can be installed using the pip package manager. First, make sure that your system has pip installed and updated
sudo apt-get install python-pip python-dev sudo pip install --upgrade pip
Step 4. Install Bazel
To build TensorFlow from source, the Bazel build system must first be installed as follows. Full details are available here.
sudo apt-get install software-properties-common swig sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java8-installer echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list curl https://storage.googleapis.com/bazel-apt/doc/apt-key.pub.gpg | sudo apt-key add - sudo apt-get update sudo apt-get install bazel - See more at: http://www.nvidia.com/object/gpu-accelerated-applications-tensorflow-installation.html#sthash.5lFpw96U.dpuf[/code]
Step 5. Install TensorFlow
Start the process of building TensorFlow by cloning a TensorFlow repository.
To clone the latest TensorFlow repository, issue the following command:git clone https://github.com/tensorflow/tensorflowThe preceding git clone command creates a subdirectory named tensorflow. After cloning, you may optionally build a specific branch (such as a release branch) by invoking the following commands:cd tensorflow git checkout Branch # where Branch is the desired branchFor example, to work with the r1.0 release instead of the master release, issue the following command:git checkout r1.0Next, you must prepare your environment for Linux or Mac OS
Install TensorFlow Python dependencies
To install TensorFlow, you must install the following packages:
* numpy, which is a numerical processing package that TensorFlow requires.
* dev, which enables adding extensions to Python.
* pip, which enables you to install and manage certain Python packages.
* wheel, which enables you to manage Python compressed packages in the wheel (.whl) format.
To install these packages for Python 2.7, issue the following command:sudo apt-get install python-numpy python-dev python-pip python-wheelTo install these packages for Python 3.n, issue the following command:sudo apt-get install python3-numpy python3-dev python3-pip python3-wheelFinally, you must also install libcupti-dev by invoking the following command:sudo apt-get install libcupti-devAfter preparing the environment, you must now configure the installation.
Configure the installation
The root of the source tree contains a bash script named configure. This script asks you to identify the pathname of all relevant TensorFlow dependencies and specify other build configuration options such as compiler flags. You
must run this script prior to creating the pip package and installing TensorFlow.
If you wish to build TensorFlow with GPU, configure will ask you to specify the version numbers of Cuda and cuDNN. If several versions of Cuda or cuDNN are installed on your system, explicitly select the desired version instead of relying on the system default.
Here is an example execution of the configure script. Note that your own input will likely differ from our sample input:$ cd tensorflow # cd to the top-level directory created $ ./configure Please specify the location of python. [Default is /usr/bin/python]: /usr/bin/python2.7 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] jemalloc enabled Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] No Google Cloud Platform support will be enabled for TensorFlow Do you wish to build TensorFlow with Hadoop File System support? [y/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] No XLA JIT support will be enabled for TensorFlow Found possible Python library paths: /usr/local/lib/python2.7/dist-packages /usr/lib/python2.7/dist-packages Please input the desired Python library path to use. Default is [/usr/local/lib/python2.7/dist-packages] Using python library path: /usr/local/lib/python2.7/dist-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]: Please specify the cuDNN version you want to use. [Leave empty to use system default]: 5 Please specify the location where cuDNN 5 library is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: 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"]: 3.0 Setting up Cuda include Setting up Cuda lib Setting up Cuda bin Setting up Cuda nvvm Setting up CUPTI include Setting up CUPTI lib64 Configuration finished
Build the pip package
To build a pip package for TensorFlow with CPU-only support, invoke the following command:bazel build --config=opt //tensorflow/tools/pip_package:build_pip_packageTo build a pip package for TensorFlow with GPU support, invoke the following command:bazel build --config=opt --config=cuda //tensorflow/tools/pip_package:build_pip_packageTip: By default, building TensorFlow from sources consumes a lot of RAM. If RAM is an issue on your system, you may limit RAM usage by specifying --local_resources 2048,.5,1.0 while invoking bazel.
The bazel build command builds a script named build_pip_package. Running this script as follows will build a .whl file within the /tmp/tensorflow_pkg directory:bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkgInstall the pip package
Invoke pip install to install that pip package. The filename of the .whlfile depends on your platform. For example, the following command will install the pip package for TensorFlow 1.0.1 on Linux:(这一步需要到/tmp/tensorflow_pkg/文件夹下看你的whl文件名)sudo pip install /tmp/tensorflow_pkg/(your file name).whlNOTE on gcc version 5: the binary pip packages available on the TensorFlow website are built with gcc4 that uses the older ABI. To make the library compatible with the older abi you have to add -cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"
[b]Step 6. Validate your installation[/b]
Validate your TensorFlow installation by doing the following:
1. Start a terminal.
2. Change directory (cd) to any directory on your system other than the tensorflow subdirectory from which you invoked the configure command.
3. Invoke python:python4. Enter the following short program inside the python interactive shell:>>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> print(sess.run(hello))If the Python program outputs the following, then the installation is successful and you can begin writing TensorFlow programs. (If you are new to TensorFlow, see Getting Started with TensorFlow):Hello, TensorFlow!
Congratulations! All works are done, Enjoy it!
相关文章推荐
- Installing CUDA 8.0 + cuDNN 5.1 + TensorFlow with Ubuntu 14.04 (上)
- (亲测)服务器 Ubuntu 14.04 安装 CUDA 8.0 + cuDNN 5.1 + tensorflow
- ubuntu14.04下CUDA8.0+cuDNN+tensorflow(with gpu support)安装教程
- Ubuntu 16.04 + GTX1080ti + CUDA8.0 + cudnn5.1 + tensorflow
- Ubuntu16.04 + gtx1060 + cuda8.0 + cudnn5.1 + caffe + Theano + Tensorflow
- ubuntu 14.04+ GTX 1070+cuda 8.0 + cudnn 5.1+opencv3.0+caffe-SSD配置一步到位
- 深度学习主机环境配置: Ubuntu16.04 + GeForce GTX 1070 + CUDA8.0 + cuDNN5.1 + TensorFlow
- Ubuntu14.04 & CUDA8.0 & Theano & Tensorflow & TensorLayer & Cudnn安装血泪史
- ubuntu 14.04+ gtx 1070+cuda 8.0 + cudnn 5.1+ tensorflow GPU 踩坑实录
- ubuntu14.04 cuda8.0 cudnn caffe tensorflow opencv
- ubuntu 14.04+ GTX 1070+cuda 8.0 + cudnn 5.1配置一步到位
- ubuntu 14.04+ GTX 1070+cuda 8.0 + cudnn 5.1+opencv3.0+caffe配置一步到位
- Ubuntu16.04+CUDA8.0+CUNN5.1+caffe+tensorflow+Theano
- 最新的Tensorflow + CUDA 8.0 +Cudnn 5.1
- Ubuntu16.04 +cuda8.0+cudnn+opencv+caffe+theano+tensorflow配置明细
- 深度学习环境搭建:linux下 Ubuntu16.04+cuda8.0+cudnn+anaconda+tensorflow并配置远程访问jupyter notebook
- ubuntu14.04+anaconda+tensorflow+cuda8.0
- ubuntu16.04 +NVIDIA驱动+cuda8.0+cudnn+andaconda+tensorflow(GPU版)+Spyder+pycharm全套配置
- Ubuntu16.04+CUDA8.0+CUNN5.1+caffe+tensorflow+Theano
- ubuntu14.04+GTX1080 部署tensorflow+cuda8.0