Linaom1214/TensorRT-For-YOLO-Series

How to use engine in a process or a thread

jet-c-21 opened this issue · 4 comments

When I try to load the engine in a process, the engine predictor will not be loaded and the process will end directly.

And when I try to load the engine in a thread, I got following error:

pycuda._driver.LogicError: explicit_context_dependent failed: invalid device context - no currently active context?

What is your operating environment? If it is a notebook, please restart the kernel.

not notebook i am trying to run it on Jetson Nano locally

@jet-c-21
You need to create contexts for each engine you want to load. You can do this with:
cfx = cuda.Device(0).make_context()
and then wrap all your code which handles data and execution with:
cfx.push() and cfx.pop()