Using Multiprocessing in Pycuda

Hi,
I wrote pycuda program for my application but when I tried to run with multiple processes, I am getting pycuda._driver.LogicError: cuModuleGetFunction failed: initialization error.

I am using import pycuda.autoinit. Could you guide me how to initialize for various processes in Py-Cuda ?

1 Like

How many GPUs do you have? Are these sharing a single GPU? If so, what is the compute mode of that GPU set to?

Hello,
I use only single GPU which is Gtx 1070 and the computing mode is default set to 0.

This may explain what you are doing wrong:

[url]python - How use PyCuda in multiprocessing? - Stack Overflow

For example, I wouldn’t use autoinit, and I would be sure not to init CUDA in the master process.

I had a similar issue, and solve it by adding a line of code on the main process, before start the subprocesses:

 multiprocessing.set_start_method('spawn')

Source: [How to use Python to run pycuda in multiple processes - Stack Overflow]

1 Like

I solved this problem : adding import trt to the function of this thread directly:

def detect_frame(index_i, mainQ:multiprocessing.Queue):

    import detect_trt_predict