Search Unity

  1. Looking for a job or to hire someone for a project? Check out the re-opened job forums.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Cant connect to trainer on port 5004

Discussion in 'ML-Agents' started by wwaero, Mar 12, 2020.

  1. wwaero

    wwaero

    Joined:
    Feb 18, 2020
    Posts:
    38
    It appears I've updated to 14.1 but I'm still unable to connect by pressing play in the editor.

    Couldn't connect to trainer on port 5004 using API version API-14. Will perform inference instead.
    UnityEngine.Debug:Log(Object)
    MLAgents.Academy:InitializeEnvironment() (at D:/Documents/GitHub/ml-agents/com.unity.ml-agents/Runtime/Academy.cs:286)
    MLAgents.Academy:LazyInitialization() (at D:/Documents/GitHub/ml-agents/com.unity.ml-agents/Runtime/Academy.cs:161)
    MLAgents.Academy:.ctor() (at D:/Documents/GitHub/ml-agents/com.unity.ml-agents/Runtime/Academy.cs:150)
    MLAgents.<>c:<.cctor>b__59_0() (at D:/Documents/GitHub/ml-agents/com.unity.ml-agents/Runtime/Academy.cs:56)
    System.Lazy`1:get_Value()
    MLAgents.Academy:get_Instance() (at D:/Documents/GitHub/ml-agents/com.unity.ml-agents/Runtime/Academy.cs:63)
    MLAgents.Agent:LazyInitialize() (at D:/Documents/GitHub/ml-agents/com.unity.ml-agents/Runtime/Agent.cs:244)
    MLAgents.Agent:OnEnable() (at D:/Documents/GitHub/ml-agents/com.unity.ml-agents/Runtime/Agent.cs:201)


    D:\Documents\GitHub\ml-agents>mlagents-learn config/trainer_config.yaml --run-id=orbit_0 --train
    WARNING:tensorflow:From c:\users\ww\appdata\local\continuum\anaconda3\envs\ml-agents-14-1\lib\site-packages\tensorflow_core\python\compat\v2_compat.py:65: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
    Instructions for updating:
    non-resource variables are not supported in the long term
    ▄▄▄▓▓▓▓
    ╓▓▓▓▓▓▓█▓▓▓▓▓
    ,▄▄▄m▀▀▀' ,▓▓▓▀▓▓▄ ▓▓▓ ▓▓▌
    ▄▓▓▓▀' ▄▓▓▀ ▓▓▓ ▄▄ ▄▄ ,▄▄ ▄▄▄▄ ,▄▄ ▄▓▓▌▄ ▄▄▄ ,▄▄
    ▄▓▓▓▀ ▄▓▓▀ ▐▓▓▌ ▓▓▌ ▐▓▓ ▐▓▓▓▀▀▀▓▓▌ ▓▓▓ ▀▓▓▌▀ ^▓▓▌ ╒▓▓▌
    ▄▓▓▓▓▓▄▄▄▄▄▄▄▄▓▓▓ ▓▀ ▓▓▌ ▐▓▓ ▐▓▓ ▓▓▓ ▓▓▓ ▓▓▌ ▐▓▓▄ ▓▓▌
    ▀▓▓▓▓▀▀▀▀▀▀▀▀▀▀▓▓▄ ▓▓ ▓▓▌ ▐▓▓ ▐▓▓ ▓▓▓ ▓▓▓ ▓▓▌ ▐▓▓▐▓▓
    ^█▓▓▓ ▀▓▓▄ ▐▓▓▌ ▓▓▓▓▄▓▓▓▓ ▐▓▓ ▓▓▓ ▓▓▓ ▓▓▓▄ ▓▓▓▓`
    '▀▓▓▓▄ ^▓▓▓ ▓▓▓ └▀▀▀▀ ▀▀ ^▀▀ `▀▀ `▀▀ '▀▀ ▐▓▓▌
    ▀▀▀▀▓▄▄▄ ▓▓▓▓▓▓, ▓▓▓▓▀
    `▀█▓▓▓▓▓▓▓▓▓▌
    ¬`▀▀▀█▓
    Version information:
    ml-agents: 0.14.1,
    ml-agents-envs: 0.14.1,
    Communicator API: API-14,
    TensorFlow: 2.0.1
    WARNING:tensorflow:From c:\users\ww\appdata\local\continuum\anaconda3\envs\ml-agents-14-1\lib\site-packages\tensorflow_core\python\compat\v2_compat.py:65: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
    Instructions for updating:
    non-resource variables are not supported in the long term
    INFO:mlagents_envs:Listening on port 5004. Start training by pressing the Play button in the Unity Editor.
    Process Process-1:
    Traceback (most recent call last):
    File "c:\users\ww\appdata\local\continuum\anaconda3\envs\ml-agents-14-1\lib\multiprocessing\process.py", line 258, in _bootstrap
    self.run()
    File "c:\users\ww\appdata\local\continuum\anaconda3\envs\ml-agents-14-1\lib\multiprocessing\process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
    File "c:\users\ww\appdata\local\continuum\anaconda3\envs\ml-agents-14-1\lib\site-packages\mlagents\trainers\subprocess_env_manager.py", line 97, in worker
    worker_id, [shared_float_properties, engine_configuration_channel]
    File "c:\users\ww\appdata\local\continuum\anaconda3\envs\ml-agents-14-1\lib\site-packages\mlagents\trainers\learn.py", line 425, in create_unity_environment
    side_channels=side_channels,
    File "c:\users\ww\appdata\local\continuum\anaconda3\envs\ml-agents-14-1\lib\site-packages\mlagents_envs\environment.py", line 124, in __init__
    aca_output = self.send_academy_parameters(rl_init_parameters_in)
    File "c:\users\ww\appdata\local\continuum\anaconda3\envs\ml-agents-14-1\lib\site-packages\mlagents_envs\environment.py", line 511, in send_academy_parameters
    return self.communicator.initialize(inputs)
    File "c:\users\ww\appdata\local\continuum\anaconda3\envs\ml-agents-14-1\lib\site-packages\mlagents_envs\rpc_communicator.py", line 101, in initialize
    self.poll_for_timeout()
    File "c:\users\ww\appdata\local\continuum\anaconda3\envs\ml-agents-14-1\lib\site-packages\mlagents_envs\rpc_communicator.py", line 94, in poll_for_timeout
    "The Unity environment took too long to respond. Make sure that :\n"
    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 are linked to the appropriate Brains
    The environment and the Python interface have compatible versions.
    INFO:mlagents.trainers:Learning was interrupted. Please wait while the graph is generated.
    INFO:mlagents.trainers:Saved Model
     
  2. wwaero

    wwaero

    Joined:
    Feb 18, 2020
    Posts:
    38
    Looks like having the proxy environment variables set was blocking communication.
     
  3. Xinzz

    Xinzz

    Joined:
    Jun 28, 2015
    Posts:
    67
    Do you solve this? having same issues here
     
  4. KD_MASS

    KD_MASS

    Joined:
    Oct 8, 2019
    Posts:
    1
    Any luck on this issue guys? I'm having the same trouble... Think the issue is on the Unity side of things.

    Couldn't connect to trainer on port 5004 using API version 0.15.0. Will perform inference instead.
    UnityEngine.Debug:Log(Object)

    MLAgents.Academy:InitializeEnvironment() (at C:/Users/KD/Desktop/ML-Agents/ml-agents-0.15.1/com.unity.ml-agents/Runtime/Academy.cs:353)
    MLAgents.Academy:LazyInitialize() (at C:/Users/KD/Desktop/ML-Agents/ml-agents-0.15.1/com.unity.ml-agents/Runtime/Academy.cs:195)
    MLAgents.Academy:.ctor() (at C:/Users/KD/Desktop/ML-Agents/ml-agents-0.15.1/com.unity.ml-agents/Runtime/Academy.cs:183)
    MLAgents.<>c:<.cctor>b__70_0() (at C:/Users/KD/Desktop/ML-Agents/ml-agents-0.15.1/com.unity.ml-agents/Runtime/Academy.cs:74)
    System.Lazy`1:get_Value()
    MLAgents.Academy:get_Instance() (at C:/Users/KD/Desktop/ML-Agents/ml-agents-0.15.1/com.unity.ml-agents/Runtime/Academy.cs:87)
    MLAgents.Agent:LazyInitialize() (at C:/Users/KD/Desktop/ML-Agents/ml-agents-0.15.1/com.unity.ml-agents/Runtime/Agent.cs:253)
    MLAgents.Agent:OnEnable() (at C:/Users/KD/Desktop/ML-Agents/ml-agents-0.15.1/com.unity.ml-agents/Runtime/Agent.cs:203)
     
  5. nmtrox

    nmtrox

    Joined:
    Apr 5, 2020
    Posts:
    2
    I am having the same issue. Any suggestions?
     
  6. Xinzz

    Xinzz

    Joined:
    Jun 28, 2015
    Posts:
    67
    Use 0.14.1 instead.
     
  7. kazurati

    kazurati

    Joined:
    Mar 22, 2019
    Posts:
    8
    Hi,
    I have the same problem.

    I have tried both versions 0.14.1 and 0.15.1 also. However, the result was the same.

    On Windows, it will start training properly, but on MAC, it will show "Couldn't connect to trainer on port 5004 using API version 0.15.0 or 0.14.1".

    Somebody help me.
     
  8. kazurati

    kazurati

    Joined:
    Mar 22, 2019
    Posts:
    8
    I solved it on my own.

    In my case, the firewall seemed to be getting in the way!
     
  9. QuickTitan

    QuickTitan

    Joined:
    Apr 10, 2016
    Posts:
    1
    Hey!
    Can you tell me how you fixed it in the firewall? What have you done exactly?
     
  10. kazurati

    kazurati

    Joined:
    Mar 22, 2019
    Posts:
    8
    I use my own installed security software, I just turned off the firewall from that software's settings. The security software used is different for each person, so you can try to find the cause by turning off your security software in turn.
     
  11. edogandursun

    edogandursun

    Joined:
    May 15, 2020
    Posts:
    1
    I have tried nearly everything but it is still not working..



    -Mac OSX : 10.15.4 (Catalina)
    -OSX Firewall has been deactivated.
    -Tried local installation as well as cloning and using pip.
    -Tried conda environments as well as classic python venv's.
    -Tried restarting the application and importing the packages multiple times after deactivating firewall and also after restarting terminal and communicator API.
    -Tried release-2, release-1, v0.15.1, v0.15.0, v0.14.1, v0.14.0
    -mlagents properly installed.
    -tensorboard properly installed.

    I have read all the documentation but it is still not working on my mac. I feel really sorry about it.

    It would be nice if I could get some help.



    Traceback of running communicator API before the above screen.

     
  12. MrWetsnow

    MrWetsnow

    Joined:
    Jan 5, 2020
    Posts:
    60
    For the specific error you are getting in the terminal, either provide a different run ID, or add the --force flag to overwrite your existing one.
     
  13. erki338

    erki338

    Joined:
    May 12, 2019
    Posts:
    3
    same problem........
     
  14. erki338

    erki338

    Joined:
    May 12, 2019
    Posts:
    3
    i have 2 pc-s i did exactly same programm with both computers. on my main computer it didnt work and other one didnt have any problems
     
  15. alvaro_unity903

    alvaro_unity903

    Joined:
    Jan 20, 2020
    Posts:
    21
    Same problem. I tried opening the port in the firewall with no success.
     
  16. surajitsaikia27

    surajitsaikia27

    Joined:
    Nov 7, 2020
    Posts:
    3
    Did anyone solved this issue? I am new to Unity and don't know how to solve this one
     
  17. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,238
    I'll flag this for the team to have a look.
     
  18. bunichiroh

    bunichiroh

    Joined:
    Sep 12, 2018
    Posts:
    2
    Same problem. I'm using ml-agents 0.17.0 with Anaconda 1.10.0. I needed downgrade numpy from 1.19.4 to 1.19.3 due to numpy problem to start learning. I've opened 5004 port in my local firewall but my unity says "Couldn't connect to trainer on port 5004 using API version 1.0.0. Will perform inference instead.". I can connect the port with "telnet localhost 5004" in my console. I need any helps. Thanks in advance.
     
    netanel117 likes this.
  19. ssshammi

    ssshammi

    Joined:
    Nov 26, 2018
    Posts:
    1
    HI please help i need to work on my coursework for Reinforcement learning by 4th i am stuck at configuration.
    Code (CSharp):
    1. Couldn't connect to trainer on port 5004 using API version 1.3.0. Will perform inference instead.
    2. UnityEngine.Debug:Log(Object)
    3. Unity.MLAgents.Academy:InitializeEnvironment() (at /Users/shammiseth/Projects/MLagents/mlagents/com.unity.ml-agents/Runtime/Academy.cs:447)
    4. Unity.MLAgents.Academy:LazyInitialize() (at /Users/shammiseth/Projects/MLagents/mlagents/com.unity.ml-agents/Runtime/Academy.cs:271)
    5. Unity.MLAgents.Academy:.ctor() (at /Users/shammiseth/Projects/MLagents/mlagents/com.unity.ml-agents/Runtime/Academy.cs:240)
    6. Unity.MLAgents.<>c:<.cctor>b__83_0() (at /Users/shammiseth/Projects/MLagents/mlagents/com.unity.ml-agents/Runtime/Academy.cs:109)
    7. System.Lazy`1:get_Value()
    8. Unity.MLAgents.Academy:get_Instance() (at /Users/shammiseth/Projects/MLagents/mlagents/com.unity.ml-agents/Runtime/Academy.cs:124)
    9. Unity.MLAgents.DecisionRequester:Awake() (at /Users/shammiseth/Projects/MLagents/mlagents/com.unity.ml-agents/Runtime/DecisionRequester.cs:49)
    I am not able to connect to post 5004 and the Firewall is off. How to i check what's blocking it. I get a popup everything i play in unity.
    ibgrpc_csharp_ext.x64.bundle” cannot be opened because the developer cannot be verified. Help please!
     

    Attached Files:

  20. ervteng_unity

    ervteng_unity

    Unity Technologies

    Joined:
    Dec 6, 2018
    Posts:
    99
  21. Octopal

    Octopal

    Joined:
    Nov 27, 2016
    Posts:
    7
    For some, it could be that their agents do not have the Decision Requester component attached, omitting it will produce the same log.
     
unityunity