anaconda使用虚拟环境安装pytorch1.13+cuda11.7版(2022.11月测试有效)
·
要点:
1. 修改conda的源,用清华源,具体修改方法详见
anaconda | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror
主要是要创建一个.condarc文件,内容改为下面这样的国内源。
ssl_verify: true
channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- defaults
show_channel_urls: true
2. 创建conda虚拟环境
网上类似教程很多,搜索即可
具体命令可以为
conda create -n pytorch
3. 安装pytorch
具体就是运行
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
很多同志运行上面命令会出错,这里解释一下“-c”参数的含义,-c指的是从anaconda官方源的pytorch下载。这个是国外的地址,速度很慢。所以需要进行第四步的修改
4. 修改命令
错误方法:conda install pytorch torchvision torchaudio pytorch-cuda=11.7
本方法直接取消-c参数,但是提示各个包版本不兼容
正确方法:
conda install pytorch==1.13.0 torchvision==0.14.0 torchaudio==0.13.0 cudatoolkit=11.7
直接强制指定各个库版本即可。
其中pytorch、torchvision、torchaudio版本有关联关系。如果要安装其他版本也可以,只要关联关系对应就可以。
附:上面是GPU方式,如果是CPU,就比较简单了,输入命令
conda install pytorch torchvision torchaudio
可以自动匹配上版本。
http://t.csdn.cn/vxvsb两篇文章,在此一并感谢
欢迎来到FlagOS开发社区,这里是一个汇聚了AI开发者、数据科学家、机器学习爱好者以及业界专家的活力平台。我们致力于成为业内领先的Triton技术交流与应用分享的殿堂,为推动人工智能技术的普及与深化应用贡献力量。
更多推荐



所有评论(0)