pytorch GPU版本安装(亲测)
pytorch gpu版本安装
安装路径:https://download.pytorch.org/whl/torch_stable.html
cuda与cudnn版本对应关系:https://docs.nvidia.com/deeplearning/cudnn/backend/v9.18.0/reference/support-matrix.html
根据经验,第三方依赖工具,非python包使用conda安装,比如ffmpeg,cudnn,cudatoolkit,python等
python依赖包最好在python环境安装好后,使用pip安装
已经知道的版本:cuda102版本python3.7:
在~/.condarc修改conda 源(国内源已经全部失效,建议直接使用国外默认源即可,速度还可以)
#建议先python版本以及cuda版本,从https://download.pytorch.org/whl/torch/ 找到可以支持的torch版本,
也可以通过cuda 和cudnn关系矩阵查看:Support Matrix :: NVIDIA cuDNN Documentation
#如下命令可以查看cudnn8的各个子版本与cuda版本的关系:conda search cudnn=8 --info
请注意:3.11.x 以及更高版本对dataclass注入方式存在问题,典型的问题就是https://github.com/facebookresearch/fairseq/issues/5012
其中,关于在conda中安装cuda12.x参考:Cuda Toolkit | Anaconda.org
python3.7 + cudatoolkit 10.2
#虚拟环境创建
conda create -n torch_gpu3 python=3.7 cudnn=7.6.5.32 cudatoolkit=10.2.89
#依赖库安装
conda activate torch_gpu3
linux:pip install torch==1.12.0+cu102 torchvision==0.13.0+cu102 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu102
windows:pip install torch==1.10.1+cu102 torchvision==0.11.2+cu102 torchaudio==0.10.1 -f https://download.pytorch.org/whl/cu102/torch_stable.html
python3.7 + cudatoolkit 11.3 + torch1.12.1
#虚拟环境创建
conda create -n torch_gpu3 python=3.7 cudnn=8.9.2.26 cudatoolkit=11.3.1
#依赖库安装
conda activate torch_gpu3
linux:pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
python3.9.16 + cudatoolkit 10.2
#虚拟环境创建
conda create -n torch_gpu3 python=3.9.16 cudnn=7.6.5.32 cudatoolkit=10.2.89
#依赖库安装
conda activate torch_gpu3
linux:pip install torch==1.12.0+cu102 torchvision==0.13.0+cu102 torchaudio==0.12.0 --extra-index-url https://download.pytorch.org/whl/cu102
windows:pip install torch==1.10.1+cu102 torchvision==0.11.2+cu102 torchaudio==0.10.1 -f https://download.pytorch.org/whl/cu102/torch_stable.html
python3.9.16 + cudatoolkit 11.3
#虚拟环境创建
conda create -n torch_gpu3 python=3.9.16 cudnn=8.4.1.50 cudatoolkit=11.3.1
#依赖库安装
conda activate torch_gpu3
linux+win:pip install torch==1.12.1+cu113 --extra-index-url https://download.pytorch.org/whl/cu113
python3.10.9 + cudatoolkit11.7
#虚拟环境创建
conda create --prefix=D:/HT/torch_gpu3 python=3.10.9 cudnn=8.4.1.50 cudatoolkit=11.7.0 ffmpeg x264#依赖库安装
conda activate torch_gpu3
linux+win:
pip install torch==1.13.1+cu117 torchvision==0.14.1+cu117 --extra-index-url https://download.pytorch.org/whl/cu117pip install torch==2.0.0+cu117 torchvision==0.15.1+cu117 torchaudio==2.0.1 --index-url https://download.pytorch.org/whl/cu117
https://download.pytorch.org/whl/cu113
linux cuda118
conda create -n test python=3.10.9 cudnn=8.4.1.50 cudatoolkit=11.8.0 ffmpeg x264
python3.10.9 + cuda11.3
#虚拟环境创建
conda create -n wave2lippython3109 python=3.10.9 cudnn=8.4.1.50 cudatoolkit=11.3.1 ffmpeg x264#依赖库安装
conda activate wave2lippython3109
linux+win:
pip install torch==1.12.1+cu113 torchvision==0.13.1+cu113 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu113
python3.11 + cuda11.8
python3.11.4 + cudatoolkit=11.8.0 + torch2.0 + flash-attention
conda create -n mypython311 python=3.11.4 cudnn=8.9.2.26 cudatoolkit=11.8.0
pip install torch==2.0.0+cu118 torchvision==0.15.1+cu118 torchaudio==2.0.1 --index-url https://downl
python3.12 + cuda11.8
conda create -n dh_live python=3.12 cudnn=8.9.2.26 cudatoolkit=11.8.0 ffmpeg x264
python3.10 +cuda12.1+windows
conda create -n cosyvoice python=3.10.9 cudnn=9.3.0.75 nvidia/label/cuda-12.1.1::cuda-toolkit ffmpeg x264
pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121
python3.10 +cuda12.1+ linux
conda create -n cosyvoice python=3.10.9 cudnn=9.1.1.17 nvidia/label/cuda-12.1.1::cuda-toolkit ffmpeg x264
pip install torch==2.3.1 torchvision==0.18.1 torchaudio==2.3.1 --index-url https://download.pytorch.org/whl/cu121
(verl环境)python3.12+cuda12.8 +linux+20260122 + flash_atten=2.8.1+torch=2.8.0 (flash-atten对torch、cuda、python版本均有要求)
conda create --prefix=conda_envs/verl0_7 python==3.12
conda activate verl0_7
conda install cuda cudnn -c nvidia/label/cuda-12.8.0(修改verl/script/install_vllm_sglang_mcore.sh的对应的依赖版本,整体对齐):pip install https://github.com/Dao-AILab/flash-attention/releases/download/v2.8.1/flash_attn-2.8.1+cu12torch2.8cxx11abiFALSE-cp312-cp312-linux_x86_64.whl
cd verl/script && ./install_vllm_sglang_mcore.sh
TMPDIR=bigspacepath/pipcache pip install torch==2.8.0 torchvision==0.23.0 torchaudio==2.8.0 --index-url https://download.pytorch.org/whl/cu128 --timeout 1200 --cache-dir=bigspacepath/pipcache
cd verl pip install .
请注意,若安装过程中遇到‘due to an OSError: [Errno 16] Device or resource busy:’错误,可尝试不是依赖包缓存安装:pip install --no-cache-dir "numpy==1.26.4"
安装torch时,若不知道适合安装的版本,可以在虚拟环境弄好后,使用对应的url进行查看:
pip install torch== --extra-index-url https://download.pytorch.org/whl/cu113
#再查看下载命令https://pytorch.org/get-started/previous-versions/
#或离线下载:https://download.pytorch.org/whl/torch_stable.html
验证是否安装成功
进入python环境:
import torch
torch.cuda.is_available()
魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。
更多推荐


所有评论(0)