问题
用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
解决