Pytorch multiprocessing CUDA Initialization error

I’m trying to run multiple threads in pytorch with GPU enabled. In each thread, I am trying to create a CUDA tensor from numpy array using the following code:

tensor = torch.from_numpy(array).cuda().float()

this triggers the following error report:

RuntimeError: CUDA error: initialization error

Any help would be greatly appreciated!

sorry I just solved this problem by using

    mp.set_start_method('spawn')