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

environment not resetting in build - but does in editor

Discussion in 'ML-Agents' started by TimHogklint, Dec 19, 2021.

  1. TimHogklint

    TimHogklint

    Joined:
    Nov 24, 2017
    Posts:
    40
    Hello

    * Honestly feel lile mono scripts are all disabled in build ? * Start,Awake,MLAgent Initialize does not work.

    So I have this project were it trains in editor but not in build. Both use the same configuration yaml.
    I tried enable graphics in the build and it just looks like it does not communicate on EndEpisode.

    Very strange , dont reset. What could cause such a disparity between editor and build ?

    Version information:
    ml-agents: 0.16.1,
    ml-agents-envs: 0.16.1,
    Communicator API: 1.0.0,
    TensorFlow: 2.7.0

    Unity Ver. Unity 2021.1.11f1 (64-bit)

    // Ofc I use CPU , not gpu.
    nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2021 NVIDIA Corporation
    Built on Mon_Sep_13_20:11:50_Pacific_Daylight_Time_2021
    Cuda compilation tools, release 11.5, V11.5.50
    Build cuda_11.5.r11.5/compiler.30411180_0

    Only "error" I get is a warning in editor that it received 0 observations - happens when I switch from physical to static. Kinda sucks.

    - Tried rebuilding the agent enviroment in diffrent project;
    // Surely that must mean the problem is on my side and not unity.

    - Tried disabling animator completly;

    - I had to see if agents script were disabled / I dont do my failstate like this but I mean
    it felt like the script wasent even active. No no it is.

    - Tried sending the build exe to my laptop to see it trains diffrently there . Nope same
    stuff no episodes.

    - Hmm looks like Start() does not run , as I have UI text that is set to state
    and its the default text ? ( for debugging )

    * Now get this , I cant get it to reset even when just checkin if its incline is below a certain
    value in FixedUpdate - its like the script even active !? what the HECK!?

    - Forcing the agent script to run via another script in the scene does not help - its
    like no mono objects ? are allowed to run ?

    - Added an exception to AVG for path and exe

    - Update to 2021.2.7f1

    - Gonna train with editor for awhile -see what happens :( Really stumped dont know
    why builds are not working.


    While training in editor console
    2021-12-20 21:47:16 INFO [stats.py:111] EditorWalker: Step: 30000. Time Elapsed: 260.881 s Mean Reward: 0.094. Std of Reward: 0.282. Training.

    While in build it says
    No episode etc ... which makes sense since enviroment isent reset or ? even starting ?


    Edit
    nvidia-smi
    CUDA Version: 11.5 ? // I thought I had 10 - dont higher version have problems ?

    ---

    Here is a link to the zipped up project
    https://ufile.io/p5rq8xz7 ( woah 1MB/s )
    if you know any better mirrors please reply.
     
    Last edited: Dec 21, 2021
    namuh likes this.
  2. TimHogklint

    TimHogklint

    Joined:
    Nov 24, 2017
    Posts:
    40
  3. namuh

    namuh

    Joined:
    Nov 20, 2016
    Posts:
    23
    Did you try building in debug mode?
    Or maybe the MaxStep Field is getting set to 0 after build? That causes infinite episodes.
    The project finally downloaded. I'll post back here if with what I find.
     
  4. TimHogklint

    TimHogklint

    Joined:
    Nov 24, 2017
    Posts:
    40
    I will try to build in debug mode once I get home ! MaxStep Field is indeed 0 but I always kept it like that and defined maxsteps in configuration file.

    Thank you for taking time out of your day to help me !
     
    namuh likes this.
  5. namuh

    namuh

    Joined:
    Nov 20, 2016
    Posts:
    23
    Hi again TimHogklint.

    I tested your environment on my machine and, on my pc at least, the build version does not even connect to the
    trainer script. The environment has a critical error as shown in the fig below on the first run.
    The Agent Script Fails to initialize properly and just crashes.

    The Agent script crashes right at Start()
    This maybe why your agent seems to not end episodes. The agent never even runs.

    Here is the error:
    NullReferenceException: Object reference not set to an instance of an object
    at BalanceAgent.Start () [0x0043e] in C:\Users\\Downloads\BipedalBalancer\BalancerAlbatross\Assets\Scripts\BalanceAgent.cs:312

    You can see the debug file yourself if you make a Development build.

    I'm not sure what causes this. Maybe I'll investigate if I get more time. Hope this helped.

    upload_2021-12-22_22-7-31.png
     
  6. TimHogklint

    TimHogklint

    Joined:
    Nov 24, 2017
    Posts:
    40
    I feel like such a dumb person for not testing building in debug - I guess cause I dont know how to use it - I will look it up ! Thank you so much - anything helps !
     
  7. namuh

    namuh

    Joined:
    Nov 20, 2016
    Posts:
    23
    Welcome :)
    Hope you can figure out what the problem is.
    Best of luck!
     
    TimHogklint likes this.
  8. TimHogklint

    TimHogklint

    Joined:
    Nov 24, 2017
    Posts:
    40
    It has been resolved ! Thanks to you namuh !

    Apparently my sinewave targets became null at sometime during the simulation. I still dont know why - however a quick nullcheck and setting sinepoints to last valid point works

    Sinetargets are set in inspector - and they were and correctly and plugged in. But I think the sinewave function might put them at impossible positions that make the transform null ?

    To be honest I just dont know - they look fine and do what I want in build and editor now.

    Thanks again namuh - Happy holidays and new year !
     
  9. namuh

    namuh

    Joined:
    Nov 20, 2016
    Posts:
    23
    I'm glad I could help.
    Merry Christmas!
     
    TimHogklint likes this.