GithubHelp home page GithubHelp logo

CUDA out of memory error about gpen HOT 2 OPEN

yangxy avatar yangxy commented on July 19, 2024
CUDA out of memory error

from gpen.

Comments (2)

yangxy avatar yangxy commented on July 19, 2024

Hi
I am trying your code on a group photo with approximately 90 faces in it. I am getting the following CUDA error...

RuntimeError: CUDA out of memory. Tried to allocate 6.27 GiB (GPU 0; 8.00 GiB total capacity; 7.82 GiB already allocated; 0 bytes free; 7.83 GiB reserved in total by PyTorch)

Is there a flag that will allow me to run with my RTX 2070 SUPER card (8GB dedicated GPU memory, 8GB shared GPU memory)? I noticed for another question about CUDA, you referred the questioner to https://github.com/rosinality/stylegan2-pytorch.
I looked at that repo and saw for a CUDA memory issue, they recommended to use torch.no_grad. Will that help here, and if so, how should that be done?

Any help would be appreciated!
Thanks!

See torch.no_grad in face_model/face_gan.py.

Face detection could be memory-consuming too. Please check out if this issue is caused by face detection or GPEN?

from gpen.

sjscotti avatar sjscotti commented on July 19, 2024

Thanks for getting back with me! From your response, I understand that you are already using the torch.no_grad capability. Here is the full error traceback that I get.


(FullSubNet) F:\GPEN-main\GPEN-main>python face_enhancement.py
Traceback (most recent call last):
  File "face_enhancement.py", line 100, in <module>
    img, orig_faces, enhanced_faces = faceenhancer.process(im)
  File "face_enhancement.py", line 43, in process
    facebs, landms = self.facedetector.detect(img)
  File "F:\GPEN-main\GPEN-main\retinaface\retinaface_detection.py", line 67, in detect
    loc, conf, landms = self.net(img)  # forward pass
  File "C:\Users\Steve\anaconda3\envs\FullSubNet\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "F:\GPEN-main\GPEN-main\retinaface\facemodels\retinaface.py", line 108, in forward
    out = self.body(inputs)
  File "C:\Users\Steve\anaconda3\envs\FullSubNet\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "C:\Users\Steve\anaconda3\envs\FullSubNet\lib\site-packages\torchvision\models\_utils.py", line 63, in forward
    x = module(x)
  File "C:\Users\Steve\anaconda3\envs\FullSubNet\lib\site-packages\torch\nn\modules\module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "C:\Users\Steve\anaconda3\envs\FullSubNet\lib\site-packages\torch\nn\modules\batchnorm.py", line 131, in forward
    return F.batch_norm(
  File "C:\Users\Steve\anaconda3\envs\FullSubNet\lib\site-packages\torch\nn\functional.py", line 2056, in batch_norm
    return torch.batch_norm(
RuntimeError: CUDA out of memory. Tried to allocate 6.27 GiB (GPU 0; 8.00 GiB total capacity; 7.82 GiB already allocated; 0 bytes free; 7.83 GiB reserved in total by PyTorch)

(FullSubNet) F:\GPEN-main\GPEN-main>

I found that if I process only about a third of the original photo, then GPEN has no trouble. So I've cropped the large photo into three separate photos, processed each by GPEN, and combined the separate outputs to get all the processed faces in one result. However, a few faces had to be cut off, so I would prefer not having to piece together the separate processed photos by hand.

from gpen.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.