码迷,mamicode.com
首页 > 其他好文 > 详细

安装pytorch GPU版不能使用问题

时间:2020-07-18 13:33:18      阅读:406      评论:0      收藏:0      [点我收藏+]

标签:cond   anaconda   print   install   dex   image   使用   device   its   

虽然我已经安装了GPU版的pytorch,但是只能使用CPU的。

安装的pytorch版本pytorch1.5.1-py36-cu102-cudn70

执行:

>>> import torch
>>> import torchvision
>>> torch.cuda.is_available()
False

因为anconda也确实安装了cudatoolkit 10.2.89,不能用感觉莫名其妙,就在程序中的:

DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu") # 让torch判断是否使用GPU

强制改成:

DEVICE = torch.device(cuda)

结果运行报错:

AssertionError: 
The NVIDIA driver on your system is too old (found version 10010).
Please update your GPU driver by downloading and installing a new
version from the URL: http://www.nvidia.com/Download/index.aspx
Alternatively, go to: https://pytorch.org to install
a PyTorch version that has been compiled with your version
of the CUDA driver.

原来是驱动版本太低,找到原因自然就好解决了。

然后重新安装cuda10.2就可以正常使用了。

说明,之前我安装cuda10.2的时候是自定义安装的,只安装了cuda,其他组件都没有安装。

安装后

(base) C:\Users\Administrator>conda activate pytorch

(pytorch) C:\Users\Administrator>python
Python 3.6.10 |Anaconda, Inc.| (default, May  7 2020, 19:46:08) [MSC v.1916 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> print(torch.cuda.is_available())
True

另外,下面这里也可以查看cuda驱动版本。

技术图片

 

安装pytorch GPU版不能使用问题

标签:cond   anaconda   print   install   dex   image   使用   device   its   

原文地址:https://www.cnblogs.com/juluwangshier/p/13334726.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!