【问题标题】:Pytorch .to('cuda') or .cuda() doesn't work and just get stuckPytorch .to('cuda') 或 .cuda() 不起作用,只是卡住了
【发布时间】:2020-02-09 04:07:36
【问题描述】:

我正在尝试做 pytorch 教程。当我尝试将他们的设备设置为 cuda 时,它不起作用并且我的代码运行卡住了。

具体信息,我使用的是conda环境 蟒蛇3.7.3 火炬 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...

谁能帮我解决这个问题?

【问题讨论】:

  • 即使在pytorch--->>1.4.0-py3.6_cuda10.1.243_cudnn7.6.3_0

标签: python pytorch


【解决方案1】:

GeForce 30系列需要cuda 11 =<,所以尽量使用cuda 11 =

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

【讨论】:

    【解决方案2】:

    这发生在 Pytorch 1.3.0 版本中(该版本是在本周发布的)。我也面临这个错误。基本上,当我打电话给.to(device) 时,它只是挂起,什么也不做。

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

    conda install pytorch=1.2.0 torchvision cudatoolkit=10.2 -c pytorch
    

    我本来只想发表评论,但我没有足够的声誉来评论。

    【讨论】:

    • 感谢 Relh!我发现 pytorch 1.2.0 没有 10.2 的 cudatoolkit,但是我安装了 cuda 10.0 和 pytorch 1.2.0 并且它运行良好!衷心感谢您的帮助
    猜你喜欢
    • 2020-10-03
    • 2020-11-23
    • 2018-11-29
    • 2019-04-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-10-06
    • 2020-07-09
    相关资源
    最近更新 更多