KylinOS V10安装CUDA和CUDNN

查看系统版本:

cat /etc/os-release 
NAME="Kylin Linux Advanced Server"
VERSION="V10 (Lance)"
ID="kylin"
VERSION_ID="V10"
PRETTY_NAME="Kylin Linux Advanced Server V10 (Lance)"
ANSI_COLOR="0;31"

nvidia-smi查看支持的CUDA版本:

[root@localhost opt]# nvidia-smi 
Sun Apr  7 11:00:01 2024       
+---------------------------------------------------------------------------------------+
| NVIDIA-SMI 535.104.05             Driver Version: 535.104.05   CUDA Version: 12.2     |
|-----------------------------------------+----------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |         Memory-Usage | GPU-Util  Compute M. |
|                                         |                      |               MIG M. |
|=========================================+======================+======================|
|   0  NVIDIA A40                     On  | 00000000:03:00.0 Off |                    0 |
|  0%   28C    P8              13W / 300W |     18MiB / 46068MiB |      0%      Default |
|                                         |                      |                  N/A |
+-----------------------------------------+----------------------+----------------------+
                                                                                         
+---------------------------------------------------------------------------------------+
| Processes:                                                                            |
|  GPU   GI   CI        PID   Type   Process name                            GPU Memory |
|        ID   ID                                                             Usage      |
|=======================================================================================|
|    0   N/A  N/A      1668      G   /usr/libexec/Xorg                             4MiB |
+---------------------------------------------------------------------------------------+
[root@localhost opt]# 

显示CUDA Version: 12.2

下载CUDA

https://developer.nvidia.com/cuda-12-0-0-download-archive

图片[1]-KylinOS V10安装CUDA和CUDNN-UU技术社区

确保磁盘剩余空间足够,如出现如下错误:

Extraction failed.
Ensure there is enough space in /tmp and that the installation package is not corrupt
Signal caught, cleaning up

可使用–tmpdir指定缓存目录

sudo sh cuda_12.0.0_525.60.13_linux.run --tmpdir=/opt/cuda

图片[2]-KylinOS V10安装CUDA和CUDNN-UU技术社区

输入accept回车

图片[3]-KylinOS V10安装CUDA和CUDNN-UU技术社区

已经安装好可驱动选择取消Driver的安装然后点击Install

安装完成

===========
= Summary =
===========

Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-12.0/

Please make sure that
 -   PATH includes /usr/local/cuda-12.0/bin
 -   LD_LIBRARY_PATH includes /usr/local/cuda-12.0/lib64, or, add /usr/local/cuda-12.0/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-12.0/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 525.00 is required for CUDA 12.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 /var/log/cuda-installer.log

添加环境变量

vim ~/.bashrc

添加

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda

查看cuda版本:

source ~/.bashrc

[root@localhost opt]# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Mon_Oct_24_19:12:58_PDT_2022
Cuda compilation tools, release 12.0, V12.0.76
Build cuda_12.0.r12.0/compiler.31968024_0
[root@localhost opt]# 

安装CUDNN

下载地址:https://developer.nvidia.com/rdp/cudnn-archive

根据实际情况下载合适的版本(需要提前创建登录NVIDIA账号)

图片[4]-KylinOS V10安装CUDA和CUDNN-UU技术社区

解压:

tar -xvf cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz

复制移动部分文件

cd cudnn-linux-x86_64-8.9.7.29_cuda12-archive/
cp include/cudnn.h /usr/local/cuda/include/
cp lib/libcudnn* /usr/local/cuda/lib64/
chmod a+r /usr/local/cuda/include/cudnn.h
chmod a+r /usr/local/cuda/lib64/libcudnn*

#注意:cudnn8.0以上会将版本信息更新到cudnn_version.h文件中,也需要将这个文件复制,否则验证的时候会没有反应
cp include/cudnn_version.h /usr/local/cuda/include/
#验证:
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
#define CUDNN_MAJOR 8
#define CUDNN_MINOR 9
#define CUDNN_PATCHLEVEL 7
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

/* cannot use constexpr here since this is a C-only file */
[root@localhost cudnn-linux-x86_64-8.9.7.29_cuda12-archive]# 

如果出现以上现象就说明安装成功。

© Заявление об авторском праве
THE END
Поддерживай, если хочешь.
Похвалить14Высокая оценка Поделиться
Соответствующие рекомендации
Замечания Украсть диван
头像
Добро пожаловать, чтобы оставить ценные идеи!
提交
头像

Прозвище

取消
ПрозвищеЛицоКодФотографии

    Нет комментариев