CUDA out of memory,但是显存明明有大量剩余
报错信息
RuntimeError: CUDA out of memory. Tried to allocate 780.38 MiB(GPU 0;8.00 GiB total capacity; 149.91 MiB allocted;6.13 GiB free; 16.59 MiB cached)
可能是计算缓存CUDA_CACHE_MAXSIZE设置太小
pytorch默认计算缓存256MB,最大可设置为4GB,我设置成了2GB,就能运行了。
Windows设置:参考
linux设置:export CUDA_CACHE_MAXSIZE = 2147483648