Start with Linux, install ubuntu16.04+nvidia387+cuda8.0+cudnn5.1+tensorflow1.0.1

Source: Internet
Author: User
Tags administrator password virtualenv gtx

Because of the recent deep learning is very popular, loaded TensorFlow study. This article mainly introduces the installation process, explains the problems you encounter, and records how to deal with them, the principle is not able to explain. Because I have never used Linux before, this article is afraid of a primary error, hope forgive me, thank you. (This article was written on March 17, 2017)

In order to be able to run TensorFlow with the GPU (NVIDIA GTX1080), the following should be installed sequentially according to the survey:

Ubuntu, nvidia driver, CUDA, CUDNN, TensorFlow

Installing Ubuntu16.04

Ubuntu16.04 can be downloaded through the official website and made into a U disk installation. For more convenient driver graphics, install Linux directly and do not install dual systems or virtual machines. After installation, due to Ubuntu source in foreign countries, in order to more efficient update, the use of Zhong Ke mirror source. To do this, press Ctrl+alt+t to open the command line, and then enter:

sudo gedit/etc/apt/sources.list

The first time you run as an administrator, you need to enter an administrator password. Then replace the content with the following:

# Default Annotated source image to improve apt update speed, if necessary, can self-uncomment deb https://mirrors.ustc.edu.cn/ubuntu/xenial main restricted universe multiverse# DEB-SRC https://mirrors.ustc.edu.cn/ubuntu/xenial main main restricted universe MultiverseDeb https://mirrors.ustc.edu.cn/ubuntu/xenial-updates main restricted universe multiverse# DEB-SRC https://mirrors.ustc.edu.cn/ubuntu/xenial-updates main restricted universe multiverseDeb https://mirrors.ustc.edu.cn/ubuntu/xenial-backports main restricted universe multiverse# DEB-SRC https://mirrors.ustc.edu.cn/ubuntu/xenial-backports main restricted universe multiverseDeb https://mirrors.ustc.edu.cn/ubuntu/xenial-security main restricted universe multiverse# DEB-SRC https://mirrors.ustc.edu.cn/ubuntu/xenial-security main restricted universe multiverse# Pre-release software source, not recommended to enable # Deb https://mirrors.ustc.edu.cn/ubuntu/xenial-proposed main restricted universe multiverse# DEB-SRC https://mirrors.ustc.edu.cn/ubuntu/xenial-proposed main restricted universe multiverse

Then update the source and install the package:

sudo apt-get updatesudo apt-get upgrade

* Install interface Select deselect download from Network. Even so, in the later retriving file, it is also possible to encounter the situation of the progress bar card dead (I am the campus network, need network login), the processing method is to unplug the network cable, after the installation is complete and then plug the network cable back.

Installing NVIDIA378.13

Install Nvidia's latest graphics driver, enter your own graphics card model from the official website, click Search, prompt to download the video card driver for 375.39 (Release 2017.2.14), however, in the Enter your own graphics card model page, select "Beta and older" below. Drivers "Connection, which can be selected to 378.13. Since I am using 375.39, after the installation of TensorFlow through the source method encountered problems (here can not be tube), the search is recommended to use 378 of the model, instead of 378.13 driver. Move the file to the home directory and change the name to "Nvidia.run"

The specific installation method is: CTRL+ALT+F1, go to the Command line page, enter the user name and password login, first close x Server (I understand that is the graphical interface):

sudo /etc/init.d/lightdm stop

Then run Nvidia.run to install:

sudo SH Nvidia.run # Note At this point the file is already in the home directory

Installation, you will encounter "the distribution-provided Pre-instrall script failed", can ignore, continue to install. But there will be questions about Neuveau, but Nvidia will help you to add Neuveau to blacklist, only need to agree to do so, but this installation will fail, exit, you need to enter:

sudo update-initramfs-u

Then type reboot to restart the computer. At this point, the desktop resolution will be reduced, press CTRL+ALT+F1 to enter the command line, the administrator login, close x server, and then install the Nvidia driver, the process will say that Nvidia will be the other X server obscured (presumably this means), agreed to, and then the smooth installation. After that, reboot restarts.

* If the installation is completed, the login interface to log in, that is, enter the password, and return the words, shut off the motherboard secret boot.

Installing CUDA8.0

Select Linux-x86_64-ubuntu-16.04-runfile (local), then rename the file Cuda.run and move it to the home root directory, press ctrl+alt+t to open the command line and run:

sudo SH Cuda.run

