CUDA:Out Of Memory问题

有不懂,请评论;

I've edited my comment here https://discuss.pytorch.org/t/pytorch-cuda-alloc-conf/165376/7I understand the meaning of this command (PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:516), but where do you actually write it? In jupyter notebook? In command prompt?https://discuss.pytorch.org/t/pytorch-cuda-alloc-conf/165376/7

and you guys can also see a more clear version of reply there.

学习建议:用英文检索,bing\google

方法:将报错内容理解,然后键入英文搜索

搜索思路: 

  1. 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 If you encounter CUDA out of memory, try to set --tile with a smaller number.

看了一个国内链接通过设置PYTORCH_CUDA_ALLOC_CONF中的max_split_size_mb解决Pytorch的显存碎片化导致的CUDA:Out Of Memory问题_梦音Yune的博客-CSDN博客,然后试了试,看了评论,操作后不行;再试试国际上的链接,完成。

环境:ubuntu(按量付费 云服务器

3090RTX 24GB显存

问题来源:

运行python inference_realesrgan.py -n RealESRGAN_x4plus -i 2-8 -o output_2_8

超分图像,出现OOM问题,

我成功的操作:

step 1 设置PYTORCH_CUDA_ALLOC_CONF 

也可以export(一次性使用):

直接terminal敲export PYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:512

设置ubuntu环境变量(永久使用):改天截图,就是设置 ~./bashrc,详细操作看如下链接。

How to Set Environment Variables in Linux {Step-by-Step Guide}

Reference:

PYTORCH_CUDA_ALLOC_CONF 

Cuda Reserve Memory - Memory Format - PyTorch Forums

https://pytorch.org/docs/stable/notes/cuda.html#memory-management

step 2 键入命令,设置--tile,修改数字

python inference_realesrgan.py -n RealESRGAN_x4plus -i 2-8 -o output_2_8 --tile 50

CUDA out of memory · Issue #101 · xinntao/Real-ESRGAN · GitHub

decrease the --tile

such as --tile 800 or smaller than 800

结果就能运行了,原理的话,自行看链接,慢慢看,一定能搞懂的。

rendering - Cycles / CUDA Error: Out of Memory - Blender Stack Exchange

CUDA:Out Of Memory问题_第1张图片

你可能感兴趣的:(python,开发语言)