当前位置:   article > 正文

Ubuntu Server 20.04 系统安装(四):深度学习 GPU 环境配置(CUDA12.2驱动+CUDA Toolkit 12.2+cuDNN v8.9.7)_ubuntu cuda12

ubuntu cuda12

引言

本文以 Ubuntu 20.04 操作系统为例,演示如何配置深度学习 GPU 环境。

一、NVIDIA 显卡驱动的安装

访问如下网址

https://developer.nvidia.com/cuda-downloads?target_os=Linux&target_arch=x86_64&Distribution=Ubuntu&target_version=20.04&target_type=runfile_local
在这里插入图片描述

下载推荐的cuda并安装

复制箭头所指处的命令到命令行

wget https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda_12.2.0_535.54.03_linux.run 

必须先关图形界面(重要)

如果不关,运行下面安装的命令之后会报错,装不上

systemctl isolate multi-user.target

关闭图形界面之后会重启,输入如下命令

安装驱动

sudo sh cuda_12.2.0_535.54.03_linux.run

稍等一会
在弹出的安装界面中选“continue”,如果选了会跳出安装,就说明安装失败,给了失败日志的路径,自己查看原因,一般是gcc版本问题,

gcc降级

  1. sudo apt-get install gcc-7 g++-7
  2. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 9
  3. sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 1
  4. sudo update-alternatives --display gcc //查看默认版本
  5. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 9
  6. sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-9 1
  7. sudo update-alternatives --display g++

如果没问题继续安装:
在这里插入图片描述
cuda安装包是自带显卡驱动的,所以这一步按空格去掉安装显卡驱动的选项,然后选择install
在这里插入图片描述

开启图形界面

sudo systemctl start graphical.target

二、安装 CUDA Toolkit 12.2

准备

开始安装之前,需要修改 apt-get 的镜像源,不然国内下载速度很慢。我们这里以阿里源为例演示如何修改。

  1. 备份官方源
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak

安装vim:

sudo apt-get install vim

运行 sudo vim /etc/apt/sources.list 打开文件,并按 i 插入以下内容,按 ESC 后再按 :wq 保存退出

sudo vim /etc/apt/sources.list
  1. deb http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
  2. deb-src http://mirrors.aliyun.com/ubuntu/ focal main restricted universe multiverse
  3. deb http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
  4. deb-src http://mirrors.aliyun.com/ubuntu/ focal-security main restricted universe multiverse
  5. deb http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
  6. deb-src http://mirrors.aliyun.com/ubuntu/ focal-updates main restricted universe multiverse
  7. # deb http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
  8. # deb-src http://mirrors.aliyun.com/ubuntu/ focal-proposed main restricted universe multiverse
  9. deb http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
  10. deb-src http://mirrors.aliyun.com/ubuntu/ focal-backports main restricted universe multiverse
  1. 更新数据源列表
sudo apt-get update

安装参考 NVIDIA 官网提供的教程

Quick Start Guide 12.3 documentation

  1. wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
  2. sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
  3. wget https://developer.download.nvidia.com/compute/cuda/12.3.1/local_installers/cuda-repo-ubuntu2004-12-3-local_12.3.1-545.23.08-1_amd64.deb
  4. sudo dpkg -i cuda-repo-ubuntu2004-12-3-local_12.3.1-545.23.08-1_amd64.deb
  5. sudo cp /var/cuda-repo-ubuntu2004-12-3-local/cuda-*-keyring.gpg /usr/share/keyrings/
  6. sudo apt-get update
  7. sudo apt-get -y install cuda-toolkit-12-3

sudo reboot # 非必需

执行完上述安装操作后,需要配置环境变量,让该系统下的所有用户都能使用:

  1. 打开全局配置文件
sudo vi /etc/profile
  1. 在文件末尾添加如下内容后保存退出。
  1. export PATH=/usr/local/cuda-12.3/bin${PATH:+:${PATH}}
  2. export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

  1. 激活环境变量
source /etc/profile
  1. 运行 nvcc -V 来校验安装是否成功,若正确显示版本号则说明安装成功
  1. $ nvcc -V
  2. nvcc: NVIDIA (R) Cuda compiler driver
  3. Copyright (c) 2005-2023 NVIDIA Corporation
  4. Built on Fri_Nov__3_17:16:49_PDT_2023
  5. Cuda compilation tools, release 12.3, V12.3.103
  6. Build cuda_12.3.r12.3/compiler.33492891_0

二、安装 cuDNN v8.9.7

安装参考 NVIDIA 官方提供的教程

  1. 官网下载合适版本的离线安装包


