Pytorch .to('cuda')或.cuda()不起作用,只会卡住

时间:2019-10-11 15:34:44

标签: python pytorch

我正在尝试做pytorch教程。当我尝试将他们的设备设置为cuda时,它无法正常工作,并且我的代码无法运行。

有关具体信息,我使用的是conda环境 python 3.7.3 pytorch 1.3.0 CUDA 10.2(NVIDIA RTX2080TI)

>>> import torch
>>> torch.cuda.is_available()
True
>>> torch.cuda.device_count()
1
>>> torch.cuda.current_device()
0
>>> device = torch.device('cuda:0')
>>> device
device(type='cuda', index=0)
>>> aa = torch.randn(5)
>>> aa = tensor([-2.2084, -0.2700, 0.0921, -1.7678, 0.7642])
>>> aa.to(device)


nothing happens...

有人可以帮我解决这个问题吗?

2 个答案:

答案 0 :(得分:2)

Pytorch 1.3.0版本(本周发布)已经发生了这种情况。我也面临这个错误。基本上,当我打电话给$this->denyAccessUnlessGranted('edit', $post);时,它只是挂起而什么也不做。

如果您想暂时解决此问题,可以降级到PyTorch 1.2.0。为此,我运行了:

.to(device)

我本来应该发表评论,但是我没有足够的声誉来做到这一点。

答案 1 :(得分:0)

GeForce 30 系列需要 cuda 11 =< ,所以尝试使用 cuda 11 =< using,

conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge