GPU configuration environment Ubuntu 18.04: Install the like CUDA 9.0

Not long ago, the International Association for Computing Machinery (ACM) decided to award Geoffrey Hinton, Yann LeCun, and Yoshua Bengio year 2018 Turing Award, in recognition of their pioneering contributions to the field of study in depth made. In fact, in the previous three decades, the three men have been in the field of neural network theory and application of deep plowing, but their earlier work did not attract much attention. Until recent years, the depth of learning suddenly become very popular. This is one big reason is precisely because the current hardware devices (especially GPU technology) development, making DNN large amount of computing is no longer a scourge.

Now, in order to study the depth of learning, it is essential to build the GPU environment. But for many people, or due to lack of experience, or due to the upgrading of software and hardware, all the things that make GPU configuration environment has become time-consuming. This paper demonstrates GPU configuration environment on Ubuntu 18.04 system (mainly installed CUDA) of the basic processes and precautions.

In the previous article , we have demonstrated the process of how to install the NVIDIA graphics driver on Ubuntu 18.04 system. That time, we installed driver version is 390.116, while the Nvidia official website show with CUDA compatible version should be 9.0, so this paper as an example to demonstrate.

Table 1. CUDA Toolkit and Compatible Driver Versions

 

Typically, install on Ubuntu 18.04 system GCC and G ++ version is relatively high, for example, you can use the following command to check your GCC and G ++ version on your computer:

$ gcc --version  
$ g++ --version

Execution results are shown mounted on a visible system GCC and G ++ version 7.4, so we must first try to put down their version, which is mounted corresponding CUDA version necessary.

GCC can not downgrade to drop too low, or there may be some unexpected problems, we recommend here downgrade to GCC5.5. The method is followed by two lines of command in the command line on the line. (These two commands that are used to install the appropriate version of gcc and g ++)

$ sudo apt install gcc-5 
$ sudo apt install g++-5

Then try to look at the version found or the default gcc 7.4, because no modifications soft link. Into the / usr / bin directory, run it:

$ ls -l gcc*

As shown below, it can be seen gcc gcc-7 points, so we need to modify the soft link, so that point gcc gcc-5.

In order to link to gcc gcc-5, run the following command:

$ sudo mv gcc gcc.bak #备份 
$ sudo ln -s gcc-5 gcc #重新链接gcc

$ sudo mv g++ g++.bak #备份 
$ sudo ln -s g++-5 g++ #重新链接g++

And then check the version, you will find that the 5.5 has become.

Next, download the CUDA on Nvidia's Web site to go to. As shown below, select the version of the operating system. CUDA 9.0 support only download and install Ubuntu 17.04 and 16.04 of. But in fact, 18.04 version of the system can be mounted 16.04 version corresponding CUDA. Therefore, we chose to 16.04, and then select [runfile (local)].

The download includes a master installer, and four patch sets, which are downloaded to the machine, e.g. Downloads file.

Into the path of good stores just down the installation files, enter the command to install Base Installer:

$ sudo sh cuda_9.0.176_384.81_linux.run

As shown below. Note that, depending on the version you download the CUDA differences in the installation file, the above command may have to adjust a little. This, you can copy from the download page above given direct orders Nvidia website, sure.

Next, the installation program displays the protocol is installed, press the Enter key to jump all the way to the final. You'll see some problems as shown below. It should be noted that we have previously installed the graphics driver, so no choice in whether a question install the graphics driver, select the default path or other yes you can.

Will appear after the installation is complete the following screen prompts CUDA installation is incomplete, because the video card driver is not installed, directly ignored.

Then install the four patches in the same manner:

$ sudo sh cuda_9.0.176.1_linux.run 
$ sudo sh cuda_9.0.176.2_linux.run 
$ sudo sh cuda_9.0.176.3_linux.run
$ sudo sh cuda_9.0.176.4_linux.run

After each patch is installed you will get the following screen.

Here, you have successfully installed CUDA, and finally, even more configure the environment variable. The method is to edit ~ / .bashrc file. Because .bashrc file is usually hidden files, if you can not see it in the table of contents, you can use [Ctrl + H] to force show hidden files. Editing software to open it with a file, and then in the end of the file add the following sentence:

export  PATH=/usr/local/cuda-9.0/bin:$PATH
export  LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64$LD_LIBRARY_PATH

As shown below, save and close the file.

现在重启一下计算机。然后,继续安装cuDNN,它提供了一些用于深度学习加速的库。同样,你需要到英伟达的官网上去下载相应的安装文件。注意,这一步,你需要注册一个账户。然后,如下图所示,选择与CUDA 9.0相匹配的cuDNN,并下载其中的cuDNN Library for Linux。

下载的时候发现是一个压缩包,下完之后解压。解压出来是一个cuda文件夹,进去有两个文件夹,一个include和一个lib64。进入刚刚解压得到的cuda文件夹,并在命令行中执行如下命令:

执行完之后,cuDNN算是安装完成了。最后,你可以安装一下GPU版的Tensorflow,并运行一些简单的神经网络训练例子来测试一下你的GPU环境。

 

(本文完)

发布了358 篇原创文章 · 获赞 4280 · 访问量 417万+

Guess you like

Origin blog.csdn.net/baimafujinji/article/details/89506896