-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
[BUG]: Exit without throwing an exception #42
Comments
Hi @hahnec, Thanks for reporting the issue! If the process is producing a segmentation fault, there is not much we can do about it. I managed to run your code without issue here which allowed me to see that about 16-18Gb of RAM was used, it peaked at around 12.5Gb without the refining step. If you look at the code, we are already cleaning up forcibly a lot of allocated variables to lower memory pressure. If you don't mind loosing precision, you could set Cheers, Thomas |
…ge through bit-depth change. References #42.
If you use the |
Hey Thomas, thanks for your suggestion to go for the memory-efficient way of using the function. I will give it a try and adapt my code. Meanwhile, I was thinking of using your less-memory consuming de-bayering functions as a workaround while sacrificing on quality. To trigger the issue on your side, you could simulate the RAM limit by further increasing the image size to something like: mockup_image = np.ones([int(4e4), int(4e4)]) Given that 16GB is pretty much common standard these days, it also means that there is always an exception to that. Not knowing what has caused a tool to crash is a bit unsatisfying on my side. Hence, my ideal solution would give the memory-expensive method a chance using a try-except statement and inform the user about the memory problem if it occurs. So, I still wonder though whether it is possible to throw/catch an exception? |
Digging further into this, I noticed the crash occurs in masks.py at line 78 which looks like this channels[channel][y::2, x::2] = 1 It is a harmless numpy index assignment. So, throwing an exception is rather up to the numpy lib I guess. Initializing the channel variable as numpy bool early on (line 76) helps in saving memory, but still causes my call to be killed for a large frame. I probably have to stick to the above-mentioned workarounds for now and hope memory limits will not be exceeded. Thanks anyway! |
Another option would be to invoke the demosaicing process in a sub-process, this is not great nor ideal from an implementation standpoint but it would give you an opportunity to wrap the entire execution AND catch any problems whilst not crashing the main process. |
Spawning a sub-process (or even a new thread?) is an interesting way to prevent the function from being killed without exceptions. Why do you think it is not great nor ideal? With PR #46 I propose to initialize masks directly as boolean to lower the memory footprint. The for-loop at the return statement then becomes redundant, which is a nice side effect and reads better in my view. Tests successfully passed. If you don't have any objection, I would be happy to have this feature in a future version as it further reduces the chances of out-of-memory issues. |
You need to maintain some sort of wrapper to spin-up the process, do the demosaicing, save the image, and then read the demosaiced image in the parent process instead of doing it directly. It is rather painful!
Thanks, this is great and how the code should have been in the first place! Cheers, Thomas |
Closing as the root of this issue is not related to this repo. Thanks for accepting the PR. Looking forward to the new release! |
Is there a date, when a new release of this repo featuring the above PR can be expected? As can be seen here, users of PlenoptiCam still face problems addressed in this issue. I would appreciate a new release with my commits as it lowers the risk of running into memory issues. |
Hi @hahnec, I generally release a new version along side a main Colour release or if people ask for it, which you did! I will look at that over the weekend. If I forget, entirely possible, please poke a stick at me until it is done! Cheers, Thomas |
Hello @hahnec, This has been released!
Cheers, Thomas |
It's much appreciated Thomas! I will then also work on a new release on my side! Many thanks! |
My pleasure! |
Description
Hey folks,
I am a frequent user of your library and made it even part of my own project PlenoptiCam, where I recently encountered a problem, which I believe is due to the colour-demosaicing software library. Raw images passed to PlenoptiCam are relativey large in terms of their spatial resolution, thus requiring a large amount of memory. I observed that occasionally my software quit at some point without throwing an error or exception. When debugging, I noticed that this behaviour occurs at a point of my pipeline where the rather costly demosaicing_CFA_Bayer_Menon2007 function is called. I attempted to reproduce the problem with a synthetic image having a very large image resolution and observed the same problem: program abort without any message. Below you can find a short code example causing this issue on my machine.
While it is obvious why this error occurs, I would like to have a little control about the case when it happens. Would it be possible to throw an exception just before the function call crashes? This would allow users to keep programs running and let them know about the cause of the problem.
Code for Reproduction
Exception Message
Environment Information
The text was updated successfully, but these errors were encountered: