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

Python crashes when training. #5229

Closed
George056 opened this issue Apr 7, 2021 · 11 comments
Closed

Python crashes when training. #5229

George056 opened this issue Apr 7, 2021 · 11 comments
Assignees
Labels
bug Issue describes a potential bug in ml-agents. stale Issues that have been idle for a while. Automatically closed by a bot if idle for too long.

Comments

@George056
Copy link

When training I receive an error but training continues, but python then crashes after training continues for a few minutes. Also, the summery folder is not generated and the obtained reward is not printed. I am having this bug on my custom environment that is using discrete actions and is manually being called. My training configuration follows.

behaviors:
    Node_AI:
        trainer_type: sac
        summary_freq: 50000
        time_horizon: 128
        max_steps: 5.0e6
        keep_checkpoints: 5
        checkpoint_interval: 500000
        init_path: null
        threaded: true
        hyperparameters:
            learning_rate: 3e-4
            batch_size: 100 #this is a guess avg is 32 - 512
            buffer_size: 50000
            learning_rate_schedule: constant
            buffer_init_steps: 0
            init_entcoef: 0.5
            save_replay_buffer: true
            tau: 0.005
            steps_per_update: 1
        network_settings:
            hidden_units: 256
            num_layers: 2 #typical is 1 - 3
            normalize: false
            vis_encoder_type: match3
        reward_signals:
            extrinsic:
                gamma: 0.99
                strength: 1.0
            curiosity:
                strength: 0.05
                gamma: 0.99
        self_play:
            save_steps: 20000
            team_change: 80000
            swap_steps: 5000
            play_against_latest_model_ratio: 0.5
            window: 10
c:\users\capstone\.conda\envs\ml-agents-node\lib\site-packages\mlagents\trainers\torch\utils.py:242: UserWarning: This overload of nonzero is deprecated:
nonzero()
Consider using one of the following signatures instead:
nonzero(*, bool as_tuple) (Triggered internally at ..\torch\csrc\utils\python_arg_parser.cpp:882.)
res += [data[(partitions == i).nonzero().squeeze(1)]]
  • Unity Version: 2020.2.3f1
  • OS + version: Windows 10
  • ML-Agents version: 0.23
  • Torch version: 1.7.1
@George056 George056 added the bug Issue describes a potential bug in ml-agents. label Apr 7, 2021
@andrewcoh andrewcoh self-assigned this Apr 8, 2021
@andrewcoh
Copy link
Contributor

andrewcoh commented Apr 12, 2021

Hi @George056

This is not a bug, just a warning that we are using a torch function signature of nonzero that is deprecated.

However, crashing after a few minutes sounds like an issue. Can you share the error logs?

@George056
Copy link
Author

I have not seen any error logs, when it crashes python freezes.

@andrewcoh
Copy link
Contributor

Does it crash on the Unity side and then the python side times out (UnityTimeoutException) or does everything freeze? I'm assuming the editor console logs are empty too?

I'm not sure where the bug could be originating. It might help to remove some features (curiosity and self-play) to determine if it's something in the trainers or just C#.

@George056
Copy link
Author

Unity temporarily stops but then goes back to playing using the heuristic.

@George056
Copy link
Author

I do know that I get a lot of warnings in Unity due to the collect observations not just being called when it is not that AI's turn to make a move.

@George056
Copy link
Author

I just removed the lines that caused all of the warning and it still froze.
What exactly happens is that at the end of a game, and I have only seen it happen at the end of a game, is that Unity freezes and then python says that the environment has stopped. I the return to Unity and it starts to play using the heuristic and python is frozen.

@andrewcoh
Copy link
Contributor

andrewcoh commented Apr 13, 2021

Is there anything in the player logs located in results/<run-id>/run_logs/Player-x.log?

This is only happening on Reset? Do you know if the call to OnEpisodeBegin for the next game is occurring?

Also, can you clarify what you mean by "manually being called" in the initial post. Are you using RequestDecision?

@George056
Copy link
Author

No log files are made, just 2 json files (timers and training_status). I am calling RequestDecision, the game is turn based and I call it when it is this agents turn.

@stale
Copy link

stale bot commented Jan 9, 2022

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.

@stale stale bot added the stale Issues that have been idle for a while. Automatically closed by a bot if idle for too long. label Jan 9, 2022
@stale
Copy link

stale bot commented Apr 18, 2022

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.

@stale stale bot closed this as completed Apr 18, 2022
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue describes a potential bug in ml-agents. stale Issues that have been idle for a while. Automatically closed by a bot if idle for too long.
Projects
None yet
Development

No branches or pull requests

2 participants