Multiprocess/ 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 =, range(n_processes))


Traceback (most recent call last):
File “”, line 188, in
File “”, line 145, in train
with Pool(processes=n_processes) as pool:
File “/usr/lib/python3.5/multiprocessing/”, line 150, in init
File “/home/cs234-gpu2/.env3.5/lib/python3.5/site-packages/torch/multiprocessing/”, 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/

1 Like