All the way to the bottom of the space, type accept agree to install, some places need to choose, in addition to asking whether to install: Nvidia driver 375.xx Select No (already installed 378.13), others agree and use the default path, that can complete the installation. Finally, add the environment variable:

Export path="$PAHT:/usr/local/cuda-8.0/bin"export Ld_library_path=" $LD _library_path:/usr/local/cuda-8.0/lib64 "

Then let the environment variable take effect with the following command:

SOURCE ~/.BASHRC

* If you encounter a problem with insufficient space when installing CUDA, you can join when running Cuda.run:

sudo SH Cuda.run--tmpdir=/opt/temp/

I personally do not encounter this problem, and if you add the following code, it will not work.

Installing cudnn5.1

Download the compressed package and rename it to cudnn.tgz and move it to the home root directory, then run the command to extract:

tar -zxvf cudnn.tgz

You will get five files and copy the files to the corresponding Cuda directory:

sudo cp cuda/include/cudnn.h/usr/local/cuda/include/sudocp cuda/lib64/libcudnn*/usr/local/ cuda/lib64/sudochmod a+r/usr/local/cuda/include/cudnn.hsudochmod a+r/usr/local/cuda/lib64/libcudnn*

Installing TensorFlow

According to the official website, Ubuntu can be used in 5 ways, respectively: Virtualenv, "native" Pip, Docker, Anaconda, and install from source. The installation was successful using Anaconda because I encountered a problem in the last step through source and virtualenv.

1. Install Anaconda, please refer to Anaconda website

2. Create the Conda environment, using the command:

SOURCE Create-n TensorFlow

Activate the Conda environment, at which point your command line is more (TensorFlow):

Install TensorFlow in Conda Environment, the final connection is the TensorFlow Python package, as needed to choose, as I use the GPU, Linux system, Python2.7, using the following command

Install --ignore-installed--upgrade https://storage.googleapis.com/tensorflow/linux/gpu/ TENSORFLOW_GPU-1.0.1-CP27-NONE-LINUX_X86_64.WHL

After the installation is complete, try to run

(TensorFlow) Some names  about your computer >>> import TensorFlow as TF

If it can run, congratulations on the successful installation. You can then exit the Conda environment with the following command

(tensorflow) Some name about your computer $ source Deactivate TensorFlow

* If you encounter problems similar to ImportError:libcudart.so. Version: Cannot open Shared object file, you can view your environment variables by following command, whether path and Ld_library_path all contain

Export

My final path contains the following paths:

Declare-x path="/home/your username/anaconda2/envs/tensorflow/bin:/home/your user name/anaconda2/bin:/usr/local/ Cuda-8.0/bin:usr/local/cuda/bin: (Some other path)"

If there are missing can try to use export path= "$PATH: Missing Path" Supplement, remember last source ~/.BASHRC

(In fact, I was in the source and virtualenv encounter is the problem, but I did not know how to solve it)

REF:

https://www.tensorflow.org/install/(TensorFlow official tutorial, very detailed and useful)

http://blog.csdn.net/silangquan/article/details/9473613 (about X server)

Http://askubuntu.com/questions/112302/how-do-i-disable-the-nouveau-kernel-driver?answertab=oldest#tab-top (about Neuveau's)

Http://www.nvidia.com/download/driverResults.aspx/114708/en-us (blinding kernel module in the case of installing Nvida drivers)

Http://www.rodsbooks.com/efi-bootloaders/secureboot.html#disable (About Login interface Loop card dead)

http://stackoverflow.com/questions/42013316/ After-building-tensorflow-from-source-seeing-libcudart-so-and-libcudnn-errors (about importerror:libcudart.so.8.0: Cannot open shared object File:no such file or directory)

http://stackoverflow.com/questions/36159194/ Tensorflow-libcudart-so-7-5-cannot-open-shared-object-file-no-such-file-or-di (about importerror:libcudart.so.8.0: Cannot open shared object File:no such file or directory)

Finally, special thanks to 52NLP, which two articles introduced from the Ubuntu installation to the last run TensorFlow, to my help very much, my installation method is also based on these two articles, thank you.

Deep Learning Host Environment configuration: Ubuntu16.04+nvidia GTX 1080+cuda8.0

Deep Learning Host Environment configuration: Ubuntu16.04+geforce GTX 1080+tensorflow

Start with Linux, install ubuntu16.04+nvidia387+cuda8.0+cudnn5.1+tensorflow1.0.1

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.