简体   繁体   English

TensorFlow 2 是否支持不同 CPU 内核上的多处理?

[英]Doest TensorFlow 2 supports Multiprocessing on different CPU cores?

I am stuck in implementing the Asynchronous Advantage Actor-Critic (A3C) using TensorFlow 2.我坚持使用 TensorFlow 2 来实现异步优势 Actor-Critic (A3C)。

Problem Definition: For A3C implementation, I have to create a bunch of workers (as much as number of CPU cores) and a master.问题定义:对于 A3C 实施,我必须创建一堆工作人员(与 CPU 内核数量一样多)和一个主服务器。 All the workers and also the master will create a copy of a unique CNN module for themselves.所有的工人和主人都会为自己创建一个独特的 CNN 模块的副本。 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.当每个工作人员必须优化主控的 CNN 模块并将其权重与主控的 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.我已经通过多线程毫无问题地实现了这一点,但是当多处理进入时,python 既不能序列化权重也不能序列化 CNN 本身以在工作人员和主服务器之间传递。

Other's problem: When I was googling to cope with this problem I have noticed different opinions (Also almost all the QA were related to the TF 1).其他问题:当我在谷歌上搜索解决这个问题时,我注意到了不同的意见(而且几乎所有的 QA 都与 TF 1 有关)。 Some people believe that TensorFlow doesn't support multiprocessing so they either moved to PyTorch or just used multithreading.有些人认为 TensorFlow 不支持多处理,所以他们要么转移到 PyTorch 要么只使用多线程。 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.首先,我想知道是否有可能通过 TF 2 实现像 A3C 这样的多处理方法。如果有可能,如果有人与我分享类似的作品,我将不胜感激。

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.我确实找到了一个使用 TF1.X 和multiprocessing A3C 的资源(见下面的链接)。 In general, they use Queues to share the model weights.通常,他们使用队列来共享 model 权重。

Personally, I'm curious is there's an easier or better way to use multiprocessing for A3C.就个人而言,我很好奇是否有一种更简单或更好的方法来为 A3C 使用multiprocessing 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 https://github.com/hongzimao/a3c/blob/master/train.py

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM