Because Ubuntu18.04 is a relatively new release, CUDA and CUDNN are not yet compatible. The highest version is 17.04, but 18.04 is actually quite compatible. In order to avoid the reader to step on the pit, this article successfully tested the Ubuntu18.04 environment configuration deep learning environment (GPU:1080ti), including:

Install and test CUDA9.0+ cudn7.4 +TensorFlow1.8+Pytorch0.4, and download related software.

The hardware configuration

DELL R730 server (rack 2U server)\

The graphics card 1080 ti * 2

The memory of 64 g

CPU 2620V4* 2

Power supply DELL 1600w *2

Hard disk 600 g * 2 * 2 + 2 t \

The installation

Note: All installation packages and drivers mentioned in the installation steps are available for download in this article. The download address is at the end of this article.

1. Install Ubuntu \

Using a USB flash drive to install Ubuntu:

Reference: jingyan.baidu.com/article/a37…

At the beginning of the installation, select “Install Ubuntu” and press enter. After a while, if the screen displays “Input not supported”, which is related to Ubuntu’s support for graphics cards, select Nomodeset on the F6 screen of the main installation screen and proceed to the next installation

The installation process is omitted. Download address of installation image:

www.ubuntu.com/download/de…

Download: ubuntu – 18.04.1 – desktop – amd64. Iso

Note: If the download is not convenient, baidu cloud download is provided at the end of this article.

2. Install the SSH

Note: This step requires input in the command window on the server desktop. After this step, you can use SSH to remotely connect to the server. XShell is used in this article.

sudo apt-get install openssh-server
Copy the code

3. Install the 1080TI graphics card driver

The default graphics driver installed is not a Nvidia driver, so remove the old one first.

sudo apt-get purgenvidia*
Copy the code

Add Graphic Drivers PPA

sudo add-apt-repository ppa:graphics-drivers/ppa
Copy the code
sudo apt-get update
Copy the code

View the appropriate driver version:

ubuntu-drivers devices
Copy the code

Figure: List of available Nvidia drivers

It can be seen from the figure that the recommended driver is the latest version 415. Install the driver:

sudo apt-get install nvidia-driver- 415.
Copy the code

Restart the machine after installation:

sudo reboot
Copy the code

Restart complete run

nvidia-smi
Copy the code

Take a look at the graphics card driver in effect:

Figure: Graphics card driver in effect

4. Install the dependent libraries

sudo apt-get install freeglut3-dev build-essential libx11-dev libxmu-dev libxi-devlibgl1-mesa-glx libglu1-mesa libglu1-mesa-dev
Copy the code

5. The GCC version is lowered

CUDA9.0 requires the GCC version to be 5.x or 6.x. You need to configure the GCC version yourself. Run the following command to change the GCC version.

  • Version installed
Sudo apt-get install GCC- 5
sudo apt-get install g++- 5
Copy the code
  • Replace the previous version \ with a command
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc- 5 50
sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++- 5 50
Copy the code

6. Install CUDA9.0

  • Download from:

Developer.nvidia.com/cuda-90-dow…

  • Version selection:

Linux –x86-64, Ubuntu–17.04, runfile(local), Download Base Installer and 4 Patch\

Note: If the download is not convenient, baidu cloud download is provided at the end of this article.

After entering the directory, run the following commands:

Note: During the installation process, you will be prompted whether to install the graphics card driver. In this case, you should select N, select Y or enter to install the other driver:

sudo sh cuda_9. 0176._38481._linux.run
Copy the code
sudo sh cuda_9. 0176.1._linux.run
Copy the code
sudo sh cuda_9. 0176.2._linux.run
Copy the code
sudo sh cuda_9. 0176.3._linux.run
Copy the code
sudo sh cuda_9. 0176.4._linux.run
Copy the code
  • Set environment variables in ~/.bashrc:
sudo vi ~/.bashrc
Copy the code

Add at the end:

exportPATH=/usr/local/cuda9.0/bin${PATH:+:${PATH}} 
exportLD_LIBRARY_PATH=/usr/local/cuda9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Copy the code

run

source ~/.bashrc
Copy the code

For it to work, you’d better reboot it.

sudo reboot
Copy the code

After reboot, test whether CUDA is successful (this step can be omitted)

cd ~/NVIDIA_CUDA9.0_Samples/1_Utilities/deviceQuery 
make -j4  
sudo ./deviceQuery
Copy the code

