pytorch GPU版本安装(亲测)

本文详细介绍了如何根据不同CUDA版本和Python版本创建虚拟环境,推荐了官方PyTorch库安装路径,并提供了针对不同环境的pip安装指令。重点讨论了3.7、10.2、11.3等多个组合的安装步骤和注意事项,包括数据class问题和版本兼容矩阵。
部署运行你感兴趣的模型镜像

安装路径:https://download.pytorch.org/whl/torch_stable.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/cu117

 pip 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

安装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()

您可能感兴趣的与本文相关的镜像

Python3.11

Python3.11

Conda
Python

Python 是一种高级、解释型、通用的编程语言,以其简洁易读的语法而闻名,适用于广泛的应用,包括Web开发、数据分析、人工智能和自动化脚本

为了快速安装GPU版本PyTorch,你可以按照以下步骤进行操作。首先,你可以访问一个特殊的网站,该网站提供了PyTorch的各个版本,包括GPU版本和CPU版本。你可以手动选择适合你系统配置的版本进行下载。例如,如果你的系统是Windows,Python版本是3.8,CUDA版本是11.1,你可以下载对应的文件,比如cu111/torch-1.8.0%2Bcu111-cp38-cp38-win_amd64.whl和cu111/torchvision-0.9.0%2Bcu111-cp38-cp38-win_amd64.whl。如果你的下载速度比较慢,你还可以在一个公众号内获取这两个文件。\[1\] 在下载之前,请确保你选择了正确的版本。在网站上,你可以参考torchtorchvision的对应图表,以确保你下载了正确的版本。通常,GPU版本的文件以"cu"开头。\[2\] 下载完成后,你可以打开Anaconda Prompt,并导入torchtorchvision库。然后,你可以使用以下命令来检查GPU是否可用并获取GPU的名称: ```python import torch torch.cuda.is_available() # 检查GPU是否可用 torch.cuda.get_device_name(0) # 获取GPU的名称 ``` 如果返回结果为True,并且显示了你的GPU的名称,那么说明你已成功安装GPU版本PyTorch。\[3\] #### 引用[.reference_title] - *1* [超简单的pytorchGPU版)安装教程(有效)](https://blog.youkuaiyun.com/qq1198768105/article/details/114783633)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* *3* [GPU版本安装Pytorch教程最新方法](https://blog.youkuaiyun.com/qq_45956730/article/details/126600028)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会发paper的学渣

您的鼓励和将是我前进的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值