UsingNet / nvjpeg-python

nvjpeg for python
MIT License
93 stars 24 forks source link

Load NvJpeg still not stable (0.0.9) #2

Closed maara-fieldtrip closed 3 years ago

maara-fieldtrip commented 3 years ago

Unfortunately I'm still seeing this in 0.0.9 when using in a ROS process, sometimes it errors out with:

SystemError: <class 'nvjpeg.NvJpeg'> returned NULL without setting an error

Most of the time runs, approximately 1/5 times I get this error on startup when I call nvjpeg.NvJpeg()

oliver-batchelor commented 3 years ago

It seems to happen much more often when called from in a thread, too - more like 4/5 times.

oliver-batchelor commented 3 years ago

I'm trying to understand what's going on here - what is actually being set to NULL here? It's the NvJpeg python object not the m_handle inside it? The pointer returned from NvJpegPython_startUpEnv never seems to be NULL so what is?

It seems to be some kind of race condition because if I put a printf inside NvJpeg_init I never get the error.

oliver-batchelor commented 3 years ago

A modification of the test-with-multiprocessing.py which reliably produces the error

from nvjpeg import NvJpeg 
nj = NvJpeg()   <--- add this line in immediately after import in the main thread
oliver-batchelor commented 3 years ago

In fact it doesn't even need to run the threads at all. This is the full test case:

from nvjpeg import NvJpeg 
nj = NvJpeg()

Gives the error ~50% of the time

chrischengis commented 3 years ago

I am also using version 0.0.9 and am seeing the same issue. I am also running with multiprocessing.

Here is the error: line 138, in init self.nj = NvJpeg() SystemError: <class 'nvjpeg.NvJpeg'> returned NULL without setting an error

I ran tests/test-with-multiprocessing.py, and it passed.

oliver-batchelor commented 3 years ago

See pull request I made a fix but it's just sitting there

chrischengis commented 3 years ago

Thanks saulzar!

Zeng, when do you expect the release with this fix be available?

zeng-qinghui commented 3 years ago

Thanks saulzar!

Zeng, when do you expect the release with this fix be available?

Thanks chrischengis! I have merged and released this fix.