2. 开始安装

  1. sudo dpkg -i cudnn-local-repo-ubuntu2004-8.9.7.29_1.0-1_amd64.deb
  2. sudo cp /var/cudnn-local-repo-ubuntu2004-8.9.7.29/cudnn-local-30472A84-keyring.gpg /usr/share/keyrings/
  3. cd /var/cudnn-local-repo-ubuntu2004-8.9.7.29/
  4. sudo dpkg -i libcudnn8_8.9.7.29-1+cuda12.2_amd64.deb
  5. sudo dpkg -i libcudnn8-dev_8.9.7.29-1+cuda12.2_amd64.deb
  6. sudo dpkg -i libcudnn8-samples_8.9.7.29-1+cuda12.2_amd64.deb
  1. 校验安装是否成功(最终输出 Test passed! 则说明安装成功)
  1. cp -r /usr/src/cudnn_samples_v8/ $HOME
  2. cd $HOME/cudnn_samples_v8/mnistCUDNN
  3. make clean && make
  4. ./mnistCUDNN

校验安装时如果遇到下述错误:

  1. ```bash
  2. test.c:1:10: fatal error: FreeImage.h: No such file or directory
  3. 1 | #include "FreeImage.h"
  4. | ^~~~~~~~~~~~~
  5. compilation terminated.
  6. >>> WARNING - FreeImage is not set up correctly. Please ensure FreeImage is set up correctly. <<<

可通过如下方式解决,然后重新进行校验

sudo apt-get -y install  libfreeimage3 libfreeimage-dev

重启后验证通过

sudo reboot

验证通过:

  1. wyr@ubuntu2004w1:~/cudnn_samples_v8/mnistCUDNN$ ./mnistCUDNN
  2. Executing: mnistCUDNN
  3. cudnnGetVersion() : 8401 , CUDNN_VERSION from cudnn.h : 8401 (8.4.1)
  4. Host compiler version : GCC 9.4.0
  5. There are 2 CUDA capable devices on your machine :
  6. device 0 : sms 56 Capabilities 6.0, SmClock 1328.5 Mhz, MemSize (Mb) 16280, MemClock 715.0 Mhz, Ecc=1, boardGroupID=0
  7. device 1 : sms 56 Capabilities 6.0, SmClock 1328.5 Mhz, MemSize (Mb) 16280, MemClock 715.0 Mhz, Ecc=1, boardGroupID=1
  8. Using device 0
  9. Testing single precision
  10. Loading binary file data/conv1.bin
  11. Loading binary file data/conv1.bias.bin
  12. Loading binary file data/conv2.bin
  13. Loading binary file data/conv2.bias.bin
  14. Loading binary file data/ip1.bin
  15. Loading binary file data/ip1.bias.bin
  16. Loading binary file data/ip2.bin
  17. Loading binary file data/ip2.bias.bin
  18. Loading image data/one_28x28.pgm
  19. Performing forward propagation ...
  20. Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
  21. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 0 memory
  22. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
  23. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 57600 memory
  24. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 178432 memory
  25. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 184784 memory
  26. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 2057744 memory
  27. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  28. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  29. Testing cudnnFindConvolutionForwardAlgorithm ...
  30. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.024864 time requiring 0 memory
  31. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.025152 time requiring 0 memory
  32. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.066912 time requiring 57600 memory
  33. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.097024 time requiring 178432 memory
  34. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.144352 time requiring 2057744 memory
  35. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.275520 time requiring 184784 memory
  36. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  37. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  38. Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
  39. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 0 memory
  40. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
  41. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 128000 memory
  42. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 4656640 memory
  43. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 1433120 memory
  44. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 2450080 memory
  45. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  46. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  47. Testing cudnnFindConvolutionForwardAlgorithm ...
  48. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.062560 time requiring 0 memory
  49. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.062880 time requiring 0 memory
  50. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.107712 time requiring 2450080 memory
  51. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.114528 time requiring 1433120 memory
  52. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.116704 time requiring 128000 memory
  53. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.130944 time requiring 4656640 memory
  54. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  55. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  56. Resulting weights from Softmax:
  57. 0.0000000 0.9999399 0.0000000 0.0000000 0.0000561 0.0000000 0.0000012 0.0000017 0.0000010 0.0000000
  58. Loading image data/three_28x28.pgm
  59. Performing forward propagation ...
  60. Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
  61. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 0 memory
  62. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
  63. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 57600 memory
  64. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 178432 memory
  65. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 184784 memory
  66. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 2057744 memory
  67. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  68. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  69. Testing cudnnFindConvolutionForwardAlgorithm ...
  70. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.024512 time requiring 0 memory
  71. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.040768 time requiring 0 memory
  72. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.052480 time requiring 57600 memory
  73. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.067328 time requiring 2057744 memory
  74. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.069856 time requiring 178432 memory
  75. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.077664 time requiring 184784 memory
  76. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  77. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  78. Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
  79. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 0 memory
  80. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
  81. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 128000 memory
  82. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 4656640 memory
  83. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 1433120 memory
  84. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 2450080 memory
  85. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  86. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  87. Testing cudnnFindConvolutionForwardAlgorithm ...
  88. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.062336 time requiring 0 memory
  89. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.064128 time requiring 0 memory
  90. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.077600 time requiring 1433120 memory
  91. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.079904 time requiring 2450080 memory
  92. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.113632 time requiring 128000 memory
  93. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.123968 time requiring 4656640 memory
  94. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  95. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  96. Resulting weights from Softmax:
  97. 0.0000000 0.0000000 0.0000000 0.9999288 0.0000000 0.0000711 0.0000000 0.0000000 0.0000000 0.0000000
  98. Loading image data/five_28x28.pgm
  99. Performing forward propagation ...
  100. Resulting weights from Softmax:
  101. 0.0000000 0.0000008 0.0000000 0.0000002 0.0000000 0.9999820 0.0000154 0.0000000 0.0000012 0.0000006
  102. Result of classification: 1 3 5
  103. Test passed!
  104. Testing half precision (math in single precision)
  105. Loading binary file data/conv1.bin
  106. Loading binary file data/conv1.bias.bin
  107. Loading binary file data/conv2.bin
  108. Loading binary file data/conv2.bias.bin
  109. Loading binary file data/ip1.bin
  110. Loading binary file data/ip1.bias.bin
  111. Loading binary file data/ip2.bin
  112. Loading binary file data/ip2.bias.bin
  113. Loading image data/one_28x28.pgm
  114. Performing forward propagation ...
  115. Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
  116. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 5632 memory
  117. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
  118. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 28800 memory
  119. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 178432 memory
  120. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 184784 memory
  121. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 2057744 memory
  122. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  123. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  124. Testing cudnnFindConvolutionForwardAlgorithm ...
  125. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.026944 time requiring 0 memory
  126. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.052864 time requiring 28800 memory
  127. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.064928 time requiring 178432 memory
  128. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.073376 time requiring 2057744 memory
  129. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.093312 time requiring 184784 memory
  130. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.109312 time requiring 5632 memory
  131. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  132. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  133. Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
  134. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 1433120 memory
  135. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 4656640 memory
  136. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 2450080 memory
  137. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 2000 memory
  138. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
  139. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 0 memory
  140. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  141. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  142. Testing cudnnFindConvolutionForwardAlgorithm ...
  143. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.087264 time requiring 2450080 memory
  144. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.088320 time requiring 1433120 memory
  145. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.088864 time requiring 0 memory
  146. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.097152 time requiring 2000 memory
  147. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.122624 time requiring 4656640 memory
  148. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.195200 time requiring 0 memory
  149. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  150. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  151. Resulting weights from Softmax:
  152. 0.0000001 1.0000000 0.0000001 0.0000000 0.0000563 0.0000001 0.0000012 0.0000017 0.0000010 0.0000001
  153. Loading image data/three_28x28.pgm
  154. Performing forward propagation ...
  155. Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
  156. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 5632 memory
  157. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
  158. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 28800 memory
  159. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 178432 memory
  160. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 184784 memory
  161. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 2057744 memory
  162. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  163. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  164. Testing cudnnFindConvolutionForwardAlgorithm ...
  165. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.026272 time requiring 0 memory
  166. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.047712 time requiring 28800 memory
  167. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.068864 time requiring 2057744 memory
  168. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.069856 time requiring 5632 memory
  169. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.075904 time requiring 184784 memory
  170. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.097664 time requiring 178432 memory
  171. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  172. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  173. Testing cudnnGetConvolutionForwardAlgorithm_v7 ...
  174. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: -1.000000 time requiring 1433120 memory
  175. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: -1.000000 time requiring 4656640 memory
  176. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: -1.000000 time requiring 2450080 memory
  177. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: -1.000000 time requiring 2000 memory
  178. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: -1.000000 time requiring 0 memory
  179. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: -1.000000 time requiring 0 memory
  180. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  181. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  182. Testing cudnnFindConvolutionForwardAlgorithm ...
  183. ^^^^ CUDNN_STATUS_SUCCESS for Algo 4: 0.079712 time requiring 2450080 memory
  184. ^^^^ CUDNN_STATUS_SUCCESS for Algo 1: 0.079808 time requiring 2000 memory
  185. ^^^^ CUDNN_STATUS_SUCCESS for Algo 7: 0.083232 time requiring 1433120 memory
  186. ^^^^ CUDNN_STATUS_SUCCESS for Algo 0: 0.088128 time requiring 0 memory
  187. ^^^^ CUDNN_STATUS_SUCCESS for Algo 5: 0.117088 time requiring 4656640 memory
  188. ^^^^ CUDNN_STATUS_SUCCESS for Algo 2: 0.185120 time requiring 0 memory
  189. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 6: -1.000000 time requiring 0 memory
  190. ^^^^ CUDNN_STATUS_NOT_SUPPORTED for Algo 3: -1.000000 time requiring 0 memory
  191. Resulting weights from Softmax:
  192. 0.0000000 0.0000000 0.0000000 1.0000000 0.0000000 0.0000714 0.0000000 0.0000000 0.0000000 0.0000000
  193. Loading image data/five_28x28.pgm
  194. Performing forward propagation ...
  195. Resulting weights from Softmax:
  196. 0.0000000 0.0000008 0.0000000 0.0000002 0.0000000 1.0000000 0.0000154 0.0000000 0.0000012 0.0000006
  197. Result of classification: 1 3 5
  198. Test passed!
  199. wyr@ubuntu2004w1:~/cudnn_samples_v8/mnistCUDNN$

安装CUDA后变成了桌面版的了,让我很纳闷,只好一个一个的卸载

  1. # 卸载gnome
  2. sudo apt-get remove gnome -y
  3. # 卸载 gnome-shell
  4. sudo apt-get remove gnome-shell -y
  5. # 彻底卸载删除gnome的相关配置文件
  6. sudo apt-get purge gnome -y
  7. # 卸载臃肿的服务组件
  8. sudo apt-get remove snapd -y
  9. # 卸载依赖组件
  10. sudo apt-get autoremove -y
  11. # 清理安装gnome时候留下的缓存程序软件包
  12. sudo apt-get autoclean
  13. sudo apt-get clean
  14. # 重启系统
  15. sudo reboot
  16. sudo shutdown -r now

GPUstat

这是一个可以替换 nvidia-smi 查看显卡信息的一个工具。可以非常清楚地看到各个显卡的温度、利用率、正在使用的用户以及各用户占用的显存等。

在这里插入图片描述

使用如下命令安装:

  1. sudo apt install python3-pip
  2. sudo pip install gpustat

用法非常简单,记住下面这一条命令就行:

gpustat -i

NetSM

这是一个跨平台的命令行网速监测工具,可以看到服务器实时网速显示。

在这里插入图片描述

通过如下命令安装:

  1. sudo apt install python3-pip
  2. sudo pip install netsm

用法非常简单,记住下面这一条命令就行:

netsm show

Tmux

跑耗时较长的任务时,可以打开 tmux 将任务挂起,即使你关闭了窗口,任务仍然在后台运行。

sudo apt-get install tmux

Axel

区别于 wget 单线程下载的多线程下载工具。用法很简单,通过 -n 参数指定线程数即可,例如:axel -n 10 下载链接

sudo apt-get install axel

提示

上述配置了三个深度学习 GPU 环境,分别是 PyTorch,TensorFlow 2 和 TensorFlow 1。且都是通过管理员来配置的。其他普通用户使用时,仅需使用 conda 在新建环境时克隆即可,下面给一个例子。

例如,普通用户要使用 PyTorch 环境,但他同时还需要安装 requests 包,直接在名为 pytorch 的环境里面是没有办法安装,因为缺少写入权限。因此可以通过如下克隆的方式安装:

  1. conda create -n pytorch2 --clone pytorch
  2. conda activate pytorch2
  3. pip install requests

这样既节省了服务器的存储空间,又避免了重复安装环境的烦恼。


当然你不克隆,直接激活使用也是可以的:

  1. conda activate pytorch
  2. pip install requests

因为默认会安装 requests 到用户家目录下,不会和其他用户的环境产生冲突。但如果环境多了,就不太容易区分了。

参考

简易记录:安装GPU驱动,CUDA和cuDNN
使用ubuntu 20.04 进行机器学习配置环境 必须做的事情
【Linux】在Ubuntu上安装和使用miniconda
Administering a multi-user conda installation
Start Locally | PyTorch
Anaconda 镜像使用帮助
使用 pip 安装 TensorFlow




ubuntu20.04安装12.2版本的cuda_cuda12.2-CSDN博客

【Linux】Ubuntu 20.04 深度学习 GPU 环境配置(CUDA Toolkit 11.7 + cuDNN v8.4.1)_Xavier Jiezou的博客-CSDN博客

ubuntu20.04 TLS Server升级后安装了gnome桌面环境_u013250861的博客-CSDN博客

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/128612
推荐阅读
相关标签
  

闽ICP备14008679号