LINUX Rocky9.1 安装 最新版 NVIDIA-525.85 cuda-525.85
发布时间:2026/10/31 14:24:55 锦皓数字建站

介绍版本版本CUDA 版本GPU 型号Rocky 9.1NVIDIA-x86_64-525.85.12cuda_12.0.1_525.85.12P40查看显卡驱动版本号和CUDA版本对应关系点击该链接https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html前期准备yum -y install net-tools yum -y install vim wget yum -y install lrzsz yum install epel-release yum install dnf yum install gcc kernel-devel kernel-headers -y yum install -y elfutils-libelf-devel yum -y install dkms 安装 dkms 时会自动安装最新版的 kernel的一些组件在安装完成时必须卸载掉 如果不安装 dkms 会报以下错 Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 515.105.01 Extraction failed. Signal caught, cleaning up rpm -qa | grep kernel kernel-devel-5.14.0-162.6.1.el9_1.x86_64.rpm kernel-headers-5.14.0-284.11.1.el9_2.x86_64.rpm uname -a Linux localhost.localdomain 5.14.0-162.6.1.el9_1.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Nov 18 02:06:38 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux 查看 kernel-devel 内核版本 是否一样 如果不一样 需要卸载之后手动下载 手动下载地址 wget https://yum.oracle.com/repo/OracleLinux/OL9/appstream/x86_64/getPackage/kernel-devel-5.14.0-162.6.1.el9_1.x86_64.rpm yum -y install kernel-devel-5.14.0-162.6.1.el9_1.x86_64.rpm wget https://repo.almalinux.org/almalinux/9/AppStream/x86_64/os/Packages/kernel-headers-5.14.0-284.11.1.el9_2.x86_64.rpm 如果上方地址下载失败则到下方百度网盘下载这个安装包 链接https://pan.baidu.com/s/1UgGM3QZmbImfgJisgXd5AA?pwdz01a 提取码z01a yum -y install kernel-headers-5.14.0-284.11.1.el9_2.x86_64.rpm 注意##################### **这个版本必须和系统版本一致** 命令行输出lspci |grep -i nvidia 查看nvidia显卡信息显示如下 0b:00.0 NIVIDIA compatible controller: Matrox Electronics Systems Ltd. G200eR2 如果没有lspci命令执行yum -y install pci*,就能在线安装lspci。 然后在命令行执行lspci -v -s 0b:00.0 显示显卡大致信息说明系统已经识别显卡。修改各个配置文件配置文件如果不存在直接新建修改一vim /usr/lib/modprobe.d/dist-blacklist.conf blacklist nouveau options nouveau modeset0修改二vim /etc/modprobe.d/dccp-blacklist.conf blacklist dccp blacklist dccp_diag blacklist dccp_ipv4 blacklist dccp_ipv6 blacklist nouveau blacklist nvidiafb options nouveau modeset0修改三vim /etc/modprobe.d/blacklist-nouveau.conf blacklist nouveau options nouveau modeset0 blacklist nvidiafb修改四vim /etc/modprobe.d/blacklist.conf blacklist nouveau options nouveau modeset0 blacklist nvidiafb blacklist vga16fb blacklist nouveau blacklist rivafb blacklist rivatv备份initramfsmv /boot/initramfs-$(uname -r).img /boot/initramfs-$(uname -r).img.bak重新建立initramfsdracut -v /boot/initramfs-$(uname -r).img $(uname -r)启动服务systemctl set-default multi-user.target刷新文本重启服务器init 3 reboot ## 重启后,检查nouveau driver确保没有被加载 为空就对了 lsmod | grep nouveau安装 NVIDIA浏览器访问https://www.nvidia.cn/点击驱动程序选择产品类型选择 Data Center/Tesla产品系列我的GPU是P系列选择P-Series产品家族我的GPU型号是P40选择P40操作系统Linux 64-bitCUDA toolkit : 12.0语言默认即可点击搜索查看是否有GPU型号信息下载将包上传到服务器上我放在/opt下了执行安装命令chmod 755 NVIDIA-Linux-x86_64-525.85.12.run 执行如下命令 ./NVIDIA-Linux-x86_64-525.85.12.run --kernel-source-path/usr/src/kernels/5.14.0-162.12.1.el9_1.0.2.x86_64/ --no-drm --no-opengl-files --kernel-source-path 参数指定内核源码位置 默认在 /usr/src/ 下 --no-drm 不安装drm模块 也可以使用 rpm -qa | grep kernel 查看内核版本 如果升级内核之后 进入系统不识别IP 使用 rpm -qa | grep kernel 把新装的内核版本卸载重启就可以了WARNING: The nvidia-drm module will not be installed. As a result, DRM-KMS will not function with this installation of the NVIDIA driver. 警告将不会安装nvidia-drm模块。因此DRM-KMS将无法在安装NVIDIA驱动程序时运行。 如图 点击 OK如图开始安装报错 如图ERROR: Unable to find the kernel source tree for the currently running kernel. Please make sure you have installed the kernel source files for your kernel and thatthey are properly configured; on Red Hat Linux systems, for example, be sure you have the ‘kernel-source’ or ‘kernel-devel’ RPM installed. If you know thecorrect kernel source files are installed, you may specify the kernel source path with the ‘–kernel-source-path’ command line option.处理说明安装的kernel-devel 版本与系统版本不一致。如图安装NVIDIA X驱动程序模块 点击OK如图 Install NVIDIA’s 32-bit compatibility libraries?是否安装NVIDIA的32位兼容库选择 NO 不安装如图尝试安装“vulkan加载器”、“vulkanicd加载器”或“libvulkan1”包。点击OK如图等待安装完成如图 这里选NO出现以下证明安装完成查看日志无报错[rootsuoyin02 opt]# tail -f /var/log/nvidia-installer.log executing: /usr/bin/chcon -t textrel_shlib_t /usr/lib64/libnvidia-opticalflow.so.525.85.12... executing: /usr/sbin/ldconfig... executing: /usr/sbin/depmod -a ... executing: /usr/bin/systemctl daemon-reload... - done. - Driver file installation is complete. - Running post-install sanity check: - done. - Post-install sanity check passed. - Installation of the NVIDIA Accelerated Graphics Driver for Linux-x86_64 (version: 525.85.12) is now complete.测试安装结果执行nvidia-smi如图有的GPU执行这个命令之后声音特别大一直持续视为正常。目前作者也是这样换了几个版本GPU还是如此不知道是什么原因有待解决安装CUDA其他版本下载地址https://developer.nvidia.com/cuda-toolkit-archive此版本下载地址https://developer.nvidia.com/cuda-downloads按照如图所示下载到服务器上 wget https://developer.download.nvidia.com/compute/cuda/12.0.1/local_installers/cuda_12.0.1_525.85.12_linux.run mv cuda_12.0.1_525.85.12_linux.run /opt chmod 755 cuda_12.0.1_525.85.12_linux.run 执行安装命令 ./cuda_12.0.1_525.85.12_linux.run如图输入accept 回车使用上下左右键 将鼠标放到 Install 上 回车等待报错 Installation failed. See log at /var/log/cuda-installer.log for details.查看日志日志里面让查看/var/log/nvidia-installer.log 这个日志文件继续看tail -f /var/log/nvidia-installer.log报错信息如下ERROR: Unable to find the kernel source tree for the currently running kernel. Please make sure you have installed the kernel source files for your kernel and that they are properly configured; on Red Hat Linux systems, for example, be sure you have the ‘kernel-source’ or ‘kernel-devel’ RPM installed. If you know the correct kernel source files are installed, you may specify the kernel source path with the ‘–kernel-source-path’ command line option.ERROR: Installation has failed. Please see the file ‘/var/log/nvidia-installer.log’ for details. You may find suggestions on fixing installation problems in the README available on the Linux driver download page at www.nvidia.com.报错信息说 无法找到当前运行内核的内核源树 如果已经安装请加–kernel-source-path 指定位置我安装NVIDIA 时明明指定了现在却显示未找到说明 CUDA 也需要指定位置。找到问题所在接下来重新执行安装命令./cuda_12.0.1_525.85.12_linux.run --kernel-source-path/usr/src/kernels/5.14.0-162.12.1.el9_1.0.2.x86_64/ 跳出界面之后操作如上面一样 先输入 accept 回车 在选择 Install 回车 等待 在打开一个窗口 tail -f /var/log/cuda-installer.log #可以看见安装进度出现如图这个说明安装成功。安装 Python 3.10.12安装编译依赖项 sudo dnf install -y gcc openssl-devel bzip2-devel libffi-devel zlib-devel readline-devel sqlite-devel 下载 Python 3.10.12 源代码 cd /opt/src curl -O https://www.python.org/ftp/python/3.10.12/Python-3.10.12.tgz 解压 Python 源代码 tar -xzvf Python-3.10.12.tgz 进入解压后的目录 cd Python-3.10.12 配置并编译 Python ./configure --prefix/usr/local/python --enable-optimizations make -j$(nproc) 这会根据系统的处理器数量进行并行编译。这个步骤可能需要一些时间。 安装 Python sudo make altinstall 使用 altinstall 而不是 install 是为了避免覆盖系统默认的 Python 版本。 验证 Python 安装 python3.10 --version 如果显示找不到命令 ln -s /usr/local/python/bin/python3.10 /usr/bin/ ln -s /usr/local/python/bin/pip3.10 /usr/bin/ 这将显示 Python 3.10.12 的版本信息。 升级 pip sudo python3.10 -m pip install --upgrade pip 这将确保您使用的是最新版本的 pip。安装 conda官网下载https://www.anaconda.com/products/individual清华镜像源 https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/?CMOD最好使用清华镜像源去下载没有如下这么繁琐的东西登录到邮箱上 查看下载地址wget https://repo.anaconda.com/archive/Anaconda3-2024.02-1-Linux-x86_64.sh chmod 755 Anaconda3-2024.02-1-Linux-x86_64.sh mv Anaconda3-2024.02-1-Linux-x86_64.sh /opt/src/ cd /opt/src/ sha256sum Anaconda3-2024.02-1-Linux-x86_64.sh bash Anaconda3-2024.02-1-Linux-x86_64.sh 一共需要输入3次 第一次直接回车 第二次输入yes 第三次直接回车 第四次输入yes 之后等待即可 执行有点慢 more ~/.bashrc ### 最后的内容如下 # conda initialize # !! Contents within this block are managed by conda init !! __conda_setup$(/data/anaconda3/bin/conda shell.bash hook 2 /dev/null) if [ $? -eq 0 ]; then eval $__conda_setup else if [ -f /data/anaconda3/etc/profile.d/conda.sh ]; then . /data/anaconda3/etc/profile.d/conda.sh else export PATH/data/anaconda3/bin:$PATH fi fi unset __conda_setup # conda initialize ### 刷新 source ~/.bashrc卸载## 卸载nvidia-smi /usr/bin/nvidia-uninstall卸载 cudacd /usr/local/cuda-12.8/bin ./cuda-uninstaller以上就是 NVIDIA 安装说明如有不懂可以留言。
锦
锦皓数字建站
深耕本土企业品牌数字化升级,专注原创端正雅致商务官网,从视觉设计到稳定运维全程保驾护航。