当前位置:网站首页>【已解决】“The Unity environment took too long to respond. Make sure that :\n“

【已解决】“The Unity environment took too long to respond. Make sure that :\n“

2022-06-23 04:43:00 Bungehurst

运行环境

  • Anaconda 4.12.0
  • Python 3.6.13
  • Pytorch 1.10.2
  • Ray 1.10.0
  • mlagents 0.28.0
  • mpi4py 3.0.3

问题描述

在运行多进程并行训练时,Unity会有如下报错,此时程序卡死

"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' Behavior Parameters > Behavior Type is set to "Default" The environment and the Python interface have compatible versions. If you're running on a headless server without graphics support, turn off display by either passing --no-graphics option or build your Unity executable as server build.

怀疑有可能是没有关闭图形造成的.

解决方案

修改unity3d_env.py文件,目录在:anaconda3/envs/<env_name>/lib/python3.6/site-packages/ray/rllib/env/wrappers/unity3d_env.py.

 def __init__(self,
                 file_name: str = None,
                 port: Optional[int] = None,
                 seed: int = 0,
                 no_graphics: bool = True,
                 timeout_wait: int = 500,
                 episode_horizon: int = 1000):
  • 修改no_graphicsno_graphics: bool = True,关闭图形输出
  • 修改timeout_wait,适当增加超时等待时间
原网站

版权声明
本文为[Bungehurst]所创,转载请带上原文链接,感谢
https://lun55423.blog.csdn.net/article/details/125376961