Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Warn mp start method #215

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions chainermn/optimizers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
import chainer
import copy
import multiprocessing.pool
import warnings


def _check_mp_start_method(comm):
"""Show a warning if multiprocessing's start_method is not 'forkserver'."""
method = multiprocessing.get_start_method()

if comm.size > 1 and comm.rank == 0:
if method is not 'forkserver':
warnings.warn("multiprocessing's `start_method` must be "
"'forkserver' (now it's '{}')".format(method),
stacklevel=2)


class _MultiNodeOptimizer(object):
Expand Down Expand Up @@ -164,6 +176,8 @@ def create_multi_node_optimizer(actual_optimizer, communicator,
Returns:
The multi node optimizer based on ``actual_optimizer``.
"""
_check_mp_start_method(communicator)

if double_buffering:
from chainermn.communicators.pure_nccl_communicator \
import PureNcclCommunicator
Expand Down