OpenCV+CUDA simultaneously linked with Python and a Python C extension

Viewed 74

I'm working on a Python project that involves C extension code, and opencv is directly used in both the Python code and C extension code, both requiring CUDA. This is proving to be very tricky to setup in terms of dependencies and linking, and so I'm hoping others might have insight after spending considerable time without much progress myself. In particular I have a few questions:

  1. Building opencv from source with shared lib + Python support, and linking the C extension with the produced libraries, seems to allow both the Python and C extension to work, but a maintainer seemed to say this is very bad and may cause weird conditions due to shared state. Are there specific areas where problems arise and is this a bad idea to do?
  2. The only obvious alternative I can see to 1) is to have Python import one opencv and have the C extension load another opencv build. Is this feasible to do on Linux and Windows without doubling the very large amount of memory consumed in loading opencv?
  1. Are there feasible general options I'm overlooking? (Hopefully involving pip wheels to save a several-hour build per install)
0 Answers
Related