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 OOM #1

Open
ducha-aiki opened this issue Mar 1, 2024 · 14 comments
Open

CUDA OOM #1

ducha-aiki opened this issue Mar 1, 2024 · 14 comments

Comments

@ducha-aiki
Copy link

Hi,

The performance is really amazing on the few image pairs I have tried.
However, when I moved to a bigger scenes (29 images), it crashes with CUDA OOM on 16Gb V100.
Any recommendations how can I run it?

  File "/home/old-ufo/dev/dust3r/dust3r/cloud_opt/optimizer.py", line 176, in forward
    aligned_pred_i = geotrf(pw_poses, pw_adapt * self._stacked_pred_i)
  File "/home/old-ufo/dev/dust3r/dust3r/utils/geometry.py", line 86, in geotrf
    pts = pts @ Trf[..., :-1, :] + Trf[..., -1:, :]

torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 2.38 GiB. GPU 0 has a total capacity of 15.77 GiB of which 775.88 MiB is free. Including non-PyTorch memory, this process has 15.01 GiB memory in use. Of the allocated memory 13.70 GiB is allocated by PyTorch, and 922.14 MiB is reserved by PyTorch but unallocated. If reserved but unallocated memory is large try setting max_split_size_mb to avoid fragmentation.  See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
@jerome-revaud
Copy link
Contributor

Oh... No easy fix that i can see, we usually perform our experiments on A100 with 80GB so we never particularly optimized the memory, sorry ^^'
With 80GB, we could optimize scenes with 200+ images.

@jerome-revaud
Copy link
Contributor

maybe @yocabon would have a better idea?

@jerome-revaud
Copy link
Contributor

One solution, kindly suggested by my colleague Romain Bregier, is to have the global alignment running on CPU. Will be slower but will not crash...

@ducha-aiki
Copy link
Author

Thank you, will try it.
And for GPU - is there a way to use multi GPU? I have a server with 8 V100 = 8 x 16Gb, not A100 unfortunately

@yocabon
Copy link
Contributor

yocabon commented Mar 1, 2024

Hi,
I updated the demo script to expose the "scene_graph" parameter. By default, we make all possible pairs, but it explodes when you add many images. Use the "sliding window" or "one reference" method to make fewer pairs, then it should fit in memory.

No we didn't implement multi gpu for the inference.

@ducha-aiki
Copy link
Author

Oh, that's super useful, thank you!

@nickponline
Copy link

How do we set the global alignment to run on CPU?

@nickponline
Copy link

I think maybe this scene = global_aligner(output, device="cpu", mode=mode)

@nickponline
Copy link

That seems to work ^

@ducha-aiki
Copy link
Author

@nickponline Just tried 36 images on CPU, now I have the OOM CPU error on a machine with 120 Gb.
Is there a way to reduce number of points besides using 224x224 resolution?

RuntimeError: [enforce fail at alloc_cpu.cpp:83] err == 0. DefaultCPUAllocator: can't allocate memory: you tried to allocate 2005401600 bytes. Error code 12 (Cannot allocate memory)

@jerome-revaud
Copy link
Contributor

@ducha-aiki do you have a scene covisibility graph? if so, this would greatly reduce the memory usage. On an A100 with 80GB, we are able to optimize scenes with 200+ images when we use 10NN per image.

@jerome-revaud
Copy link
Contributor

we had this implemented here

def make_pairs(imgs, scene_graph='complete', prefilter=None, symmetrize=True):

but it didn't make it in the final version ...

@ducha-aiki
Copy link
Author

I don't have a co-visibility graph, but I can probably run DINOv2, or SALAD to get an estimation. Thank you for the suggestion

@xuyanging
Copy link

Oh... No easy fix that i can see, we usually perform our experiments on A100 with 80GB so we never particularly optimized the memory, sorry ^^' With 80GB, we could optimize scenes with 200+ images.

Good, I replace 3090 laptop with H100 and it works!

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

5 participants