Trying Build And Run Project with already trained Ml Agent

I have a problem with running a project, which contains an Already Trained ML Agent. When I run the EXE file the game starts but the Agent just stays there and its not trying to complete its goal. In the Editor everything is fine. When I press the play button the agent with already attached trained brain starts to fulfil its goal and it works perfectly. I would like to use this Trained Agent in a future game. Thanks in Advanced for your help !

Hi, thanks for reaching out. Can you supply some additional information to help us narrow the problem down?

  • Is this is one of the example environments or in your own custom environment? If your own then can you roughly describe what you are training the agent to do?
  • What version of mlagents are you using?
  • What version of unity are you using?
  • What platform (Mac, PC, Linux) are you developing on?

Thanks so much for your interest :)

@henrypeteet Hello :) . I am training my own agent. Its should always try to reach the green square, to jump over the white wall and to avoid going down to the Red Dead zone. I am currently working on MAC and Im using the latest versions of Unity 2020 and the latest Preview of ML Agent - 1.4.0. On the Editor everything is fine. When I add trained brain to the bunny its performing very well and it reaches its goal 95-99% of the time. When I perform training in external window it also goes really well, beside the problem with the very little initial window size. However, when I decide to Build And Run the scene, Run it outside of the Unity Editor not for training, but for seeing how well it does when its already trained, the Agent stays without moving. Its like it does not have any attached logic - like when you run scene, but without any script that should apply the actions.

The picture below has taken when the bunny is using its trained brain and tries to achieve its goal


Thanks for the explanation and screenshot.

If you set the Behavior Parameters --> Behavior Type to "Inference Only" and click play in the editor do you get the same bad result? If the agent doesn't reflect the trained behavior then it is likely you have the wrong neural net dragged onto your Behavior Parameters --> Model. Make sure to drag the item from your results// onto that field.

If this is not the issue then did you happen to adjust the engine's timescale value?

If neither of these help this would likely be categorized as a bug and we would want to file it on the GitHub page.

Hello @henrypeteet . Thanks for the suggestions. In the editor in inference mode everything is fine. I will ty to play with the timescale and i will share with you some results. In fact, when I click play in the Editor everything works really good. When the behaviour in inference and the nn file is attached also everything works great.
This is the behaviour of my agent with other two components - Model Overrider and Decision Requester. Thanks again for your help. I will experiment with the timescale and I will share with you some results.

6377778--710268--Screenshot 2020-10-03 at 8.44.41.png

@henrypeteet There is an Error. I saw it when I build Debug build. I am posting an image, some logs and my build settings. I did not change the timescale and I have tried both with and without 'ENABLE_TENSORFLOW' and it all remains the same. It looks like it can not find a DllFile. I will do some investigation

