1 | lspci | grep NVIDIA |
1 2 | 01:00.0 3D controller: NVIDIA Corporation Device 20f1 (rev a1) 81:00.0 3D controller: NVIDIA Corporation Device 20f1 (rev a1) |
这里结果中的“00:”前缀,表示该显卡是虚拟机上挂载的显卡。
1 | nvidia-smi |
如果没有找到命令,则说明驱动没有安装。
再执行nvcc -V,如果没有找到命令,则说明CUDA没有安装。如果已经安装CUDA,则会出现如下结果:
1 | nvcc -V |
1 2 3 4 5 | nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2021 NVIDIA Corporation Built on Wed_Jul_14_19:41:28_PDT_2021 Cuda compilation tools, release 11.4, V11.4.100 Build cuda_11.4.r11.4/compiler.30188945_0 |
如果有结果,则说明存在nouveau。没有则直接跳过这一步。
1 | vim /usr/lib/modprobe.d/dist-blacklist.conf
|
然后在最后添加如下内容:
1 2 | blacklist nouveau options nouveau modeset=0 |
安装Nvidia驱动所需要的依赖包为kernel-devel、gcc、dkms。
验证CUDA,编译并运行验证Sample代码所需要的依赖包为gcc-c++。
1 | uname -r
|
1 | 4.19.90-2003.4.0.0036.oe1.aarch64 |
然后查看当前yum环境中提供的kernel-devel包的版本。
1 | yum list|grep kernel-devel |
1 | kernel-devel.aarch64 4.19.90-2003.4.0.0036.oe1 @anaconda |
yum提供的kernel-devel的版本是不是和当前服务器内核版本一致,如果一致则直接安装,不一致则更换一个和当前内核一致的版本。
华为镜像源配置对应的环境镜像: https://mirrors.huaweicloud.com/home
1 | yum install gcc dkms gcc-c++ |
驱动路径下执行命令:
1 | ./NVIDIA-Linux-aarch64-470.82.01.run --kernel-source-path=/usr/src/kernels/4.19.90-2003.4.0.0036.oe1.aarch64/ |
注意如下提示,请输入“YES”;安装结束后,执行命令nvidia-smi可以查看显卡信息。
1 | Would you like to register the kernel module sources with DKMS? This will allow DKMS to automatically build a new module, if you install a different kernel later. |
执行nvidia-smi命令后,能看到类似下面的表格。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | +-----------------------------------------------------------------------------+ | NVIDIA-SMI 410.73 Driver Version: 410.73 CUDA Version: 10.0 | |-------------------------------+----------------------+----------------------+ | GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | |===============================+======================+======================| | 0 GeForce GTX 108... Off | 00000000:01:00.0 On | N/A | | 35% 44C P8 18W / 250W | 4694MiB / 11176MiB | 0% Default | +-------------------------------+----------------------+----------------------+ | 1 GeForce GTX 108... Off | 00000000:02:00.0 Off | N/A | | 33% 38C P8 17W / 250W | 12MiB / 11178MiB | 0% Default | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: GPU Memory | | GPU PID Type Process name Usage | |=============================================================================| | 0 1846 G /usr/bin/X 29MiB | | 0 1903 G /usr/bin/gnome-shell 15MiB | | 0 11521 C ./darknet_gpu 2319MiB | | 0 32297 C ./darknet 2319MiB | +-----------------------------------------------------------------------------+ |
第一行表示当前显卡驱动的版本和显卡支持的CUDA的版本;这里支持CUDA的版本是只能够支持的最高版本,是可以向下兼容的。
参数 |
说明 |
---|---|
GPU |
本机的GPU编号。 |
NAME |
GPU名称。 |
Persistence-M |
驱动常驻模式,如果设置为ON,则GPU功耗大但是启动新的GPU应用花费的时间更少。 |
Fan |
风扇转速百分比。 |
Temp |
显卡温度。 |
Perf |
当前的性能状态,P0最高,P12最低。 |
Pwr |
当前能耗。 |
Bus-Id |
GPU总线。 |
Disp.A |
GPU显示功能是否初始化。 |
Memory-Usage |
显存的使用情况。 |
Volatile GPU-Util |
浮动的GPU利用率。 |
ECC |
错误码。 |
Compute M |
计算模式。 |
Processes |
每块GPU的进程情况。 |
CUDA:GPU编程的语言函数。CUDA 版本 (对应)> Tensorflow 版本。
cuDNN:深度学习/矩阵运算的加速库。 CUDA 版本 (对应)> cuDNN 版本。
显卡驱动(CUDA驱动):向下兼容的,可以一直保持最新。
1 | sh cuda_11.4.1_470.57.02_linux_sbsa.run
|
1 2 | Do you accept the above EULA? (accept/decline/quit): accept/decline/quit: accept |
如已安装高版本,不安装以下工具。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | Install the CUDA 9.0 Toolkit? (y)es/(n)o/(q)uit: y Enter Toolkit Location [ default is /usr/local/cuda-9.0 ]: Do you want to install a symbolic link at /usr/local/cuda? (y)es/(n)o/(q)uit: y Install the CUDA 9.0 Samples? (y)es/(n)o/(q)uit: y Enter CUDA Samples Location [ default is /root ]: Installing the CUDA Toolkit in /usr/local/cuda-11.4 ... =========== = Summary = =========== Driver: Not Selected Toolkit: Installed in /usr/local/cuda-11.4 Samples: Installed in /root, but missing recommended libraries Please make sure that - PATH includes /usr/local/cuda-11.4/bin - LD_LIBRARY_PATH includes /usr/local/cuda-9.0/lib64, or, add /usr/local/cuda-11.4/lib64 to /etc/ld.so.conf and run ldconfig as root To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-11.4/bin Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-11.4/doc/pdf for detailed information on setting up CUDA. ***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 384.00 is required for CUDA 9.0 functionality to work. To install the driver using this installer, run the following command, replacing <CudaInstaller> with the name of this run file: sudo <CudaInstaller>.run -silent -driver Logfile is /tmp/cuda_install_24940.log |
export PATH=${PATH}:/usr/local/cuda-11.4/bin export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/cuda-11.4/lib64
保存文件后执行source /etc/profile。
1 | nvcc -V
|
1 2 3 4 5 | nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2021 NVIDIA Corporation Built on Wed_Jul_14_19:41:28_PDT_2021 Cuda compilation tools, release 11.4, V11.4.100 Build cuda_11.4.r11.4/compiler.30188945_0 |
如果前面安装了CUDA,这里可以执行如下操作:
1 2 | cd /root/NVIDIA_CUDA-11.4_Samples/1_Utilities/deviceQuery make |
编译完成后执行./deviceQuery。
1 | ./deviceQuery |
1 2 3 4 | ./deviceQuery Starting... CUDA Device Query (Runtime API) version (CUDART static linking) Detected 2 CUDA Capable device(s) Device 0: "NVIDIA A100-PCIE-40GB" |
1 | tar -xvf cudnn-11.4-linux-aarch64sbsa-v8.2.4.15.tgz |
将解压后的文件复制到cuda的安装后的目录中。
1 2 | cp cuda/include/cudnn.h /usr/local/cuda-11.4/include cp cuda/lib64/libcudnn* /usr/local/cuda-11.4/lib64 |
将复制后的文件全部添加“a+r”权限。
1 | chmod a+r /usr/local/cuda-11.4/include/cudnn.h /usr/local/cuda-11.4/lib64/libcudnn* |