Pytorch安装 Win10 + Python 3.6 + Anaconda + CUDA 10.0

1. 确认CUDA-enabled GPU

Win + R: dxdiag 查看显卡类型
NVIDIA官网查看是否支持CUDA
CUDA-Enabled GeForce and TITAN Products

2. 安装NVIDIA Driver和CUDA Toolkit

NVIDIA Driver Downloads
https://www.nvidia.com/Download/index.aspx?lang=en-us

CUDA Toolkit 10.0 Archive
https://developer.nvidia.com/cuda-10.0-download-archive?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal

官方安装教程(包括网络安装版本/network和本地安装版本/local)
https://docs.nvidia.com/cuda/cuda-quick-start-guide/index.html#windows
CUDA Toolkit 10.0 Archive Page

注意 安装CUDA前需要装好可用版本的Visual Studio,我本来装的是Visual Studio 2019,但是在安装过程中报错检测不到Visual Studio,在装完Visual Studio 2017以后问题解决
Visual Studio 2017 下载
Visual Studio Community 2017 Version

3. 安装Pytorch

Pytorch官网 https://pytorch.org/get-started/locally/
(不知道为什么中英文官网好像有一些微妙的差别)

可以直接选择配置用conda安装
conda install command

conda install pytorch torchvision cudatoolkit=10.0 -c pytorch

但是我用conda一直报错找不到channel
PackagesNotFoundError: The following packages are not available from current channels

可以尝试https://www.cnblogs.com/hellojiaojiao/p/10790273.html / https://blog.csdn.net/miao0967020148/article/details/85230430 提供的解决方法

但我改用了看起来更简单的pip install

CUDA 10.0

pip3 install https://download.pytorch.org/whl/cu100/torch-1.0.1-cp36-cp36m-win_amd64.whl 
pip3 install torchvision

但这样安装以后我import pytorch还是没有成功 发现是因为pip3会把包装到自带的3.x版本的默认环境 (参考https://blog.csdn.net/qq_22526061/article/details/81040778) 在我的环境(py=3.6)中 pip就是pip3 所以直接用pip就可以

pip install https://download.pytorch.org/whl/cu100/torch-1.0.1-cp36-cp36m-win_amd64.whl 
pip install torchvision 

4. 验证Pytorch

参考官网

from __future__ import print_function
import torch
x = torch.rand(5,3)
print(x)

结果会输出一个tensor
参考结果
进一步验证CUDA

import torch
torch.cuda.is_available()

运行时报错
RuntimeError: module compiled against API version 0xb but this version of numpy is 0xa

原来是因为numpy版本问题(参考https://blog.csdn.net/chris_zhangrx/article/details/78407459)更新numpy

pip install --upgrade numpy

结束
运行结果

  • 29
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值