Ubuntu 18.04 Lab Environment configuration
System: Ubuntu 18.04 64bit
Graphics: Nvidia GeForce 1080Ti
Download
There is a relationship between Cuda, CuDNN, and Nvidia, and it is recommended that you determine which Cuda version to install.
Note: Some of the packages that you will install later do not support CUDA9.1.
Cuda:https://developer.nvidia.com/cuda-toolkit-archive
Cudnn:https://developer.nvidia.com/rdp/cudnn-archive
Nvidia Driver: Https://www.geforce.cn/drivers
anaconda:https://www.anaconda.com/download/
The experimental environment selected is the Cuda version of 9.0. Currently Cuda only supports Ubuntu17.04 and Ubuntu16.04 system version of the download installation, due to the existence of some backward compatibility, tested can choose 16.04 System version installation files. Installation Type Select Runfile, where the download file name "Cuda_9.0.176_384.81_linux.run" in 384.81 refers to the driver version must be lower than this version, but also not too low. Install other versions as well.
Nvidia drives this experiment by selecting version 384.13.
CUDNN Select the latest version of V7.1.4 that supports Cuda 9.0. :
Installing the NVIDIA Driver
The Nouveau driver that comes with Ubuntu affects Cuda installation, which causes some operations to log on after a few actions are not disabled.
Run at Terminal:
If there is output, run:
At the end of the open file, add:
blacklist nouveau
Perform:
Reboot and execute again:
If there is no output, you can perform the subsequent operation.
Perform an uninstall of the sudo apt-get remove --purge nvidia-*
original NVIDIA driver.
Ctrl+alt+f3 enters the character interface. Execution: sudo service lightdm stop
closes the graphical interface.
To enter the drive storage folder, execute:
sudo chmod a+x NVIDIA-Linux-*.run //获取权限sudo ./NVIDIA-Linux-*.run –no-x-check –no-nouveau-check –no-opengl-files //安装驱动
Where-no-opengl-files is a must, the other two can not be knocked.
Reboot after completion. Run the command nvidia-smi
. The following interface appears to indicate that the driver installation was successful.
Cuda Installation
Since Cuda 9.0 supports only GCC 6.0 and below, and Ubuntu 18.04 has a pre-installed GCC version of 7.3,
So manually downgrade:
sudo apt-get install gcc-4.8 sudo apt-get install g++-4.8
After loading into the/usr/bin directory, execute: ls -l gcc*
. The results are as follows:
lrwxrwxrwx 1 root root 7th May 16 18:16 /usr/bin/gcc -> gcc-7.3
Discover that GCC is linked to gcc-7.0 and need to change it to link to gcc-4.8 as follows:
sudo mv gcc gcc.bak #备份 sudo ln -s gcc-4.8 gcc #重新链接
Similarly, the same changes are made to g++:
ls -l g++*
lrwxrwxrwx 1 root root 7th May 15:17 g++ -> g++-7.3
You need to change the g++ link to g++-4.8:
sudo mv g++ g++.bak sudo ln -s g++-4.8 g++
View gcc and g++ version numbers again:
gcc -v g++ -v
Displays GCC version 4.8, which indicates that the GCC 4.8 installation was successful.
Enter the folder where the Cuda installation files are stored. Perform:
sudo sh cuda_*.run --no-opengl-libs
Perform the same action on the four patches that are downloaded.
Note: Do not install the Nvidia driver in Cuda during execution.
After the installation is complete sudo gedit /etc/profile
, execute:. Add a path at the end of the file after opening it, as follows:
export PATH=/usr/local/cuda-9.0/bin:$PATHexport LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64$LD_LIBRARY_PATH
After saving, restart the computer and enter the terminal. Perform:
cd /usr/local/cuda-9.2/samples/1_Utilities/deviceQuerysudo make./deviceQuery
If there is a result=pass, Cuda installation is successful.
Installing CUDNN
Enter the CUDNN installation file directory and execute:
tar -xzvf cudnn-9.0-linux-x64-v7.1.tgzsudo cp cuda/include/cudnn.h /usr/local/cuda/includesudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64sudo chmod a+r /usr/local/cuda/include/cudnn.h
Installing Anaconda
Download the python3.6 version of the installation package.
Go in Anaconda Install file directory, execute:
Post-Installation execution: A source ~/.bashrc
conda list
list of installed packages is displayed after the terminal executes, indicating that the installation was successful. Otherwise execute sudo gedit ~/.profile
, add the following information.
if [ -d "$HOME/anaconda3/bin" ] ; then
Execute: source .profile
to make it effective.
Environment creation and Dependency package installation
The program is written by python2.7 and we need to create the virtual environment through the installed Anaconda. (It can be done directly in the system without using Anaconda, and the Anaconda facilitates switching between different environments.) )
In terminal execution: conda create -n py27 pip python=2.7
Create an environment. -N is name.
Executes the source activate py27
activation environment.
Perform pip install torch torchvision
the installation Pytorch and torchvision (CUDA9.0 environment). See other versions of Cuda user installation commands https://pytorch.org/
.
Ubuntu 18.04 Lab Environment configuration