OutOfMemoryError: CUDA out of memory. CUDA内存剩余0
解决方法:
OutOfMemoryError: CUDA out of memory. Tried to allocate 2.25 GiB (GPU 0; 4.00 GiB total capacity; 6.68 GiB already allocated; 0 bytes free; 6.73 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try setting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
根据网上设置过PYTORCH_CUDA_ALLOC_CONF max_split_size_mb参数没效果,0 bytes free依旧报剩余0内存
后来降低pytorch版本为Torch 1.13.1(CUDA11.7)+xFormers0.016就行了,可以在A启动器.exe的管理高级选项-》环境维护安装
大概原因就是pytorch版本高占用内存大,要6g起步,我的显卡是4G的所以只能用低版本的。