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,可以看到確實在使用英偉達顯卡。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM