Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug ML agents not stopping when I exit play mode

Discussion in 'ML-Agents' started by theashbot, May 12, 2023.

  1. theashbot

    theashbot

    Joined:
    Apr 17, 2022
    Posts:
    21
    When start the training it tells me to enter play mode to start the training, then when I exit play mode it should stop the training right? well for me the training just continues, and it says enter play mode to resume. So I can never save my Brian I was wounding if you know what to do. after I leave the CMD open for a few minuets of not doing anything I get this error in the CMD.

    [INFO] MoveToGoal. Step: 150000. Time Elapsed: 106.003 s. Mean Reward: 9.996. Std of Reward: 0.217. Training. [WARNING] Restarting worker[0] after 'Communicator has exited.' [INFO] Listening on port 5004. Start training by pressing the Play button in the Unity Editor. ============== Diagnostic Run torch.onnx.export version 2.0.1+cpu ============== verbose: False, log level: Level.ERROR ======================= 0 NONE 0 NOTE 0 WARNING 0 ERROR ======================== Traceback (most recent call last): File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\trainer_controller.py", line 175, in start_learning n_steps = self.advance(env_manager) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents_envs\timers.py", line 305, in wrapped return func(*args, **kwargs) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\trainer_controller.py", line 233, in advance new_step_infos = env_manager.get_steps() File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\env_manager.py", line 124, in get_steps new_step_infos = self._step() File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\subprocess_env_manager.py", line 420, in _step self._restart_failed_workers(step) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\subprocess_env_manager.py", line 328, in _restart_failed_workers self.reset(self.env_parameters) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\env_manager.py", line 68, in reset self.first_step_infos = self._reset_env(config) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\subprocess_env_manager.py", line 446, in _reset_env ew.previous_step = EnvironmentStep(ew.recv().payload, ew.worker_id, {}, {}) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\subprocess_env_manager.py", line 101, in recv raise env_exception mlagents_envs.exception.UnityTimeOutException: The Unity environment took too long to respond. Make sure that : The environment does not need user interaction to launch The Agents' Behavior Parameters > Behavior Type is set to "Default" The environment and the Python interface have compatible versions. If you're running on a headless server without graphics support, turn off display by either passing --no-graphics option or build your Unity executable as server build. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\torch\onnx\_internal\onnx_proto_utils.py", line 219, in _add_onnxscript_fn import onnx ModuleNotFoundError: No module named 'onnx' The above exception was the direct cause of the following exception: Traceback (most recent call last): File "C:\Users\Asher\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 197, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\Asher\AppData\Local\Programs\Python\Python39\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "C:\GameDev\Unity\ML Agents\venv\Scripts\mlagents-learn.exe\__main__.py", line 7, in <module> File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\learn.py", line 264, in main run_cli(parse_command_line()) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\learn.py", line 260, in run_cli run_training(run_seed, options, num_areas) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\learn.py", line 136, in run_training tc.start_learning(env_manager) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents_envs\timers.py", line 305, in wrapped return func(*args, **kwargs) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\trainer_controller.py", line 200, in start_learning self._save_models() File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents_envs\timers.py", line 305, in wrapped return func(*args, **kwargs) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\trainer_controller.py", line 80, in _save_models self.trainers[brain_name].save_model() File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\trainer\rl_trainer.py", line 172, in save_model model_checkpoint = self._checkpoint() File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents_envs\timers.py", line 305, in wrapped return func(*args, **kwargs) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\trainer\rl_trainer.py", line 144, in _checkpoint export_path, auxillary_paths = self.model_saver.save_checkpoint( File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\model_saver\torch_model_saver.py", line 60, in save_checkpoint self.export(checkpoint_path, behavior_name) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\model_saver\torch_model_saver.py", line 65, in export self.exporter.export_policy_model(output_filepath) File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\mlagents\trainers\torch_entities\model_serialization.py", line 164, in export_policy_model torch.onnx.export( File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\torch\onnx\utils.py", line 506, in export _export( File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\torch\onnx\utils.py", line 1620, in _export proto = onnx_proto_utils._add_onnxscript_fn( File "C:\GameDev\Unity\ML Agents\venv\lib\site-packages\torch\onnx\_internal\onnx_proto_utils.py", line 221, in _add_onnxscript_fn raise errors.OnnxExporterError("Module onnx is not installed!") from e torch.onnx.errors.OnnxExporterError: Module onnx is not installed!

    Thank you in advance.
     
  2. zajacignacy

    zajacignacy

    Joined:
    Nov 24, 2021
    Posts:
    2
    Same problem here, i tried
    pip3 install onnx
    but didnt work
     
    theashbot likes this.
  3. smallg2023

    smallg2023

    Joined:
    Sep 2, 2018
    Posts:
    102
    that's pretty normal, you can press control+c in the cmd window to manually stop it.