ubuntu18 + cuda10.2 + cudnn + 7.6.5 + pytorch1.1.0 + python3.6 installation environment configuration

deep-image-matting project runtime configuration instructions

Preface: This article describes how to configure the operating environment cuda10.2 + cudnn7.6.5 + pytorch1.1.0 + python3.6 in ubuntu system environment. In this paper there is the assumption that you have ubuntu installed the latest video card driver and running. There are five major steps, followed in order by record description. Reference article: https: //www.cnblogs.com/booturbo/p/11834661.html installation cuda + cudnn and https://blog.csdn.net/JohnsonSmile/article/details/89597095 create a virtual environment + installation pytorch

5.1 Installation cuda10.2

5.1.1 download cuda10.2

Cuda download link below, please download the required version according to their actual

https://developer.nvidia.com/cuda-downloads

5.1.2 Installation cuda10.2

The first step recommended download 'runfile (local)' document on the grounds that the installation process is relatively straightforward, the statement is as follows. In the terminal run command and then enter the phrase, because cuda comes installed by default graphics driver, which you have previously installed graphics driver conflict, so after a carriage return you need to install the graphics driver of the "hook" to cancel out.

sudo sh xxxxxxxxx.run

The second step, after the installation is complete you need to edit environment variables. As follows:

# 打开环境配置文件,terminal命令如下:
sudo gedit ~/.bashrc
#然后在文件最后添加下面3行,保存
export CUDA_HOME=/usr/local/cuda

export PATH=$PATH:$CUDA_HOME/bin

export LD_LIBRARY_PATH=/usr/local/cuda-10.1/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
# 然后刷新环境变量,terminal命令如下
source ~/.bashrc 

The third step is to test whether the installation is successful cuda, terminal statement is as follows. If the version number show cuda Description no problem.

nvcc -V

5.2 Installation cudnn7.6.5

5.2.1 download cudnn7.6.5

The first step, to go to the official website to download, to register and log in and fill out a questionnaire before downloading, download the corresponding file according to their needs.

# 官网下载cudnn链接
https://developer.nvidia.com/rdp/cudnn-download?spm=a2c4e.10696291.0.0.1df819a4HJWSTe
# 一共要下载四个文件,名字如下:
 cuDNN Library for Linux,
 cuDNN Runtime Library for Ubuntu18.04(Deb),
 cuDNN Developer Library for Ubuntu18.04(Deb),
 cuDNN Code Samples and User Guide for Ubuntu18.04(Deb),

A second step of sequentially executed code installed cudnn

# 解压 cuDNN Library for Linux,terminal命令如下:
tar -zxvf xxxxxxxxx.tgz
# 将解压出来的文件复制到安装的CUDA环境中,terminal命令如下:
sudo cp cuda/include/cudnn.h /usr/local/cuda/inlude
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64 
# 更改文件权限,terminal命令如下:
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
# 依次安装 cuDNN Runtime Library for Ubuntu18.04(Deb),cuDNN Developer Library for Ubuntu18.04(Deb),cuDNN Code Samples and User Guide for Ubuntu18.04(Deb)三个Deb 包,terminal命令如下:
sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.2_amd64.deb
sudo dpkg -i libcudnn7-doc_7.6.5.32-1+cuda10.2_amd64.deb

The third step, after the end of the installation, reboot the system, and then test the installation was successful.

# 测试命令如下
cp -r /usr/src/cudnn_samples_v7/ ~
cd ~/cudnn_samples_v7/mnistCUDNN
make clean && make
./mnistCUDNN

Emergence Test passed! No error that is successfully installed

5.3 to create a virtual environment

5.3.1 installation creates a virtual environment toolkit virtualenv

terminal command is as follows:

sudo pip install virtualenv
sudo pip install virtualenvwrapper

5.3.2 to create a virtual environment to develop versions of python

terminal command is as follows:

# virtualenv -p [/usr/bin/pythonx] [path/env_name]
virtualenv -p /usr/bin/python3.6 ./env_python3.6
# (验证操作)进入虚拟环境的terminal命令,进入虚拟环境路径-》bin目录下,激活虚拟环境:
source activate
# (验证操作)退出虚拟环境
deactivate

5.4 Installation pytorch

5.4.1 enter the virtual environment

# 进入虚拟环境的terminal命令,进入虚拟环境路径-》bin目录下,激活虚拟环境,terminal命令如下:
source activate

5.4.2 mounting pytorch1.1.0 + torchvision0.3.0

# terminal命令如下:
pip install torch==1.1.0 torchvision==0.3.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

5.4.3 modify Pillow version 5.4.0

Pillow default installation of version 7.0.0 is being given at the time of import torch, terminal command:

pip install Pillow==5.4.0 -i https://pypi.tuna.tsinghua.edu.cn/simple

5.5 Installation requirements.txt

The other project required the installation kit, requirements.txt file inside the project. terminal command is as follows:

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
Published 45 original articles · won praise 24 · views 3410

Guess you like

Origin blog.csdn.net/my_name_is_learn/article/details/104680861