ubuntu16.4 Build TensorFlow Environment

Source: Internet
Author: User

1 Description:

Native configuration: Graphics Gtx970,ubuntu16.4.1+cuda8.0+cudnn v5+tensorflow0.11

1. Download 1.1 System Image

Since I tried the ubuntu14.04, after installing the Nvidia driver, there will be a circular login problem, and always can not find a valid solution, so can only choose ubuntu16.04.

Mirror Address Https://www.ubuntu.com/download/alternative-downloads

1.2 CUDA 8.0

Https://developer.nvidia.com/cuda-downloads ()
Description
(1) Under Nvidia's Cuda download page, select the Cuda version you want to use to download.
(2) We use CUDA8.0 here (page with prompt GTX1070, GTX1080 support 8.0 version), students can download CUDA7.5 if they do not use the above two versions of the GPU. DOWNLOAD (download).
(3) Download requires registration.
(4) Schematic selection

Note: Use the Deb (local) version.

1.3 CuDNN V5

: HTTPS://DEVELOPER.NVIDIA.COM/CUDNN (login required)
Description
(1) Download needs to fill out a questionnaire, on three options, it is recommended to carefully fill out, after all, people free to use.
(2) Complete Click on the small box in front of I Agree to

Select Cudnn v5.1 for Linux

1.4 TensorFlow 0.11

TensorFlow GitHub above mentioned 4 kinds of installation methods, this tutorial using the four source code installation
VIRTUALENV Installation
Anaconda Installation
Docker Installation
Installing from sources
Https://github.com/tensorflow/tensorflow ()
Description: I chose the Linux GPU Python2

(2) Click Python 2 to start the download.

2. Installing the ubuntu16.04 LTS system

For details, please see the previous Notes Windows System installation Ubuntu dual system

3. Installing the NVIDIA Driver

Open terminal to enter the following command:

sudo apt-get update

然后在系统设置->软件更新->附加驱动->选择nvidia最新驱动(361)->应用更改

4. Installing cuda8.0

4.1 GCC Reduced version

The GCC compiler for Ubuntu is 5.4.0, however cuda8.0 does not support more than 5.0 compilers and therefore needs to be degraded to reduce the compiler version to 4.9:
Execute in Terminal:

sudo apt-GetInstall g++-4.9sudo update-alternatives--INSTALL/USR/BIN/GCC gcc/usr/bin/gcc-4.9  -sudo update-alternatives--INSTALL/USR/BIN/GCC gcc/usr/bin/gcc-5 Tensudo update-alternatives--install/usr/bin/g++ g++/usr/bin/g++-4.9  -sudo update-alternatives--install/usr/bin/g++ g++/usr/bin/g++-5 Tensudo update-alternatives--install/usr/bin/cc CC/USR/BIN/GCC -sudo update-alternatives--Setcc/usr/bin/Gccsudo Update-alternatives--install/usr/bin/c++ C + +/usr/bin/g++ -sudo update-alternatives--SetC + +/usr/bin/g++
4.2 Installing Cuda

In the directory where Cuda is open terminal enter the following command in turn:

CD//*  * * (own user name)/desktop/### (This command means to find the file that we have just sent over with a USB stick) sudo dpkg-i cuda-repo-ubuntu1604-8-0-rc _8.0.27-1_amd64?. Debsudo apt-get updatesudo apt-get install Cuda?
4.3 Installing CUDNN

Open terminal and enter the following command in turn:

CD//*  * * (own user name)/desktop/                     # (This command means to find the file that we have just sent over with a USB stick) tar Xvzf Cudnn-8.0-linux-x64-v5.1-ga.tgz               # (unzip this file) sudo cp cuda/include/cudnn.h/usr/local/cuda/include   # (copy) sudo cp cuda/lib64/libcudnn*/usr/local/cuda/lib64     # (copy) sudo chmoda+r/usr/local/cuda/include/cudnn.h/usr/local/cuda/ lib64/libcudnn*

4.4 Installing additional dependent 4.4.1 Configuration environment variables

按照的教程,在terminal中输入以下命令:
sudo gedit ~/.bash_profile #打开. bash_profile

Then, at the end of the open text, add:

