Visual Studio
安装 Python
Update nvidia driver
打开 cmd - 运行 nvidia-smi (若运行不成功需添加系统变量) - 查看 Driver Version - 确定支持的CUDA版本
CUDA
cuDNN (需要注册nvidia)
解压,将bin, include, lib三个文件夹复制到 C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0
在系统变量的path中添加
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.0\extras\CUPTI\libx64
Anaconda安装
点击 Anaconda Prompt, 输入
conda create -n pytorch_gpu pip python=3.7
conda activate pytorch_gpu
PyTorch
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch
验证安装是否成功
运行 python
import torch
x = torch.rand(5,3)
print(x)
torch.cuda.is_available() (如果返回false,很可能网络安装pytorch的版本不对,可以下载相应版本pytorch,用pip安装)
安装Spyder
打开 Anaconda Navigator - Home - Application on pytorch_gpu - Spyder install
run Spyder(pytorch_gpu)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
There are multiple different Pytorch versions for 1.1.0 if you want to use a GPU or want to be CPU only.
For Cuda10.0: https://download.pytorch.org/whl/cu100/torch_stable.html
For Cuda9.0: https://download.pytorch.org/whl/cu90/torch_stable.html
For CPU only: https://download.pytorch.org/whl/cpu/torch_stable.html
Then use ctrl+f to search for:
torch-1.1.0-cp{CPython version}-cp{CPython version}m-win_AMD64.whl
Replace {Cpython version} with your python version, for example 37 for 3.7.
Then download that file. Install using:
pip install <path to wheel file>