RuntimeError: CUDA error: invalid device ordinal

 

 

 

 

device = torch.device('cuda:1')

报错内容:

Traceback (most recent call last):
  File "C:/Users/WQBin/Desktop/Deep-Learning-with-PyTorch-Tutorials-master/lesson28-激活函数与GPU加速/main.py", line 51, in <module>
    net = MLP().to(device)
  File "D:\app\Anaconda3\envs\deeplearning\lib\site-packages\torch\nn\modules\module.py", line 425, in to
    return self._apply(convert)
  File "D:\app\Anaconda3\envs\deeplearning\lib\site-packages\torch\nn\modules\module.py", line 201, in _apply
    module._apply(fn)
  File "D:\app\Anaconda3\envs\deeplearning\lib\site-packages\torch\nn\modules\module.py", line 201, in _apply
    module._apply(fn)
  File "D:\app\Anaconda3\envs\deeplearning\lib\site-packages\torch\nn\modules\module.py", line 223, in _apply
    param_applied = fn(param)
  File "D:\app\Anaconda3\envs\deeplearning\lib\site-packages\torch\nn\modules\module.py", line 423, in convert
    return t.to(device, dtype if t.is_floating_point() else None, non_blocking)
RuntimeError: CUDA error: invalid device ordinal

Process finished with exit code 1
RuntimeError: CUDA error: invalid device ordinal

 

 

 虽然这里没显示,但是切换CUDA,可以看到确实在使用英伟达显卡。

posted @ 2020-04-12 18:18  wqbin  阅读(12206)  评论(1编辑  收藏  举报