Ubuntu TensorFlow Install (ubuntu16.04+cuda9.0+cudnn7.5+python3.6+tensorflow1.5)

Source: Internet
Author: User
Tags nvcc

On the internet to find a lot of cases, stepped on a lot of pits, feel more comprehensive is the following introduction

Http://www.cnblogs.com/xuliangxing/p/7575586.html

Let's talk about my steps:

First installed the Anacoda, because it is a scientific computing environment, so first installed the latest version, so the corresponding Python 3.6

Install graphics driver: gtx950m installed the latest 390 drivers, worried about incompatibility, so all with the latest

Installing Cuda, this pit was finally discovered, because the latest version of the 9.1 installation, the last TensorFlow only to find 9.0 of the files. So, this place must choose other release version->9.0

First download the corresponding Cuda on the official website (https://developer.nvidia.com/cuda-downloads):

(1) Installation of missing dependent library files

The command is as follows:

sudo apt-get install Freeglut3-dev build-essential libx11-dev libxmu-dev libxi-dev libgl1-mesa-glx libglu1 #安装依赖 Library 

(2) Install the execution file

sudo sh cuda_8. 0.61_375.26_linux.run  #执行安装文件

Note: The installation process will prompt you to do some confirmation, first of all, accept the terms of service, enter accept confirmation, and then will be prompted to install Cuda Tookit, cuda-example , etc., all enter Y to determine. However, please be aware that when asked to install the accompanying driver, be sure to select N!

Because we have installed the latest driver NVIDIA381 in the front, the accompanying driver is the old version and there is a problem, so don't choose to install the driver. The rest are directly default or select Yes.

(3) Setting environment variables

    • Enter a command to edit the environment variable configuration file
    • Append the following two lines of code at the end of the text (press "I" for editing)
Export path=/usr/local/cuda-8.0/bin: $PATH  export ld_library_path=/usr/local/cuda-8.0/lib64: $LD _ Library_path
Cuda_home=/usr/local/cuda
    • Save exit (Press "!WQ"), execute the following command to make the environment variable take effect immediately
#环境变量立即生效 sudo source ~/.BASHRC  

(4) Check that CUDA is configured correctly

  At this point, the basic Cuda has been installed, we can check whether CUDA is configured correctly by the following command:

NVCC--version

  :

(5) Test Cuda Sammples

  Why do I need to install Cuda samples? On the one hand, in order to learn cuda use, on the other hand, can test Cuda is really successful installation. If Cuda samples is fully compiled and does not have an error message (warning ignored), then the CUDA is successfully installed. If the last line shows the pass, but there is error during compilation, please search for the relevant error message on your own website after resolving.

# Switch to cuda-samples directory cd/usr/local/cuda- 8.0/samples or Cd/home/nvidia_cuda-8.0_samples # no make, first install command sudo apt-get Install Cmake,-j is the maximum use of CPU compilation, speed up compilation Make–j# compile, switch to release directory (/usr/local/cuda-8.0/samples/bin/x86_64/linux/release full catalog) CD./bin/x86_64/linux/ release# Verify the success of the run instance./ Devicequery # can take a serious look at its own results, which shows you the information about your Nvidia graphics card, and finally you can see the result = Pass succeeds.  

The output shows information about the graphics card, and finally result = PASS, which means Cuda is truly fully installed.

Then installs the CUDNN this also follows the original website description the procedure to be able

2.1. Download Cudnn

CUDNN is a library of GPU-accelerated computational deep neural networks. First go to the official website (https://developer.nvidia.com/rdp/cudnn-download) download CUDNN, need to register an account to download, no words to register one. Because my video card is gtx1080ti, so download the version number, the latest version is V7:

2.2, Installation Cudnn

Installing CUDNN is a simple, simple way to copy several files: library files and header files. Copy the CUDNN header file to the include path of the Cuda installation path and copy the CUDNN library file to the lib64 path of the Cuda installation path. The operation is as follows

1#Unzip the file2 TAR-ZXVF cudnn-8.0-linux-x64-V7.tgz34#Switch to the folder path that you just unzipped5CD Cuda6#Copy the header file in the include (remember to go to the include file and execute the command below)7 sudo cp/include/cudnn.h/usr/local/cuda/include/89#Copy the Lib file under Lib64 to the Cuda installation path under LIB64 (remember to go to the lib64 file to execute the command below)Ten sudo cp lib*/usr/local/cuda/lib64/1112#Set permissionssudo chmod a+r/usr/local/cuda/include/Cudnn.hsudo chmod a+r/usr/local/cuda/lib64/libcudnn*  ====== update soft connect ======cd/usr/local/cuda/lib64/ sudo rm-rf libcudnn.so libcudnn.so.7 
                                    
                                     # 
                                     Delete the original dynamic file, version number note Changes, you can view the Cudnn lib64 folder in the ln-s libcudnn.so.7.0.2 libcudnn.so.7 #  Generate soft links (note that this is the CUDNN version you download, you can view your own LIBCUDNN version under/usr/local/cuda/lib64)sudo ln-s libcudnn.so.7 libcudnn.so # Generate soft links in sudo ldconfig-v # immediate effect          
                                    

Note: The version number of the soft connection above is based on the Lib version number of the CUDNN that you actually downloaded.

Finally, let's see if the Cuda is still available after verifying the installation Cudnn

NVCC--version  

Finally install the latest version of TensorFlow

You can refer to TensorFlow's official installation tutorial (https://www.tensorflow.org/install/), the official website provides the PIP, Docker, virtualenv, Anaconda or source code compiled method installation TensorFlow, we mainly introduce here with Anaconda installation. Other installation methods, you can go to the official installation tutorial to view.

3.1 Installing TensorFlow

The official download source for installing TensorFlow Cpu,tensorflow via Anaconda is now available on GitHub (Https://github.com/tensorflow/tensorflow) to find the corresponding version number:

 (1), create a Conda environment named TensorFlow Python 3.6
2.7Conda create-n tensorflow python=2.73.4conda create-n tensorflow python=3.43.5< C12>conda create-n TensorFlow python=3.5
3.6Conda create-n tensorflow python=3.6   #我下的TensorFlow   The corresponding Python is version 3.6, so I'll use this line

  
Note: (according to tensorflow version number, be sure to set the Python version number, remember to remember!!!!! Important thing to say three times! Otherwise will be reported all kinds of wrong)
(2), activating Conda Environment
SOURCE Activate TensorFlow
(3), TensorFlow each version (the latest seems to be 1.3 version)

Then choose the corresponding download link (operating system, Python version, CPU version or CPU+GPU version) according to the different TensorFlow versions to be installed, and the official documentation has information about it.

Python 2.7Cpu:https://Storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp27-none-linux_x86_64.whlGpu:https://Storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp27-none-linux_x86_64.whl===============================================================================================
Python
3.4Cpu:https://Storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp34-cp34m-linux_x86_64.whlGpu:https://Storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp34-cp34m-linux_x86_64.whl===============================================================================================
Python 3.5Cpu:https://Storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.3.0-cp35-cp35m-linux_x86_64.whlGp:https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.3.0-cp35-cp35m-linux_x86_64. WHL===============================================================================================
Python 3.6Cpu:https://storage.googleapis.com/tensorflow/linux/cpu/ TENSORFLOW-1.3.0-CP36-CP36M-LINUX_X86_64.WHLGpu:https://Storage.googleapis.com/tensorflow/linux /GPU/TENSORFLOW_GPU-1.3.0-CP36-CP36M-LINUX_X86_64.WHL
Follow the original address instructions to continue the installation test

Ubuntu TensorFlow Install (ubuntu16.04+cuda9.0+cudnn7.5+python3.6+tensorflow1.5)

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.