Threads do not end properly at the end of a training run
Describe the bug
I currently have a Python script that interacts with the mlagents Python package. Since the script is in Python, instead of using the mlagents-learn command through a subprocess (e.g., subprocess.run(["mlagents-learn", arguments...,])), I was hoping to directly run the run_cli(parse_command_line(...)) instead to make them more tightly integrated.
I noticed that if we were to run the training process in a loop sequentially, e.g.,
for i in range(5):
run_cli(parse_command_line(...))
some threads do not end properly, and get carried forward to future training processes. This was observed through the cli output, where the first run will execute properly, but for the second run and so on, there will be multiple parallel instances of the same training occurring (see below). This occurs regardless of the num_envs training parameter.
It should also be noted that if subprocess.run(["mlagents-learn", arguments...]) was used instead, this issue does not occur.
To Reproduce Run mlagents' functions in a loop:
for i in range(5):
run_cli(parse_command_line(...))
Console logs / stack traces
...
INFO:mlagents.trainers.stats:3DBallHard. Step: 5000. Time Elapsed: 89.207 s. Mean Reward: 1.192. Std of Reward: 0.633. Training.
INFO:mlagents.trainers.stats:3DBallHard. Step: 5000. Time Elapsed: 70.051 s. Mean Reward: 1.192. Std of Reward: 0.633. Training.
INFO:mlagents.trainers.stats:3DBallHard. Step: 5000. Time Elapsed: 45.627 s. Mean Reward: 1.192. Std of Reward: 0.633. Training.
INFO:mlagents.trainers.stats:3DBallHard. Step: 5000. Time Elapsed: 25.793 s. Mean Reward: 1.192. Std of Reward: 0.633. Training.
INFO:mlagents.trainers.stats:3DBallHard. Step: 5000. Time Elapsed: 4.729 s. Mean Reward: 1.192. Std of Reward: 0.633. Training.
...
Environment (please complete the following information):
- Unity Version: Unity 2020.3.7f1
- OS + version: CentOS Linux 7 (Core)
- ML-Agents version: Release 18, v0.27.0
- Torch version: 1.8.1
- Environment: 3DBallHard
This issue has been automatically marked as stale because it has not had activity in the last 28 days. It will be closed in the next 14 days if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed because it has not had activity in the last 42 days. If this issue is still valid, please ping a maintainer. Thank you for your contributions.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.