I run a function in parallel and each worker has access to one GPU with id 0 or 1. def f(GPU_id, arg): # Select GPU to use. os.environ["CUDA_VISIBLE_DEVICES"]=str(GPU_id) # Do something with arg. Let's say I want to evaluate arg=[1, 2, 3, 4]. from multiprocessing import Pool p = Pool(2) for arg in [[1, 2], [3, 4]]: # Call the function in parallel on GPU 0 and 1 p.starmap(f, zip([0, 1], arg)) But now, I would like to run it asynchronously (not sure if this is the right term), meaning that the workers do not wait until the others have finished their task before they go to the next task. Therefore, the worker needs to keep the GPU_id and take the next argument from the list. Any ideas how to do this? Continue reading...