In the whole process of machine learning, configuring the environment has always been a relatively complicated thing. Today, I introduce several methods to configure the environment according to the official documentation of Nvidia.

Installation plan

Gitlab.com/nvidia/cont… Domestic synchronization mirror: gitee.com/zionfuo/cud…

The installation script is in the dist directory

Select the VERSION number of CUDA

Cuda8 /cuda9 on the moment pool cloud uses ubuntu16.04, and cuda10 and above use ubuntu18.04

  • Base: cudA installation mode
  • Devel: NVCC installation mode
  • Runtime: CUDnn and other installation modes

Checking the System Version

source /etc/os-release && echo $VERSION_ID
Copy the code

Cuda and NVCC installation tutorials

Import apt repository and its GPG key

# check if the system output 16.04 Please use the following command curl - fsSL https://mirrors.aliyun.com/nvidia-cuda/ubuntu1604/x86_64/7fa2af80.pub | apt - key add - echo "deb HTTP: / / https://mirrors.aliyun.com/nvidia-cuda/ubuntu1604/x86_64/ / "> / etc/apt/sources. List. D/cuda. List # check if system output 18.04, Please use the following command curl - fsSL https://mirrors.aliyun.com/nvidia-cuda/ubuntu1804/x86_64/7fa2af80.pub | apt - key add - echo "deb https://mirrors.aliyun.com/nvidia-cuda/ubuntu1804/x86_64/ /" > /etc/apt/sources.list.d/cuda.listCopy the code

Cuda and NVCC are available in Nvidia-CUDa of Ali Source, and the corresponding version of the software can be searched in Ali source.

Mirrors.aliyun.com/nvidia-cuda…

Install the required version of CUDA

Cuda11 is used as an example. The installation commands are as follows based on the Dockerfile

Apt-get update && apt-get install-y --no-install-recommends cuda-cudart-11-0=11.0.221-1 cuda-compat-11-0 && ln -s cuda-11.0 /usr/local/cuda && rm -rf /var/lib/apt/lists/*Copy the code

Install the required version of NVCC

Take CUDa10 NVCC as an example. The following installation commands are displayed based on the Dockerfile

# "10-0" to install CUDA10.0 NVCC, Install apt-get update && apt-get install -y --no-install-recommends apt install cuda-command-line-tools-10-0 rm -rf /var/lib/apt/lists/*Copy the code

Cudnn and tensorRT installation tutorial

# check if the system output 16.04 Please use the following command curl - fsSL https://mirrors.cloud.tencent.com/nvidia-machine-learning/ubuntu1604/x86_64/7fa2af80.pub | apt - key add - echo "deb https://mirrors.cloud.tencent.com/nvidia-machine-learning/ubuntu1604/x86_64//" > The/etc/apt/sources. List. D/cuda. List # check if system output 18.04, Please use the following command curl - fsSL https://mirrors.cloud.tencent.com/nvidia-machine-learning/ubuntu1804/x86_64/7fa2af80.pub | apt - key add - echo "deb https://mirrors.cloud.tencent.com/nvidia-machine-learning/ubuntu1804/x86_64//" > /etc/apt/sources.list.d/cuda.listCopy the code

Cudnn and tensorRT are available in NviDIa-machine-Learning of Tencent source, and the corresponding version of the software can be searched in Tencent source.

Mirrors.cloud.tencent.com/nvidia-mach…

Install the required version of CUDNN

Cuda10.2 cudNN 8.0.3 is used as an example. The following installation commands are obtained according to the Dockerfile

Apt-get update && apt-get install-y --no-install-recommends libcudnn8=8.0.3.33-1+ CUDa10.2&&blrecommends Libcudnn8 =8.0.3.33-1+ CUDa10.2&& apt-mark hold libcudnn8 && rm -rf /var/lib/apt/lists/*Copy the code

Install the required version of tensorRT

According to the official documentation of TensorFlow, the installation commands are as follows

www.tensorflow.org/install/gpu

Apt-get install-y --no-install-recommends libnvinfer7=7.1.3-1+ CUDa11.0 Libnvinfer - dev = 7.1.3-1 + cuda11.0 libnvinfer - plugin7 = 7.1.3-1 + cuda11.0Copy the code