hosh0425
hosh0425

Reputation: 98

Doest TensorFlow 2 supports Multiprocessing on different CPU cores?

I am stuck in implementing the Asynchronous Advantage Actor-Critic (A3C) using TensorFlow 2.

Problem Definition: For A3C implementation, I have to create a bunch of workers (as much as number of CPU cores) and a master. All the workers and also the master will create a copy of a unique CNN module for themselves. The problem arises when each worker has to optimize the master's CNN module and also synchronize its weight with the weights of the master's CNN. I have implemented this by multithreading with no problems, but when multiprocessing comes in, python could serialize neither the weights nor CNN itself to pass between workers and master.

Other's problem: When I was googling to cope with this problem I have noticed different opinions (Also almost all the Q-A were related to the TF 1). Some people believe that TensorFlow doesn't support multiprocessing so they either moved to PyTorch or just used multithreading. Other people proposed ray library.

First of all, I want to know is it possible to do a multiprocessing approach like A3C by TF 2. And if it is possible I will appreciate it if someone shares similar works with me.

Upvotes: 3

Views: 793

Answers (1)

user13528202
user13528202

Reputation: 11

I'm running into the exact same issue myself. I did find a resource (see link below) that uses TF1.X and multiprocessing for A3C. In general, they use Queues to share the model weights.

Personally, I'm curious is there's an easier or better way to use multiprocessing for A3C. I found it quite hard to replicate their approach, so if you find another method, please share!

https://github.com/hongzimao/a3c/blob/master/train.py

Upvotes: 1

Related Questions