【Tesla T4为例】GPU安装最新版本NVIDIA Driver、CUDA、cuDNN、Anaconda、Pytorch

embedded/2024/9/24 13:19:16/

NVIDIA Driver

进入英伟达官网下载页面
在这里插入图片描述
按照以上方式选择即可得到>535.113.01版本的驱动,可以实现多卡推理,小于这个版本会导致多卡训练以及推理报错
虽然最新版本为550.54.15,但是535版本更加稳定,并且pytorch目前只支持到12.1,而在CUDA Toolkit选择栏中没有这个版本,所以选择12.2最稳妥
在这里插入图片描述
下载后上传至服务器,在安装驱动前先安装一些依赖

sudo yum install epel-release
sudo yum update
sudo yum install pkgconfig libglvnd-devel

赋予权限后运行

chmod +x NVIDIA-Linux-x86_64-535.161.08.run
sh ./NVIDIA-Linux-x86_64-535.161.08.run -s  --no-x-check
nvidia-smi

在这里插入图片描述

CUDA

进入CUDA官网下载页面
在这里插入图片描述
在服务器中输入uname -a查看服务器系统
然后选择对应的版本
在这里插入图片描述
在Base Installer的Installation Instructions这里,对wget之后的内容选中-右键-转到这个网址,或者复制后在新的标签页打开即可下载,下载后上传至服务器,执行(4个G大小)

sudo sh cuda_12.2.0_535.54.03_linux.run

运行后在出现的页面中以下操作

1.输入accept
2. - [×] Driver 取消×

按回车进行取消,然后按↓到Install进行回车进行安装
在这里插入图片描述
安装完成后显示

===========
= Summary =
===========Driver:   Not Selected
Toolkit:  Installed in /usr/local/cuda-12.2/Please make sure that-   PATH includes /usr/local/cuda-12.2/bin-   LD_LIBRARY_PATH includes /usr/local/cuda-12.2/lib64, or, add /usr/local/cuda-12.2/lib64 to /etc/ld.so.conf and run ldconfig as rootTo uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-12.2/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 535.00 is required for CUDA 12.2 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 --driverLogfile is /var/log/cuda-installer.log

根据上面的提示信息设置路径

export PATH=/usr/local/cuda-12.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-12.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

输入命令nvcc -V进行检验

[root@Nvidia-Tesla-T4 Downloads]# nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Jun_13_19:16:58_PDT_2023
Cuda compilation tools, release 12.2, V12.2.91
Build cuda_12.2.r12.2/compiler.32965470_0

CuDNN

在这里插入图片描述
最新的9.0.0版本支持以前的所有版本以及未来的版本,安装即可,cuDNN网址
在这里插入图片描述
https://developer.download.nvidia.com/compute/cudnn/9.0.0/local_installers/cudnn-local-repo-rhel7-9.0.0-1.0-1.x86_64.rpm
和之前一样,点开链接下载

sudo rpm -i cudnn-local-repo-rhel7-9.0.0-1.0-1.x86_64.rpm
sudo yum clean all
sudo yum -y install cudnn

Anaconda

进入官网下载

sh Anaconda3-2024.02-1-Linux-x86_64.sh

一直按回车最后输入yes,再按一次回车,最后配置是否在进入服务器时就启动base_conda,我选择no
设置一下环境变量

export PATH="/root/anaconda3/bin:$PATH"

然后配置conda源

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
conda config --show channels

创建自己的虚拟环境

conda create -n sakura python=3.10

安装完成后添加pip源

pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

Pytorch

根据pytorch官方的配置选择
在这里插入图片描述

pip3 install torch torchvision torchaudio

验证一下

python
import torch
print("torch.__version__        ",torch.__version__)
# torch.__version__         2.2.2+cu121
print("torch.version.cuda       ",torch.version.cuda)
# torch.version.cuda        12.1
print("torch.cuda.is_available  ",torch.cuda.is_available())
# torch.cuda.is_available   True
print('torch.cuda.get_device_name       '+ str(torch.cuda.get_device_name()))
# torch.cuda.get_device_name       Tesla T4
print('torch.cuda.device_count  '+ str(torch.cuda.device_count()))
# torch.cuda.device_count  4

http://www.ppmy.cn/embedded/2658.html

相关文章

【鸿蒙开发】生命周期

1. UIAbility组件生命周期 UIAbility的生命周期包括Create、Foreground、Background、Destroy四个状态。 UIAbility生命周期状态 1.1 Create状态 Create状态为在应用加载过程中&#xff0c;UIAbility实例创建完成时触发&#xff0c;系统会调用onCreate()回调。可以在该回调中…

Mybatis generate xml 没有被覆盖

添加插件即可 <plugin type"org.mybatis.generator.plugins.UnmergeableXmlMappersPlugin"/>

git创建分支并推送到远端,并关联

1&#xff1a;创建本地分支&#xff08;两种方式&#xff09; git checkout -b new_branch_name // 或者&#xff0c;上面一步等于下面这两步 git branch new_branch_name git checkout new_branch_name2&#xff1a;推送到远端 git push origin ${本地分支名称}:${远端分支名…

蓝桥杯刷题-游戏

1388. 游戏 - AcWing题库 #include <bits/stdc.h>using namespace std; const int N 110; int n , s[N]; int f[N][N][2]; int a[N];int sum(int l, int r) {return s[r] - s[l - 1]; }int main() {cin >> n;for(int i 1;i < n;i ){cin >> a[i];s[i] …

热词解析| 制造企业如何跟上新质生产力建设步伐【触想智能】

回顾3月份的网络热词&#xff0c;「新质生产力」在各大平台霸榜刷屏&#xff0c;并且受到两会政府工作报告的频繁聚焦。究竟何为新质生产力?以及&#xff0c;传统制造企业如何加速融入这场火热的现代化产业革新浪潮之中? 图源| 纪录片《加快形成新质生产力》 1、什么是新质生…

宿舍预付费管控云平台

1.宿舍预付费管控云平台概述 宿舍预付费管控云平台是一种创新的智能管理系统&#xff0c;专为学校、公寓等住宿环境设计&#xff0c;旨在提升管理效率&#xff0c;优化用户体验&#xff0c;并实现资源的高效利用。通过云端技术&#xff0c;该平台可以实现远程充值、实时消费记…

AI时代,我要如何学习,才能跟上步伐

在21世纪这个被数据驱动的时代&#xff0c;人工智能&#xff08;AI&#xff09;已经渗透到我们生活的方方面面。无论是智能手机中的语音助手、在线客服的聊天机器人&#xff0c;还是自动驾驶汽车&#xff0c;AI的应用都在告诉我们一个信息&#xff1a;未来已来。因此&#xff0…

Kolla-ansible部署OpenStack集群

0. OpenStack 部署 系统要求 单机部署最低配置&#xff1a; 2张网卡8G内存40G硬盘空间 主机系统&#xff1a; CentOS Stream 9Debian Bullseye (11)openEuler 22.03 LTSRocky Linux 9- Ubuntu Jammy (22.04) 官方不再支持CentOS 7作为主机系统&#xff0c;我这里使用的是R…