Skip to content

Commit

Permalink
warning about fork
Browse files Browse the repository at this point in the history
  • Loading branch information
ppwwyyxx committed May 22, 2020
1 parent d95bf7a commit 315eab9
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion examples/FasterRCNN/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ def __ne__(self, _):
_C.TRAIN.WEIGHT_DECAY = 1e-4
_C.TRAIN.BASE_LR = 1e-2 # defined for total batch size=8. Otherwise it will be adjusted automatically
_C.TRAIN.WARMUP = 1000 # in terms of iterations. This is not affected by #GPUs
_C.TRAIN.WARMUP_INIT_LR = 0. # defined for total batch size=8. Otherwise it will be adjusted automatically
_C.TRAIN.WARMUP_INIT_LR = 1e-5 # defined for total batch size=8. Otherwise it will be adjusted automatically
_C.TRAIN.STEPS_PER_EPOCH = 500
_C.TRAIN.STARTING_EPOCH = 1 # the first epoch to start with, useful to continue a training

Expand Down
7 changes: 4 additions & 3 deletions tensorpack/dataflow/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ def __init__(self, ds, num_prefetch, num_proc):
self.procs = [MultiProcessRunner._Worker(self.ds, self.queue, idx)
for idx in range(self.num_proc)]
ensure_proc_terminate(self.procs)
start_proc_mask_signal(self.procs)
self._reset_done = False

def __iter__(self):
for k in itertools.count():
Expand All @@ -233,8 +233,9 @@ def __iter__(self):
yield dp

def reset_state(self):
# do nothing. all ds are reset once and only once in spawned processes
pass
assert not self._reset_done, "reset_state() was called twice! This violates the API of DataFlow!"
self._reset_done = True
start_proc_mask_signal(self.procs)


class MultiProcessRunnerZMQ(_MultiProcessZMQDataFlow):
Expand Down
4 changes: 2 additions & 2 deletions tensorpack/utils/concurrency.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ def start_proc_mask_signal(proc):
if isinstance(p, mp.Process):
if sys.version_info < (3, 4) or mp.get_start_method() == 'fork':
log_once("""
Starting a process with 'fork' method is not safe and may consume unnecessary extra CPU memory.
Use 'forkserver' or 'spawn' method (available after Py3.4) instead if you run into any issues.
Starting a process with 'fork' method is efficient but not safe and may cause deadlock or crash.
Use 'forkserver' or 'spawn' method instead if you run into such issues.
See https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods on how to set them.
""".replace("\n", ""),
'warn') # noqa
Expand Down

0 comments on commit 315eab9

Please sign in to comment.