如何理解 CUDA 内存不足消息?

如何理解 CUDA 内存不足消息?

以下是 的输出nvidia-smi

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 410.104      Driver Version: 410.104      CUDA Version: 10.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 108...  On   | 00000000:01:00.0 Off |                  N/A |
| 57%   68C    P8    19W / 280W |   7278MiB / 11176MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  GeForce GTX 108...  On   | 00000000:02:00.0 Off |                  N/A |
| 67%   73C    P2   259W / 280W |  10873MiB / 11178MiB |     96%      Default |
+-------------------------------+----------------------+----------------------+

现在我尝试运行代码并显示此消息。

RuntimeError: CUDA out of memory. Tried to allocate 8.62 MiB (GPU 0; 10.91 GiB total capacity; 2.80 GiB already allocated; 16.88 MiB free; 0 bytes cached)

我知道我没有足够的内存,但是在哪里可以查看我的代码需要多少内存?

我尝试运行另一个需要 10000 倍内存的代码,但它给出了这个错误

RuntimeError: CUDA out of memory. Tried to allocate 858.38 MiB (GPU 0; 10.91 GiB total capacity; 2.51 GiB already allocated; 756.88 MiB free; 0 bytes cached)

我怎样才能让它告诉我类似的事情CUDA out of memory. Need 12GB Memory total.

相关内容