Export ld_library_path="$LD _library_path:/usr/local/cuda/lib64:/usr/local/cuda/extras/cupti/lib64  "export cuda_home=/usr/local/cuda

Continue to enter in terminal:

SOURCE ~/.bash_profile #使更改的环境变量生效

Of course, there are other tutorials written in the file ~/.BASHRC file, similar to the one above. This method can be implemented if there is a problem configuring the./config file later.

4.4.2 Configuring environment variables

Enter the following command in Terminal:

sudo apt-get
5. Install Bazel5.1 installation Bazel dependent

Because this tutorial compiles/installs using TensorFlow source code, you need to use Bazel build.

链接:https://www.bazel.io/versions/master/docs/install.html 

In terminal, enter the following 1-7 commands in turn

sudo add-apt-repository ppa:webupd8team/javasudo apt-get  updatesudo apt-get Install Oracle-java8-installer
" Deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8 " | sudo tee/etc/apt/sources.list.d/bazel.listcurl https:///bazel.io/bazel-release.pub.gpg | sudo Apt-key Add-
5.2 Installing Bazel

Then go back to the previous TensorFlow Installation Tutorial page: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md

Click on the link: Installer for your system, jump to Bazel's download page:

Download bazel-0.3.2-installer-linux-x86_64.sh to the desktop, and then enter the following command in terminal

CD//*  * * (own username)/desktop/                  # (This command means to find the file we have just sent over with a USB stick) chmod +x Path_to_install. SH                         #对. sh file authorization./path_to_install. SH--user                         #运行. sh file
5.3 Installing third-party libraries

Enter the following command in the terminal

sudo apt-get install python-numpy Swig python-dev python-wheel #安装第三方库sudo apt-get  Install Gitgit clone git://

6. Install tensorflow6.1 Download TensorFlow

Enter the following command in the terminal

git clone https://Github.com/tensorflow/tensorflow

In particular, I am using the TensorFlow 0.11 version, which requires Cuda 7.5 or more, CuDNN v5.
The default download directory is under/home

6.2 Configuring TensorFlow

Or just the URL?
Https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/get_started/os_setup.md

Enter the following command in Terminal:

CD ~/tensorflow                        #切换到tensorflow文件夹. /configure                            #执行configure文件

Then follow the options:

6.3 Create Pip

Enter the following command in Terminal:

// Tensorflow/tools/pip_package:build_pip_package // tensorflow/tools/pip_package:build_pip_packageBazel-bin/tensorflow/tools/pip_package/build_pip_ package/tmp//* * * (your own user name)/DESKTOP/TENSORFLOW-0.11.0RC1-CP27-NONE-LINUX_X86_64.WHL 

6.4 Setting up the TensorFlow environment

// Tensorflow/tools/pip_package:build_pip_package  //tensorflow/tools/pip_package:build_pip_package-S. /bazel-bin/tensorflow/tools/pip_package/build_pip_package.runfiles/org_tensorflow/* . ln-s. /tensorflow/tools/pip_package/*. Python setup.py Develop

Description: In the compilation may take a long time, slowly wait on the line, perhaps my Computer configuration is too low, waiting for more than half of genius compiled.

Congratulations at this point, you have finished the installation

7. Test TensorFlow

Here to test, if you can see the same picture with me, then congratulations on your successful configuration of GPU version of the TensorFlow!

$ cd tensorflow/models/image/mnist$ python convolutional.py
8. Frequently Asked Questions

8.1 Circular Login

After installing the N-card driver in ubuntu14.04, there is an issue that cannot display the login screen or log in. This is mainly incompatible with the video card, the specific solution can refer to Google's solution, the keyword Ubuntu login loop.
After testing, the online tutorial is not applicable to me, helpless turn to ubuntu16.04

8.2 Missing third-party libraries

Because this tutorial is my installation after the success of writing, which inevitably forget some of the library installation, such as Git, pip these libraries, the installation process is very simple, specifically can Google.

8.3 TensorFlow Configuration Issues

When executing./configure or setting the TensorFlow environment, if there is a path to a library that cannot be found, check whether the CUDA environment variable is set correctly and refer to section 4.1 for details.

Description: Reproduced from

http://blog.csdn.net/zhaoyu106/article/details/52793183

ubuntu16.4 Build TensorFlow Environment

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.