Hi!
I’m using pytorch with python multiprocessing tool to train a PPO network. When collecting data, I need to use both GPU and CPU. And I want to use multiple processes for data collection for faster training. Here is how I implement it:
for i in range(1):
worker_args = (args)
workers.append(multiprocessing.Process(target=collect_sample, args=worker_args))
for worker in workers:
worker.start()
In the above code, collect_sample
function will use Pytorch to collect data with both GPU and CPU. And as an error indicates, I also added: torch.multiprocessing.set_start_method('spawn')
. However, after adding this line, another error happens: “TypeError: can’t pickle _thread.lock objects”. I didn’t figure out good solutions to this problem. May I have your help? Thank you!