DllNotFoundException: macblas
  at (wrapper managed-to-native) Unity.Barracuda.MacBLAS.macsgemm(single*,int,int,single*,int,int,single*,int,int,int,bool,bool)
  at Unity.Barracuda.MacBLAS.SGEMM (System.Single* Ap, System.Int32 AN, System.Int32 AM, System.Single* Bp, System.Int32 BN, System.Int32 BM, System.Single* Cp, System.Int32 CN, System.Int32 CM, System.Int32 bs, System.Boolean transposeA, System.Boolean transposeB) [0x00001] in /Users/ivaylodimitrov/Desktop/Unity3D/SeekGoalMLAgent/Library/PackageCache/com.unity.barracuda@1.1.1-preview/Barracuda/Runtime/Plugins/OSX/MacBLAS.cs:39
  at Unity.Barracuda.UnsafeArrayCPUOps.Dense (Unity.Barracuda.Tensor X, Unity.Barracuda.Tensor W, Unity.Barracuda.Tensor B, Unity.Barracuda.Layer+FusedActivation fusedActivation) [0x00132] in /Users/ivaylodimitrov/Desktop/Unity3D/SeekGoalMLAgent/Library/PackageCache/com.unity.barracuda@1.1.1-preview/Barracuda/Runtime/Core/Backends/BarracudaUnsafeArrayCPU.cs:1255
  at Unity.Barracuda.GenericWorker+<StartManualSchedule>d__29.MoveNext () [0x002ed] in /Users/ivaylodimitrov/Desktop/Unity3D/SeekGoalMLAgent/Library/PackageCache/com.unity.barracuda@1.1.1-preview/Barracuda/Runtime/Core/Backends/GenericWorker.cs:203
  at Unity.Barracuda.GenericWorker.Execute () [0x0000c] in /Users/ivaylodimitrov/Desktop/Unity3D/SeekGoalMLAgent/Library/PackageCache/com.unity.barracuda@1.1.1-preview/Barracuda/Runtime/Core/Backends/GenericWorker.cs:118
  at Unity.Barracuda.GenericWorker.Execute (System.Collections.Generic.IDictionary`2[TKey,TValue] inputs) [0x0003c] in /Users/ivaylodimitrov/Desktop/Unity3D/SeekGoalMLAgent/Library/PackageCache/com.unity.barracuda@1.1.1-preview/Barracuda/Runtime/Core/Backends/GenericWorker.cs:106
  at Unity.MLAgents.Inference.ModelRunner.DecideBatch () [0x000f4] in /Users/ivaylodimitrov/Desktop/Unity3D/SeekGoalMLAgent/Library/PackageCache/
  at Unity.MLAgents.Policies.BarracudaPolicy.DecideAction () [0x00001] in /Users/ivaylodimitrov/Desktop/Unity3D/SeekGoalMLAgent/Library/PackageCache/
  at Unity.MLAgents.Agent.DecideAction () [0x0002c] in /Users/ivaylodimitrov/Desktop/Unity3D/SeekGoalMLAgent/Library/PackageCache/
  at (wrapper delegate-invoke) <Module>.invoke_void()
  at Unity.MLAgents.Academy.EnvironmentStep () [0x000bd] in /Users/ivaylodimitrov/Desktop/Unity3D/SeekGoalMLAgent/Library/PackageCache/
  at Unity.MLAgents.AcademyFixedUpdateStepper.FixedUpdate () [0x00001] in /Users/ivaylodimitrov/Desktop/Unity3D/SeekGoalMLAgent/Library/PackageCache/

(Filename: /Users/ivaylodimitrov/Desktop/Unity3D/SeekGoalMLAgent/Library/PackageCache/com.unity.barracuda@1.1.1-preview/Barracuda/Runtime/Plugins/OSX/MacBLAS.cs Line: 39)

6377907--710295--Screenshot 2020-10-03 at 9.10.38.jpg
6377907--710301--Screenshot 2020-10-03 at 10.14.14.png
6377907--710304--Screenshot 2020-10-03 at 10.17.36.png

Thanks for the updates.

Hmm, does the resolution in help at all with the last bug?

With regards to the overall problem is there a reason you need the Model Overrider, if you want to use the model from the game you shouldn't need it IIUC? If you just remove it or disable it does inference in the built executable work?

@henrypeteet Thanks ! No, the suggested issue is connected to the main Unity Repository. My project is separated. However, thanks to your suggestion to read the upper thread in GitHub I was able to fix my own problem. Here are two images. The problem was The Build Architecture - it seems that the Intel 64 Works Great for me. Its Perfect ! But previosly I was using Intel 64 + Apple silicon. I am not an expert in this but it seems that MAC OS build architectures have something to do with how the OS after build and run deals with the produced Application. Unfortunately, the produced build for MAC OS is a single Application file and does not give me much information. If I can help with anything for investigating why Intel 64 + Apple Silicon architecture causes this problem, feel free to contact me :) . Thanks for the support. Kind Regards and Great Job with the Ml Agent. I like it a lot ! Have a Great One ! :)

6391329--712560--Screenshot 2020-10-07 at 9.47.35.png
6391329--712563--Screenshot 2020-10-07 at 9.49.26.png

Glad it worked out. Thanks.