visinf / irr

Iterative Residual Refinement for Joint Optical Flow and Occlusion Estimation (CVPR 2019)
Apache License 2.0
194 stars 32 forks source link

Reducing GPU memory usage #7

Closed Dolu1990 closed 5 years ago

Dolu1990 commented 5 years ago

Hi,

Is there a way to reduce the GPU memory usage ? With 1k *1k frame, it get out of memory.

RuntimeError: CUDA out of memory. Tried to allocate 28.00 MiB (GPU 0; 7.79 GiB total capacity; 5.71 GiB already allocated; 20.12 MiB free; 131.19 MiB cached)

Maybe by changing some training parameters i can reduce the memory usage of the optical flow runtime ?

Thanks ^^

hurjunhwa commented 5 years ago

Hi,

You may refer this great work, dealing with how to reduce the network size while still achieving comparable accuracy, which backbone architecture is similar to that of PWC-Net: https://arxiv.org/pdf/1903.07414.pdf Then, you may have some ideas how to reduce the GPU memory usage while not hurting the accuracy that much.

Or,

1) in our implementation, you may use light-weighted flow decoder without the dense connection: by using class OpticalFlowEstimator(nn.Module) instead of class FlowEstimatorDense(nn.Module) in models/pwc_modules.py.

2) Also turning off the ContextNetwork would be also one option.

3) Or, estimate the flow and occlusion map up to the second last pyramid level or even less.

In these ways, you can reduce the amount of GPU memory usage, but as a trade-off, the accuracy would be a bit worse than the original model. By the way, 1) and 2) requires re-training the networks from the scratch because the pretrained weights are tuned for the original model.

Thanks!

Dolu1990 commented 5 years ago

I will try that, Thanks :D