Multiprocess/pool.py TypeError: __init__() missing 1 required keyword-only argument: 'ctx'

Hi, I’m using pytorch on python 3.5.2. While attempting to use torch.multiprocessing.pool, I’m getting the following error.

Code snippet:

from torch.multiprocessing.pool import Pool

with Pool(processes=n_processes) as pool:
games = pool.map(self.play_game, range(n_processes))

Error:

Traceback (most recent call last):
File “rl_net.py”, line 188, in
agent.train(100000)
File “rl_net.py”, line 145, in train
with Pool(processes=n_processes) as pool:
File “/usr/lib/python3.5/multiprocessing/pool.py”, line 150, in init
self._setup_queues()
File “/home/cs234-gpu2/.env3.5/lib/python3.5/site-packages/torch/multiprocessing/pool.py”, line 23, in _setup_queues
self._inqueue = SimpleQueue()
TypeError: init() missing 1 required keyword-only argument: ‘ctx’

Use torch.multiprocessing.Pool instead of torch.multiprocessing.pool.Pool; the latter is a definition for Python 3.3 and under, and loaded into torch.multiprocessing.Pool – as stated in torch/multiprocessing/__init__.py.

1 Like