Ml-agents: Can't communicate with external (python)

Created on 5 Nov 2019  ยท  2Comments  ยท  Source: Unity-Technologies/ml-agents

Error: UnityAgentsException: The Communicator was unable to connect. Please make sure the External process is ready to accept communication with Unity.

Conda is activated and waiting for unity editor, to hit the play button.
By hiting the play in the unity editor, after a 2,3 second delay, the mentioned error pops up in the unity editor.

in conda enviroment:
tensorflow installed, version 1.7.1
python version is 3.6.9

and I've downloaded the last ml-agents-master from github and I'm working with that.
The command I'm using for setting up the python is:
mlagents-learn config/trainer_config.yaml --run-id=firstRun --train

I can run unity with the previously generated models for brains with no problem (by assigning models from the Unity SDK folder/examples).
But when I want to train the model in unity, I do the following:
1- Make sure there is no model for brain
2-Check the control in Academy (because when control is unchecked, errors are there and it's not about the connections to the python environment whatsoever, like:
No model was present for the Brain 3DBallHardLearning. or
An item with the same key has already been added. Key: Agent (Ball3DHardAgent))

And the error at the begning of this post is produced.

And when I go with executable manner, this is the output I get:

(ml-agents) F:\Projects\AI\ml-agents-master>mlagents-learn config\trainer_config.yaml --env=TestMlAgents\TestMlAgents --run-id=firstRun --train
c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\tensorflow\python\framework\dtypes.py:517: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint8 = np.dtype([("qint8", np.int8, 1)])
c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\tensorflow\python\framework\dtypes.py:518: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint8 = np.dtype([("quint8", np.uint8, 1)])
c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\tensorflow\python\framework\dtypes.py:519: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint16 = np.dtype([("qint16", np.int16, 1)])
c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\tensorflow\python\framework\dtypes.py:520: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_quint16 = np.dtype([("quint16", np.uint16, 1)])
c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\tensorflow\python\framework\dtypes.py:521: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  _np_qint32 = np.dtype([("qint32", np.int32, 1)])
c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\tensorflow\python\framework\dtypes.py:526: FutureWarning: Passing (type, 1) or '1type' as a synonym of type is deprecated; in a future version of numpy, it will be understood as (type, (1,)) / '(1,)type'.
  np_resource = np.dtype([("resource", np.ubyte, 1)])


                        โ–„โ–„โ–„โ–“โ–“โ–“โ–“
                   โ•“โ–“โ–“โ–“โ–“โ–“โ–“โ–ˆโ–“โ–“โ–“โ–“โ–“
              ,โ–„โ–„โ–„mโ–€โ–€โ–€'  ,โ–“โ–“โ–“โ–€โ–“โ–“โ–„                           โ–“โ–“โ–“  โ–“โ–“โ–Œ
            โ–„โ–“โ–“โ–“โ–€'      โ–„โ–“โ–“โ–€  โ–“โ–“โ–“      โ–„โ–„     โ–„โ–„ ,โ–„โ–„ โ–„โ–„โ–„โ–„   ,โ–„โ–„ โ–„โ–“โ–“โ–Œโ–„ โ–„โ–„โ–„    ,โ–„โ–„
          โ–„โ–“โ–“โ–“โ–€        โ–„โ–“โ–“โ–€   โ–โ–“โ–“โ–Œ     โ–“โ–“โ–Œ   โ–โ–“โ–“ โ–โ–“โ–“โ–“โ–€โ–€โ–€โ–“โ–“โ–Œ โ–“โ–“โ–“ โ–€โ–“โ–“โ–Œโ–€ ^โ–“โ–“โ–Œ  โ•’โ–“โ–“โ–Œ
        โ–„โ–“โ–“โ–“โ–“โ–“โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–„โ–“โ–“โ–“      โ–“โ–€      โ–“โ–“โ–Œ   โ–โ–“โ–“ โ–โ–“โ–“    โ–“โ–“โ–“ โ–“โ–“โ–“  โ–“โ–“โ–Œ   โ–โ–“โ–“โ–„ โ–“โ–“โ–Œ
        โ–€โ–“โ–“โ–“โ–“โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–€โ–“โ–“โ–„     โ–“โ–“      โ–“โ–“โ–Œ   โ–โ–“โ–“ โ–โ–“โ–“    โ–“โ–“โ–“ โ–“โ–“โ–“  โ–“โ–“โ–Œ    โ–โ–“โ–“โ–โ–“โ–“
          ^โ–ˆโ–“โ–“โ–“        โ–€โ–“โ–“โ–„   โ–โ–“โ–“โ–Œ     โ–“โ–“โ–“โ–“โ–„โ–“โ–“โ–“โ–“ โ–โ–“โ–“    โ–“โ–“โ–“ โ–“โ–“โ–“  โ–“โ–“โ–“โ–„    โ–“โ–“โ–“โ–“`
            'โ–€โ–“โ–“โ–“โ–„      ^โ–“โ–“โ–“  โ–“โ–“โ–“       โ””โ–€โ–€โ–€โ–€ โ–€โ–€ ^โ–€โ–€    `โ–€โ–€ `โ–€โ–€   'โ–€โ–€    โ–โ–“โ–“โ–Œ
               โ–€โ–€โ–€โ–€โ–“โ–„โ–„โ–„   โ–“โ–“โ–“โ–“โ–“โ–“,                                      โ–“โ–“โ–“โ–“โ–€
                   `โ–€โ–ˆโ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–“โ–Œ
                        ยฌ`โ–€โ–€โ–€โ–ˆโ–“


INFO:mlagents.trainers:CommandLineOptions(debug=False, num_runs=1, seed=-1, env_path='TestMlAgents\\TestMlAgents', run_id='firstRun', load_model=False, train_model=True, save_freq=50000, keep_checkpoints=5, base_port=5005, num_envs=1, curriculum_folder=None, lesson=0, slow=False, no_graphics=False, multi_gpu=False, trainer_config_path='config\\trainer_config.yaml', sampler_file_path=None, docker_target_name=None, env_args=None, cpu=False)
INFO:mlagents.envs:Environment timed out shutting down. Killing...
Process Process-1:
Traceback (most recent call last):
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\multiprocessing\process.py", line 258, in _bootstrap
    self.run()
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\multiprocessing\process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\mlagents\envs\subprocess_env_manager.py", line 82, in worker
    env = env_factory(worker_id)
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\mlagents\trainers\learn.py", line 359, in create_unity_environment
    args=env_args,
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\mlagents\envs\environment.py", line 105, in __init__
    aca_output = self.send_academy_parameters(rl_init_parameters_in)
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\mlagents\envs\environment.py", line 689, in send_academy_parameters
    return self.communicator.initialize(inputs)
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\mlagents\envs\rpc_communicator.py", line 88, in initialize
    "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.
Traceback (most recent call last):
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\multiprocessing\connection.py", line 312, in _recv_bytes
    nread, err = ov.GetOverlappedResult(True)
BrokenPipeError: [WinError 109] The pipe has been ended

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\mlagents\envs\subprocess_env_manager.py", line 59, in recv
    response: EnvironmentResponse = self.conn.recv()
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\multiprocessing\connection.py", line 250, in recv
    buf = self._recv_bytes()
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\multiprocessing\connection.py", line 321, in _recv_bytes
    raise EOFError
EOFError

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\Users\smart\Miniconda3\envs\ml-agents\Scripts\mlagents-learn.exe\__main__.py", line 7, in <module>
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\mlagents\trainers\learn.py", line 408, in main
    run_training(0, run_seed, options, Queue())
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\mlagents\trainers\learn.py", line 222, in run_training
    options.sampler_file_path, env.reset_parameters, run_seed
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\mlagents\envs\subprocess_env_manager.py", line 225, in reset_parameters
    return self.env_workers[0].recv().payload
  File "c:\users\smart\miniconda3\envs\ml-agents\lib\site-packages\mlagents\envs\subprocess_env_manager.py", line 62, in recv
    raise UnityCommunicationException("UnityEnvironment worker: recv failed.")
mlagents.envs.exception.UnityCommunicationException: UnityEnvironment worker: recv failed.

(ml-agents) F:\Projects\AI\ml-agents-master>mlagents-learn config\trainer_config.yaml --env=TestMlAgents\TestMlAgents --run-id=firstRun --train
bug

All 2 comments

Hi, can you make sure the python package and the Unity SDK version are all from the 0.11 release? The definition of the gRPC service has changed and is not backwards compatible.

@surfnerd I redownloaded the github root project and now it's working! I think I've used the link provided in the guids & documents previously and allegedly that was an old link.
Thanks It was getting confusing :)

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MarcPilgaard picture MarcPilgaard  ยท  3Comments

GuntherFox picture GuntherFox  ยท  3Comments

mattinjersey picture mattinjersey  ยท  3Comments

gerardsimons picture gerardsimons  ยท  3Comments

MrGitGo picture MrGitGo  ยท  4Comments