Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CUDA out of memory despite having a lot of free GPU memory #10

Closed
Mh-Magdy opened this issue Oct 7, 2024 · 8 comments
Closed

CUDA out of memory despite having a lot of free GPU memory #10

Mh-Magdy opened this issue Oct 7, 2024 · 8 comments

Comments

@Mh-Magdy
Copy link

Mh-Magdy commented Oct 7, 2024

torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 1.37 GiB. GPU .
The GPU memory is totally free and i still get this error each run?!

@jingheya
Copy link
Collaborator

jingheya commented Oct 7, 2024

What is the resolution of your images? And how about the total GPU memory of your device?

@Mh-Magdy
Copy link
Author

Mh-Magdy commented Oct 7, 2024

Test Image Resolution: 612x408
My GPU memory: 6144MiB

@jingheya
Copy link
Collaborator

jingheya commented Oct 7, 2024

A little bit odd (⊙_⊙). I tried an image with a resolution of 685x609, but it only required 2947MiB of memory.
Have you enabled half precision?

@Mh-Magdy
Copy link
Author

Mh-Magdy commented Oct 7, 2024

I got the same error even with the infer.sh script on the example images with half precision enabled by default inside infer.sh.

image

I tested Lotus on google colab [T4 gpu] and ran the infer.sh script and got the same error.

image

@jingheya
Copy link
Collaborator

jingheya commented Oct 7, 2024

Thanks for pointing out the problem, let me check the code.

@jingheya
Copy link
Collaborator

jingheya commented Oct 7, 2024

Hi, you can add torch.cuda.empty_cache() after each inference. Please refer to this line.

@Mh-Magdy
Copy link
Author

Mh-Magdy commented Oct 7, 2024

Thank you for your prompt response. I'll try the fix and let you know the update.
Thank once again for your great work.

@haodong2000
Copy link
Collaborator

Issue closed, please re-open it upon any problems 🤗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants