Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question about the training agent in client and server.

Discussion in 'ML-Agents' started by smartriver97, Jun 22, 2020.

  1. smartriver97

    smartriver97

    Joined:
    Jun 3, 2020
    Posts:
    11
    I want use the Mlagents components in a tank agent in client,where the game logic was designed in the server.
    In the client,I can't instantiate copies of the training area, so is it possible to train the same behaviour by open several unity client?
    By the way,are there appropriate methods for the Asynchronous communication environment?
     
  2. MrWetsnow

    MrWetsnow

    Joined:
    Jan 5, 2020
    Posts:
    60
    For your first question, the answer is yes. Pass the --num-envs N flag to mlagents-learn, where N is the number of environments you want to spawn.
     
    celion_unity likes this.
  3. celion_unity

    celion_unity

    Joined:
    Jun 12, 2019
    Posts:
    289
    For the second part, we don't currently have any support for asynchronous communication between the trainers and environments.
     
  4. smartriver97

    smartriver97

    Joined:
    Jun 3, 2020
    Posts:
    11
    Thanks for your answer.
    Can I open multiple Unity Client for train the same behaviour? The game Client I used is difficult to modify,which can open one Dungeon one time. I can only add the necessary component on the game object which generated in the game and train the agent in one Dungeon. I want to start up several Unity Client as the multiple environment, is there any way to implement it?
     
  5. MrWetsnow

    MrWetsnow

    Joined:
    Jan 5, 2020
    Posts:
    60
    Do you mean you need to do something manual in each environment? The way the --num-envs flag is meant to work is the following:

    1. Build an executable in Unity of your entire App (include just the training scene you need and make sure that it launches automatically without having to click any UI elements). This is under File/Build Settings. Make sure the training scene has a checkbox next to it and is the main scene (or the only one).

    2. Do your training:

    mlagents-learn configs/your_config.yaml --run-id=YouRunID --env=path/to/above/executable --no-graphics --num-envs 4

    This will launch 4 separate training environments. --no-graphics is useful to make your machine do less work, but only works if you don't have any physics based observations (i.e. ray casts), otherwise leave the flag out.

    Training should start automatically.
     
    celion_unity likes this.
  6. smartriver97

    smartriver97

    Joined:
    Jun 3, 2020
    Posts:
    11
    Thanks very much!
     
  7. smartriver97

    smartriver97

    Joined:
    Jun 3, 2020
    Posts:
    11
    Thanks very much!It is usefull!
    But I notice that the training will stop when one environment stop or have a crash,and all other environment will stop after that. Can I restart an environment when one environment unexpected stop? I think it is important for a robust training.
    Should I new an env in the Exception handling? and what else I should do?
     
  8. ervteng_unity

    ervteng_unity

    Unity Technologies

    Joined:
    Dec 6, 2018
    Posts:
    150
    Hi @smartriver97, restarting one of many environments is not currently supported, though we're looking into the possibility of adding that feature. However, in the event of a crash you can quit ML-Agents using Ctrl+C and resume the old run using
    --resume
    .