m-tassano / fastdvdnet

FastDVDnet: A Very Fast Deep Video Denoising algorithm
MIT License
572 stars 123 forks source link

CUDA out of memory. But why though? #44

Closed pedrovivash closed 2 years ago

pedrovivash commented 2 years ago

I'm assuming the response to this will be something along the lines: "turn off GPU." Yet, I find it hard to believe that using the same hardware I've used with DaVinci Resolve (which can denoise an unlimited amount of video frames on the fly using motion estimation), my measly 80kb jpg files (sure 10717 frames worth) are failing with fastDVDnet. Well:

Traceback (most recent call last): File "test_fastdvdnet.py", line 166, in test_fastdvdnet(**vars(argspar)) File "test_fastdvdnet.py", line 98, in test_fastdvdnet max_num_fr=args['max_num_fr_per_seq']) File "C:\Users\pedro\Desktop\CLONE\fastdvdnet\utils.py", line 127, in open_sequence expand_axis0=False) File "C:\Users\pedro\Desktop\CLONE\fastdvdnet\utils.py", line 185, in open_image img = normalize(img) File "C:\Users\pedro\Desktop\CLONE\fastdvdnet\utils.py", line 307, in normalize return np.float32(data/255.) numpy.core._exceptions.MemoryError: Unable to allocate 23.7 MiB for an array with shape (3, 1080, 1920) and data type float32

This is utilizing 8GB VRAM. I guess I'm confused about how the program handles the memory allocation? It's all way over my head...

And to be clear, I'm avoiding solutions like Resolve. I'd prefer to use open-source, especially since noise reduction benefits from tinkering. I also like that you all have made this project otherwise straightforward to work with.

m-tassano commented 2 years ago

My impression is that your limiting factor here is not the GPU memory, but your RAM memory. The testing script loads all the input frames before running the CNN model. If I understand correctly, you want to denoise a sequence with 10717 frames, but your system does not have enough RAM memory to load all of them. You could try slicing the sequence to denoise and load less frames at a time. You could as well for example modify the testing script so that it loads the input frames in a sliding window fashion.

pedrovivash commented 2 years ago

Just saw this, thank you! I'll take a look at the script in the future. Cheers.