admin管理员组文章数量:1666734
1.建立Pytorch Anaconda虚拟环境
conda create --name pytorch python=3.6 anaconda
在anaconda装不同环境的好处就是可以把不同的框架独立,互不影响。如果只装pytorch,那么就只有pytorch
2.启动Pytorch Anaconda虚拟环境
activate pytorch
3.安装Pytorch
pytorch官网版本及安装命令选择
因为我安装的CPU版本,所以选CPU
4.安装Pytorch(镜像加速)
配置镜像源
Step 1
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
Step 2
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
Step 3
conda config --set show_channel_urls yes
Step 4
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
Step 5
conda install pytorch torchvision cpuonly
问题1:Invalid spec: =2.7
解决办法:链接
可参考:https://blog.csdn/asdfg6541/article/details/104508468/
注意,因为在镜像安装,所以没有官方命令的**-c pytorch**
5.测试
在命令行输入:python,激活python环境
python
然后输入:
from __future__ import print_function
import torch
x = torch.rand(5, 3)
print(x)
结果:
6.安装gpu版本的torch
推荐系统玩家 之 Pytorch,CUDA安装实现GPU计算(Anaconda和Pycharm教程)
注意:conda安装10.2的时候,torch还是安装11.1的
NOTE: 'conda-forge' channel is required for cudatoolkit 11.1
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
win10配置Anaconda清华源镜像,conda下载加速
安装教程-torch-gpu
配置清华源改错
配置清华源的8条命令
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --set show_channel_urls yes
配置完之后用conda下载torch gpu版本速度起飞
常用测试命令
nvcc -V #查看CUDA版本
nvidia-smi #查看GPU使用情况
# 查看是否安装成功,如果没有其它警告,说明安装成功!
import torch
print(torch.__version__) #注意是双下划线
print(torch.version.cuda)
print(torch.cuda.is_available())
print(torch.cuda.get_device_name())
显示:
1.9.1
11.1
True
NVIDIA GeForce RTX 3090
版权声明:本文标题:anaconda中CPU版本的pytorch安装教程 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1730077041a1221915.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论