Support running in parallel in python multithreading
PhuongNDVN opened this issue · 0 comments
PhuongNDVN commented
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")