文章目录
- 1. 配置cuda环境
- 2. 配置conda环境
- 3. 配置pytorch gpu环境
1. 配置cuda环境
- 在命令行输入以下命令可以查看当前显卡驱动版本和最高支持的cuda版本
nvidia-smi
- 根据cuda版本去官网下载并安装cuda
下载链接:https://developer.nvidia.com/cuda-toolkit-archive - 根据cuda、cudnn版本对照表下载安装合适的cudnn
版本对照:https://docs.nvidia.com/deeplearning/cudnn/backend/v9.12.0/reference/support-matrix.html
下载链接:https://developer.nvidia.com/cudnn-archive
2. 配置conda环境
- 去官网下载anaconda
下载链接:https://repo.anaconda.com/archive - conda换源
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/ conda config --set show_channel_urls yes
- pip换源
pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/
- 安装uv
pip install uv
- 安装conda环境(python维护周期查询)
conda create -n [环境名] python=3.x -y
3. 配置pytorch gpu环境
- 先去官网查询安装torch等库的命令
官网链接:https://pytorch.org/get-started/previous-versions/ - 使用在命令前加上uv再执行命令提高下载速度,比如
uv pip install torch==2.7.1 torchvision==0.22.1 torchaudio==2.7.1 --index-url https://download.pytorch.org/whl/cu128
- 安装后,运行python,执行以下代码验证是否配置成功
import torch torch.cuda.is_available() torch.cuda.get_device_name(0)