Unity-Technologies / ml-agents

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
https://unity.com/products/machine-learning-agents
Other
17.19k stars 4.16k forks source link

Cannot load environment in gym-unity #3247

Closed sahandrez closed 4 years ago

sahandrez commented 4 years ago

Hello,

I am following the notebooks here with a single agent 3DBall built environment on Windows 10. I was able to successfully run the notebook without the Gym environment and everything seems to be fine. However, when using gym-unity wrapper, the code gets stuck on initializing the environment in the line env = UnityEnv(env_name, worker_id=0, use_visual=False) with the following timeout exception:

UnityTimeOutException                     Traceback (most recent call last)
<ipython-input-20-26d9d3b4397d> in <module>
      1 env_name = "./built_envs/3DBall_Single/3DBall_Single.exe"  # Name of the Unity environment binary to launch
----> 2 env = UnityEnv(env_name, worker_id=5006, use_visual=False, multiagent=False)
      3 
      4 # Examine environment parameters
      5 print(str(env))

c:\users\srezaeishoshtari\workspace\ml-agents\gym-unity\gym_unity\envs\__init__.py in __init__(self, environment_filename, worker_id, use_visual, uint8_visual, multiagent, flatten_branched, no_graphics, allow_multiple_visual_obs)
     59         """
     60         self._env = UnityEnvironment(
---> 61             environment_filename, worker_id, no_graphics=no_graphics
     62         )
     63 

c:\users\srezaeishoshtari\workspace\ml-agents\ml-agents-envs\mlagents_envs\environment.py in __init__(self, file_name, worker_id, base_port, seed, docker_training, no_graphics, timeout_wait, args, side_channels)
    123         rl_init_parameters_in = UnityRLInitializationInputProto(seed=seed)
    124         try:
--> 125             aca_output = self.send_academy_parameters(rl_init_parameters_in)
    126             aca_params = aca_output.rl_initialization_output
    127         except UnityTimeOutException:

c:\users\srezaeishoshtari\workspace\ml-agents\ml-agents-envs\mlagents_envs\environment.py in send_academy_parameters(self, init_parameters)
    510         inputs = UnityInputProto()
    511         inputs.rl_initialization_input.CopyFrom(init_parameters)
--> 512         return self.communicator.initialize(inputs)
    513 
    514     @staticmethod

c:\users\srezaeishoshtari\workspace\ml-agents\ml-agents-envs\mlagents_envs\rpc_communicator.py in initialize(self, inputs)
     99 
    100     def initialize(self, inputs: UnityInputProto) -> UnityOutputProto:
--> 101         self.poll_for_timeout()
    102         aca_param = self.unity_to_external.parent_conn.recv().unity_output
    103         message = UnityMessageProto()

c:\users\srezaeishoshtari\workspace\ml-agents\ml-agents-envs\mlagents_envs\rpc_communicator.py in poll_for_timeout(self)
     92         if not self.unity_to_external.parent_conn.poll(self.timeout_wait):
     93             raise UnityTimeOutException(
---> 94                 "The Unity environment took too long to respond. Make sure that :\n"
     95                 "\t The environment does not need user interaction to launch\n"
     96                 "\t The Agents are linked to the appropriate Brains\n"

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.

Note that I am using the same executable with a single agent unity environment. Am I missing something? These are the versions of the packages: mlagents==0.13 gym==0.15.4

Thanks!

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.