Installing a NVIDIA GPU Driver and CUDA Toolkit (Recommended)
Scenarios
When using a P1, P2v, or PI1 ECS, make sure that the GPU driver and CUDA toolkit have been installed on the ECS. Otherwise, computing acceleration will not take effect.
- An ECS is available.
- If the ECS is created using a public image, the GPU driver and CUDA toolkit have been installed by default.
- If the ECS is created using a private image, check whether the GPU driver and CUDA toolkit have been installed. For details, see Checking Whether the GPU Driver and CUDA Toolkit Have Been Installed.
If the GPU driver and CUDA toolkit have not been installed on the target image, you can manually install them after the ECS is created. For details, see Installation Instructions.
Reading this section, you will learn:
- How can I check whether the GPU driver and CUDA toolkit have been installed?
- Have the GPU driver and CUDA toolkit been installed on an ECS?
- How can I manually install the desired GPU driver and CUDA toolkit?
Notes
- The operations described in this section apply only to P1, P2v, and PI1 ECSs.
Installation Instructions
- Check whether the GPU driver and CUDA toolkit have been installed on your ECS. For details, see Checking Whether the GPU Driver and CUDA Toolkit Have Been Installed.
- If they have been installed, no further action is required.
- If no, go to 2.
- Install the GPU driver and CUDA toolkit.
The installation method varies depending on the ECS OS. For details, see Table 1.
Table 1 Instructions to install the GPU driver and CUDA toolkit OS
Instruction
Windows
For details, see Installation Procedure for Windows.
- CentOS 7.x
- Red Hat Enterprise Linux (RHEL) 7.x
- EulerOS 2.x
For details, see Installation Procedure for CentOS 7.x, RHEL 7.x, and EulerOS 2.x.
- CentOS 6.x
- RHEL 6.x
For details, see Installation Procedure for CentOS 6.x and RHEL 6.x.
OpenSUSE 42.x
For details, see Installation Procedure for OpenSUSE 42.x.
Checking Whether the GPU Driver and CUDA Toolkit Have Been Installed
Perform the operations described in this section to check whether GPU driver and CUDA toolkit have been installed on an existing ECS. This method can also be used to check whether the installation of the GPU driver and CUDA toolkit is successful on an ECS with Automatically install GPU driver selected during the ECS creation.
- Windows
Check the C:\nvidia_install_log.txt file. If the installation failed, manually install the GPU driver and CUDA toolkit specified in the file.
- Linux
Check the /var/log/nvidia_install_log.txt file. If the installation failed, manually install the GPU driver and CUDA toolkit specified in the file.
Installation Procedure for Windows
- Download the GPU driver and CUDA toolkit installation packages required by the Windows ECS.
URL: http://mirrors.myhuaweicloud.com/ecs/windows/exe/
Visit the preceding URL on the ECS.
In the preceding URL, there are three folders, win2008r2, win2012r2, and win2016. Each folder consists of the the cuda and driver installation packages.
Obtain your desired installation packages according to the OS running on your ECS.
An example is provided as follows:
If your ECS runs Windows Server 2016, perform the following operations to obtain your desired GPU driver and CUDA toolkit:
- Visit http://mirrors.myhuaweicloud.com/ecs/windows/exe/.
Visit the preceding URL on the ECS.
The win2008r2, win2012r2, and win2016 folders are displayed.
- Open folder win2016.
The cuda and driver folders are displayed.
- Select your desired GPU driver and CUDA toolkit versions.
CUDA toolkit: cuda_9.0.176_windows.exe
GPU driver: 385.08-tesla-desktop-winserver-international.exe
- Visit http://mirrors.myhuaweicloud.com/ecs/windows/exe/.
- Install the GPU driver and CUDA toolkit.
Installation Procedure for CentOS 7.x, RHEL 7.x, and EulerOS 2.x
The operations described in this section apply to the ECSs running the following OSs:
- CentOS 7.x series
- Red Hat Enterprise Linux 7.x series
- EulerOS 2.x series
For a Linux ECS, you are advised to use Repo for installation.
- Configure CUDA Repo for the CentOS 7.x, RHEL 7.x, or EulerOS 2.x ECS.
- (Optional) Run the following command to clear Repo files on the CentOS 7.x or EulerOS 2.x ECS:
- Run the following command to create a nvidia-centos7.repo file:
vi /etc/yum.repos.d/nvidia-centos7.repo
- Add the following content to the file:
[ecs-cuda] name=ecs-cuda-$basearch baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/cuda/7/$basearch enabled=1 gpgcheck=0 [ecs-driver] name=ecs-driver-$basearch baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/driver/7/$basearch enabled=1 gpgcheck=0 [ecs-package] name=ecs-package-$basearch baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/package/7/$basearch enabled=1 gpgcheck=0
- Run the following command to install the desired Repo file:
yum install http://mirrors.myhuaweicloud.com/epel/epel-release-latest-7.noarch.rpm -y
- Run the following command to clear useless Repo files:
- Run the following command to update the epel-7 Repo file:
curl -o /etc/yum.repos.d/epel.repo http://mirrors.myhuaweicloud.com/repo/epel-7.repo
- Update the Repo file on the CentOS ECS.
- For the CentOS 7 system software repository
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.myhuaweicloud.com/repo/CentOS-Base-7.repo
- For the EulerOS system software repository
curl -o /etc/yum.repos.d/EulerOS-Base.repo http://mirrors.myhuaweicloud.com/repo/euler/EulerOS_2_2_base.repo
curl -o /etc/yum.repos.d/EulerOS-Base.repo http://mirrors.myhuaweicloud.com/repo/euler/EulerOS_2_3_base.repo
- RHUI system software repository has been available for RHEL ECSs.
- For the CentOS 7 system software repository
- Install CUDA on the CentOS 7.x, RHEL 7.x, or EulerOS 2.x ECS.
- Run the following command to install the kernel-devel that matches the kernel version:
- (Optional) For a CentOS ECS, run the following command to install DKMS:
- Run the following command to obtain the driver version:
- Run the following command to install the Repo file required by the driver version:
- Run the following command to install the driver:
- Run the following command to obtain the CUDA version:
yum list | grep cuda | grep rhel7
Figure 1 Obtaining the CUDA version
- Run the following command to install CUDA Repo:
yum install -y cuda-repo-rhel*
In the preceding command, * indicates the CUDA version obtained in 2.f. All the files in the target version must be installed.
- Run the following command to install CUDA:
- Run the following command to restart the ECS:
Installation Procedure for CentOS 6.x and RHEL 6.x
The operations described in this section apply to the ECSs running the following OSs:
- CentOS 6.x series
- Red Hat Enterprise Linux 6.x series
For a Linux ECS, you are advised to use Repo for installation.
- Configure CUDA Repo for the CentOS 6.x or RHEL 6.x ECS.
- (Optional) Run the following command to clear Repo files on the CentOS 6.x ECS:
- Run the following command to create a nvidia-centos6.repo file:
vi /etc/yum.repos.d/nvidia-centos6.repo
- Add the following content to the file:
[ecs-cuda] name=ecs-cuda-$basearch baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/cuda/6/$basearch enabled=1 gpgcheck=0 [ecs-driver] name=ecs-driver-$basearch baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/driver/6/$basearch enabled=1 gpgcheck=0 [ecs-package] name=ecs-package-$basearch baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/rpm/package/6/$basearch enabled=1 gpgcheck=0
- Run the following command to install the desired Repo file:
yum install http://mirrors.myhuaweicloud.com/epel/epel-release-latest-6.noarch.rpm -y
- Run the following command to clear useless Repo files:
- Run the following command to update the epel-6 Repo file:
curl -o /etc/yum.repos.d/epel.repo http://mirrors.myhuaweicloud.com/repo/epel-6.repo
- Update the Repo file on the CentOS ECS.
- Install CUDA on the CentOS 6.x or RHEL 6.x ECS.
- Run the following command to install the kernel-devel that matches the kernel version:
- Run the following command to obtain the driver version:
- Run the following command to obtain the Repo file version required by the driver: Figure 2 Obtaining the Repo file version
- Run the following command to install the desired Repo file version:
yum install nvidia-diag-driver-local-repo-rhel6-*.x86_64
In the preceding command, * indicates the Repo file version obtained in 2.c.
- Run the following command to install the driver:
- Run the following command to obtain the CUDA version:
yum list | grep cuda | grep rhel6
Figure 3 Obtaining the CUDA version
- Run the following command to install CUDA Repo:
In the preceding command, * indicates the CUDA version obtained in 2.f. All the files in the target version must be installed.
- Run the following command to install CUDA:
- Run the following command to restart the ECS:
Installation Procedure for Ubuntu 14.04 and Ubuntu 16.04
The operations described in this section apply to the ECSs running the following OSs:
- Ubuntu 14.04
- Ubuntu 16.04
For a Linux ECS, you are advised to use Repo for installation.
- Configure Repo on the Ubuntu 14.04 or Ubuntu 16.04 ECS.
- Configure Repo on the Ubuntu 14.04 ECS.
cp -fp /etc/apt/sources.list /etc/apt/sources.list.back cat > /etc/apt/sources.list <<EOF deb http://mirrors.myhuaweicloud.com/ubuntu/ trusty main restricted universe multiverse deb http://mirrors.myhuaweicloud.com/ubuntu/ trusty-security main restricted universe multiverse deb http://mirrors.myhuaweicloud.com/ubuntu/ trusty-updates main restricted universe multiverse deb http://mirrors.myhuaweicloud.com/ubuntu/ trusty-proposed main restricted universe multiverse deb http://mirrors.myhuaweicloud.com/ubuntu/ trusty-backports main restricted universe multiverse deb-src http://mirrors.myhuaweicloud.com/ubuntu/ trusty main restricted universe multiverse deb-src http://mirrors.myhuaweicloud.com/ubuntu/ trusty-security main restricted universe multiverse deb-src http://mirrors.myhuaweicloud.com/ubuntu/ trusty-updates main restricted universe multiverse deb-src http://mirrors.myhuaweicloud.com/ubuntu/ trusty-proposed main restricted universe multiverse deb-src http://mirrors.myhuaweicloud.com/ubuntu/ trusty-backports main restricted universe multiverse deb http://mirrors.myhuaweicloud.com/ecs/linux/apt ecs cuda deb http://mirrors.myhuaweicloud.com/ecs/linux/apt ecs driver EOF apt-get update --fix-missing wget -O - http://mirrors.myhuaweicloud.com/ecs/linux/apt/huaweicloud.ubuntu.gpg.key | apt-key add - apt update
- Configure Repo on the Ubuntu 16.04 ECS.
cp -fp /etc/apt/sources.list /etc/apt/sources.list.back cat > /etc/apt/sources.list <<EOF deb http://mirrors.myhuaweicloud.com/ubuntu/ xenial main restricted universe multiverse deb http://mirrors.myhuaweicloud.com/ubuntu/ xenial-security main restricted universe multiverse deb http://mirrors.myhuaweicloud.com/ubuntu/ xenial-updates main restricted universe multiverse deb http://mirrors.myhuaweicloud.com/ubuntu/ xenial-proposed main restricted universe multiverse deb http://mirrors.myhuaweicloud.com/ubuntu/ xenial-backports main restricted universe multiverse deb-src http://mirrors.myhuaweicloud.com/ubuntu/ xenial main restricted universe multiverse deb-src http://mirrors.myhuaweicloud.com/ubuntu/ xenial-security main restricted universe multiverse deb-src http://mirrors.myhuaweicloud.com/ubuntu/ xenial-updates main restricted universe multiverse deb-src http://mirrors.myhuaweicloud.com/ubuntu/ xenial-proposed main restricted universe multiverse deb-src http://mirrors.myhuaweicloud.com/ubuntu/ xenial-backports main restricted universe multiverse deb http://mirrors.myhuaweicloud.com/ecs/linux/apt ecs cuda deb http://mirrors.myhuaweicloud.com/ecs/linux/apt ecs driver EOF apt-get update --fix-missing wget -O - http://mirrors.myhuaweicloud.com/ecs/linux/apt/huaweicloud.ubuntu.gpg.key | apt-key add - apt update
- Configure Repo on the Ubuntu 14.04 ECS.
- Install CUDA on the Ubuntu 14.04 or Ubuntu 16.04 ECS.
- Run the following command to install the kernel-devel that matches the kernel version:
apt-get install -y --allow-unauthenticated linux-headers-`uname -r`
- Run the following command to obtain the driver version:
apt-cache search nvidia | grep driver | grep ubuntu
Figure 4 Obtaining the driver version
- Run the following command to install the desired Repo file:
apt-get install -y nvidia-diag-driver-local-repo-ubuntu*
In the preceding command, * indicates the driver version obtained in 2.b. Only one specified version can be installed.
- Run the following command to install the driver:
apt-get update && apt-get install -y --allow-unauthenticated cuda-drivers
- Run the following command to check the CUDA version:
apt-cache search cuda | grep ubuntu
Figure 5 Checking the CUDA version
- Run the following command to install the desired CUDA Repo file:
apt-get install -y cuda-repo-ubuntu*
In the preceding command, * indicates the driver version obtained in 2.g. All the files in the target version must be installed.
- Run the following command to install CUDA:
pt-get update && apt-get install -y --allow-unauthenticated cuda
- Run the following command to install the kernel-devel that matches the kernel version:
Installation Procedure for OpenSUSE 42.x
The operations described in this section apply to the ECSs running the following OSs:
- OpenSUSE 42.x series
- Run the following command to configure the opensuse_source4202 system software repository:
mv /etc/zypp/repos.d/* /tmp/ sudo zypper ar -fcg http://mirrors.myhuaweicloud.com/opensuse/distribution/leap/42.2/repo/oss HWCloud:42.2:OSS sudo zypper ar -fcg http://mirrors.myhuaweicloud.com/opensuse/distribution/leap/42.2/repo/non-oss HWCloud:42.3:NON-OSS sudo zypper ar -fcg http://mirrors.myhuaweicloud.com/opensuse/update/leap/42.2/oss HWCloud:42.2:UPDATE-OSS sudo zypper ar -fcg http://mirrors.myhuaweicloud.com/opensuse/update/leap/42.2/non-oss HWCloud:42.2:UPDATE-NON-OSS
- Configure CUDA Repo.
- Run the following command to create an HWnvidia-cudo.repo file:
vi /etc/zypp/repos.d/HWnvidia-cudo.repo
- Add the following content to the file:
[HWnvidia-cuda] enabled=1 autorefresh=1 baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/zypper/opensuse422/cuda type=rpm-md gpgcheck=0
- Run the following command to create an HWnvidia-driver.repo file:
- Add the following content to the file:
[HWnvidia-driver] enabled=1 autorefresh=1 baseurl=http://mirrors.myhuaweicloud.com/ecs/linux/zypper/opensuse422/driver type=rpm-md gpgcheck=0
- Run the following command to create an HWnvidia-cudo.repo file:
- Install CUDA.
- Run the following command to install kernel-devel:
zypper install -y kernel-default-devel=`uname -r|awk -F'-' '{print $1"-"$2}'`
- Run the following command to obtain the driver version:
zypper se nvidia | grep driver | grep opensuse
Figure 6 Obtaining the driver version
- Run the following command to install the desired driver Repo:
zypper install -y nvidia-diag-driver-local-repo-opensuse422-*
- Run the following command to install the driver:
zypper --gpg-auto-import-keys refresh && zypper install -y cuda-drivers
- Run the following command to check the CUDA version:
zypper se cuda | grep opensuse
Figure 7 Checking the CUDA version
- Run the following command to install the desired CUDA Repo file:
zypper --no-gpg-checks install -y cuda-repo-opensuse*
In the preceding command, * indicates the CUDA version.
- Run the following command to install CUDA:
zypper --gpg-auto-import-keys refresh && zypper install -y cuda
- Run the following command to install kernel-devel:
Last Article: Installing a GRID Driver on a GPU-accelerated ECS
Next Article: Obtaining a Tesla Driver and CUDA Toolkit
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.