If the graphics card performance information is displayed, Result = PASS indicates that CUDA is successfully installed.

7. Install CUDNN

Developer.nvidia.com/rdp/cudnn-d…

You need to log in and agree to download it.

Note: If the download is not convenient, baidu cloud download is provided at the end of this article.

Click:

Download cuDNN V7.4.1 (Nov 8, 2018), for CUDA 9.0 –cuDNNLibrary for Linux

Save to cudNn-9.0-linux-x64-v7.4.1.5.tgz for download

The installation is very simple, just decompress and copy to the corresponding CUDA path of the system. Note that the last line should not be copied with “-d”.

tar -zxvf cudnn9.0-linux-x64-v74.1.. 5.tgz
Copy the code
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
Copy the code
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
Copy the code
sudo chmod a+r/usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
Copy the code

The installation is complete if no errors are reported.

8. Install Tensorflow GPU 1.8

Because Anaconda provides a complete scientific library, you can use Anaconda directly for installation.

1) Install Anaconda

Download address: www.anaconda.com/download/

Note: If the download is not convenient, baidu cloud download is provided at the end of this article.

Anaconda3-5.3.0-linux-x86_64. sh (Python 3.7)

bash Anaconda35.3. 0-Linux-x86_64.sh
Copy the code

2) Change PIP and Conda to domestic sources

Since it is slow to access PIP and Conda in China, it is recommended to change to domestic source:

A. Change PIP source to Ari cloud:

mkdir ~/.pip
Copy the code
cat > ~/.pip/pip.conf << EOF
[global]
trusted-host=mirrors.aliyun.com
index-url=https://mirrors.aliyun.com/pypi/simple/
EOF
Copy the code

B. Change the source of CONDA to Tsinghua University:

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
Copy the code

3) install Python3.6 virtual environment in Anaconda

TensorFlow does not support Anaconda’s Python version 3.7, so we created a Python virtual environment

conda create --name tf python=3.6Create a TF environmentCopy the code

Virtual environment commands:

Source Activate TF # Activate tf environmentCopy the code
Source deactivate TF # Exit tf environmentCopy the code
Conda remove --name tf --allCopy the code

4) Install TensorFlow GPU 1.8 in Anaconda

pip install --ignore-installed --upgrade tensorflow-gpu
Copy the code

The following components will be automatically installed:

Numpy, wheel, tensorflow-tensorboard, six, Protobuf, HTML5lib, Markdown, Werkzeug, bleach, setupTools

5) Use the following code to test the installation

Command line input: \

source activate tf
Copy the code
python
Copy the code

Enter the following code from the Python command:

import tensorflowas tf
hello= tf.constant('Hello, TensorFlow! ')
sess= tf.Session()
print(sess.run(hello))
Copy the code

No error is configured.

9. Install Keras

Install directly in this virtual environment:

pip install keras
Copy the code

10. Pytorch installation

Install directly in this virtual environment:

conda install pytorch torchvision -c pytorch
Copy the code

Pytorch is installed successfully:

Command line input: \

source activate tf
Copy the code
python
Copy the code

Enter the following code from the python command:

import torch
print(torch.cuda.is_available())
Copy the code

 

If True is returned, the installation succeeded.

conclusion

Due to the recent release of Ubuntu18.04, relatively few users, in order to avoid readers to step on the pit, this paper successfully tested the configuration of deep learning environment in the Ubuntu18.04 environment (GPU:1080ti), including:

CUDA9.0+ CUDN7.4 +TensorFolw1.8+Pytorch0.4 installation and testing, and baidu cloud download of related software.

Author: Huang Haiguang

reference

Blog.csdn.net/weixin_4186…

Please reply to “1804” for all software downloads required for this article

You can also download it directly with Baidu Cloud:

Link: pan.baidu.com/s/11AxudhGg…

Extraction code: W214

Please follow and share ↓↓↓\

Machine learning beginners \

QQ group: 654173748

Past wonderful review \

  • Easy introduction to machine learning – with recommended learning materials

  • Machine learning learner public account download resources summary (a) \

  • Github Image download by Dr. Hoi Kwong (Machine learning and Deep Learning resources)

  • Printable version of Machine learning and Deep learning course notes \

  • Machine Learning Cheat Sheet – understand Machine Learning like reciting TOEFL Vocabulary

  • Introduction to Deep Learning – Python Deep Learning, annotated version of the original code in Chinese and ebook

  • Zotero paper Management tool

  • The mathematical foundations of machine learning