环境安装-新
cuda版本 cuda_12.4.1_551.78_windows.exe
cudnn版本 cudnn-windows-x86_64-8.9.7.29_cuda12-archive.zip
驱动版本 566.36-desktop-win10-win11-64bit-international-dch-whql.exe
创建环境
conda create -n pytorch python=3.9
conda create -n pytorch python=3.10
下载pytorch等
conda install pytorch torchvision torchaudio pytorch-cuda=12.4 -c pytorch -c nvidia
conda install pytorch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 pytorch-cuda=12.1 -c pytorch -c nvidia
pip install torch==2.2.2 torchvision==0.17.2 torchaudio==2.2.2 --index-url https://download.pytorch.org/whl/cu121
验证
import torch
print("PyTorch 版本:", torch.__version__)
print("CUDA 版本:", torch.version.cuda)
print("CUDA 是否可用:", torch.cuda.is_available())
print("GPU 设备数量:", torch.cuda.device_count())
if torch.cuda.is_available():
print("GPU 设备名称:", torch.cuda.get_device_name(0))
结果
PyTorch 版本: 2.5.1
CUDA 版本: 12.4
CUDA 是否可用: True
GPU 设备数量: 1
GPU 设备名称: NVIDIA GeForce RTX 4070
进程已结束,退出代码为 0
移植conda环境,以yoloshow为例
# 2. 进入虚拟环境的 Scripts 目录(修复激活脚本的路径)
cd e:\anaconda\envs\yoloshow\Scripts
# 3. 执行环境激活脚本的修复(强制更新路径)
activate.bat

浙公网安备 33010602011771号