簡體   English   中英

如何解決“運行時錯誤:CUDA 錯誤:內存不足”?

[英]How Solve 'RuntimeError: CUDA error: out of memory'?

我導入了 torch 並使用cuda運行了簡單的代碼,但是RuntimeError: CUDA error: out of memory發生RuntimeError: CUDA error: out of memory錯誤。

我的代碼和錯誤是:

>>> import torch
>>> print(torch.rand(1, device="cuda"))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: CUDA error: out of memory

我使用torch遇到了同樣的問題,問題通過以下代碼解決:

import os
os.environ['CUDA_VISIBLE_DEVICES'] = '2, 3'

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM