問題
用Pytorch跑模型時,會出現RuntimeError: CUDA out of memory
解決方法
1.真的沒有內存了
RuntimeError: CUDA out of memory. Tried to allocate 64.00 MiB
(GPU 0; 4.00 GiB total capacity; 2.92 GiB already allocated; 58.76 MiB free;
2.95 GiB reserved in total by PyTorch)
可以改小batch_size
2.內存足夠,不分配
RuntimeError: CUDA out of memory.
Tried to allocate 784.00 MiB
(GPU 0; 4.00 GiB total capacity; 456.81 MiB already allocated; 2.47 GiB free;
548.00 MiB reserved in total by PyTorch)
Win10下多線程的問題,num_threads/workers=0
解決