Skip to content

Commit 8a33517

Browse files
Only using multiprocess when --num-runs>1 (#1583)
Fixes the bug of the models not being saved in docker
1 parent 5510062 commit 8a33517

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

ml-agents/mlagents/trainers/learn.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,16 +107,22 @@ def main():
107107

108108
jobs = []
109109
run_seed = seed
110-
for i in range(num_runs):
110+
111+
if num_runs == 1:
111112
if seed == -1:
112113
run_seed = np.random.randint(0, 10000)
113-
process_queue = Queue()
114-
p = Process(target=run_training, args=(i, run_seed, options, process_queue))
115-
jobs.append(p)
116-
p.start()
117-
# Wait for signal that environment has successfully launched
118-
while process_queue.get() is not True:
119-
continue
114+
run_training(0, run_seed, options, Queue())
115+
else:
116+
for i in range(num_runs):
117+
if seed == -1:
118+
run_seed = np.random.randint(0, 10000)
119+
process_queue = Queue()
120+
p = Process(target=run_training, args=(i, run_seed, options, process_queue))
121+
jobs.append(p)
122+
p.start()
123+
# Wait for signal that environment has successfully launched
124+
while process_queue.get() is not True:
125+
continue
120126

121127
# For python debugger to directly run this script
122128
if __name__ == "__main__":

0 commit comments

Comments
 (0)