Skip to content
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

Support running in parallel in python multithreading #11

Open
PhuongNDVN opened this issue Nov 28, 2022 · 0 comments
Open

Support running in parallel in python multithreading #11

PhuongNDVN opened this issue Nov 28, 2022 · 0 comments

Comments

@PhuongNDVN
Copy link

PhuongNDVN commented Nov 28, 2022

I try to run the project in python multithreading. The total processing time is similar to running in serial. I tried to modify pybind.cpp with pybind11::call_guard pybind11::gil_scoped_release () but no effect. What I've tried:

  pybind11::gil_scoped_release release;
  const Result r = detector.detectBatch(mats, &detections, flags);
  pybind11::gil_scoped_acquire acquire;

Plz consider this issue.

The code I tested with multithreading:

from threading import Thread
ts = time.perf_counter()
num_of_threads = 3
threads = []
for k in range(num_of_threads):
    thread = Thread(target=detector.detectBatch, args=[images, ])
    threads.append(thread)
    thread.start()
for thread in threads:
    thread.join()
duration = time.perf_counter() - ts
print("detectBatch()-multithread took:", duration*1000, "milliseconds")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant