环境配置
anaconda安装
CPU版本pytorch
1)创建虚拟环境
conda create -n d2l-zh python=3.8
2)安装
pip install jupyter d2l torch torchvision
GPU版本pytorch
cuda与torch对应关系:https://pytorch.org/get-started/previous-versions/
cuda 10.0
conda create -n d2l-zh-gpu python=3.7
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
pip install jupyter d2l
手动下载pytorch
测试安装
进入Python环境
>>> import torch
>>> torch.__version__
'1.2.0'
>>> torch.cuda.is_available()
True