导读 这篇文章主要介绍了如何解决.cuda()加载用时很长的问题,具有很好的参考价值,希望对大家有所帮助。如有错误或未考虑完全的地方,望不吝赐教
方法一:
pip install --upgrade --force-reinstall http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl

后面这个可以自己到官网上找自己对应的python和cuda版本的安装包,官网为链接:

方法二:
conda install pytorch torchvision cuda80 -c soumith

这里可以根据自己cuda版本确定。查看cuda版本,在python命令行里面输入:

import torch
torch.version.cuda

即可。

补充:关于win10环境下在使用torch调用cuda()失败的原因

看了无数篇博客都是牛头不对马嘴,忙活了半天才搞清楚

如果大家在用torch的过程中看见这样的错误。。。。淡定,不是你的问题,也不是代码问题。。。是破win10的原因

只需要在代码前面加上

torch.cuda.current_device()
torch.cuda._initialized = True

就可以正常训练了。。。心累啊

原文来自:https://www.jb51.net/article/213123.htm

本文地址:https://www.linuxprobe.com/time-consuming-cuda.html编辑:xiangping wu,审核员:逄增宝

Linux命令大全:https://www.linuxcool.com/

Linux系统大全:https://www.linuxdown.com/

红帽认证RHCE考试心得:https://www.rhce.net/