opendilab / DI-engine

OpenDILab Decision AI Engine. The Most Comprehensive Reinforcement Learning Framework B.P.
https://di-engine-docs.readthedocs.io
Apache License 2.0
3k stars 365 forks source link

[Error] AttributeError: 'InteractionSerialEvaluator' object has no attribute '_end_flag' #334

Closed mahuangxu closed 2 years ago

mahuangxu commented 2 years ago

When running the basic example: python3 -u dizoo/classic_control/cartpole/entry/cartpole_dqn_main.py It shows the following error.

Traceback (most recent call last):
  File "C:/ProgramData/Anaconda3/envs/PYTORCH/Lib/site-packages/dizoo/classic_control/cartpole/entry/cartpole_dqn_main.py", line 91, in <module>
    main(cartpole_dqn_config)
  File "C:/ProgramData/Anaconda3/envs/PYTORCH/Lib/site-packages/dizoo/classic_control/cartpole/entry/cartpole_dqn_main.py", line 84, in main
    evaluator = InteractionSerialEvaluator(
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\ding\worker\collector\interaction_serial_evaluator.py", line 56, in __init__
    self.reset(policy, env)
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\ding\worker\collector\interaction_serial_evaluator.py", line 112, in reset
    self.reset_env(_env)
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\ding\worker\collector\interaction_serial_evaluator.py", line 76, in reset_env
    self._env.launch()
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\ding\envs\env_manager\base_env_manager.py", line 199, in launch
[2022-05-22 16:15:02] ERROR    Env 0 reset has exceeded max retries(1)                                                                             base_env_manager.py:274
    self.reset(reset_param)
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\ding\envs\env_manager\base_env_manager.py", line 242, in reset
    self._reset(env_id)
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\ding\envs\env_manager\base_env_manager.py", line 281, in _reset
    raise runtime_error
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\ding\envs\env_manager\base_env_manager.py", line 259, in _reset
    obs = reset_fn()
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\ding\envs\env_manager\base_env_manager.py", line 251, in reset_fn
    return self._envs[env_id].reset(**self._reset_param[env_id])
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\ding\envs\env\ding_env_wrapper.py", line 68, in reset
    obs = self._env.reset()
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\gym\wrappers\record_video.py", line 58, in reset
    self.start_video_recorder()
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\gym\wrappers\record_video.py", line 75, in start_video_recorder
    self.video_recorder.capture_frame()
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\gym\wrappers\monitoring\video_recorder.py", line 155, in capture_frame
    self._encode_image_frame(frame)
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\gym\wrappers\monitoring\video_recorder.py", line 213, in _encode_image_frame
    self.encoder = ImageEncoder(
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\gym\wrappers\monitoring\video_recorder.py", line 337, in __init__
    raise error.DependencyNotInstalled(
RuntimeError: Env 0 reset has exceeded max retries(1), and the latest exception is: DependencyNotInstalled("Found neither the ffmpeg nor avconv executables. On OS X, you can install ffmpeg via `brew install ffmpeg`. On most Ubuntu variants, `sudo apt-get install ffmpeg` should do it. On Ubuntu 14.04, however, you'll need to install avconv with `sudo apt-get install libav-tools`.")
Exception ignored in: <function InteractionSerialEvaluator.__del__ at 0x0000017CA3252280>
Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\ding\worker\collector\interaction_serial_evaluator.py", line 138, in __del__
  File "C:\ProgramData\Anaconda3\envs\PYTORCH\lib\site-packages\ding\worker\collector\interaction_serial_evaluator.py", line 125, in close
AttributeError: 'InteractionSerialEvaluator' object has no attribute '_end_flag'

Process finished with exit code 1
PaParaZz1 commented 2 years ago

There is already some hints in you error messages: Found neither the ffmpeg nor avconv executables.

This bug is because your setting doesn't install ffmpeg, which is used to save replay video when evaluation, and there are 2 solutions:

beijiguang94 commented 2 years ago

There is already some hints in you error messages: Found neither the ffmpeg nor avconv executables.

This bug is because your setting doesn't install ffmpeg, which is used to save replay video when evaluation, and there are 2 solutions:

  • install ffmpeg, but it may be a lit hard in win32 system.
  • comment the code part related to save replay video, for example, just comment the code related to enable_save_replay

I also met the above error on Windows 10 64 bit. Then I tried pip install ffmpeg, but it didn't work. After searching on the Internet, an effective resolution is to download ffmpeg here with a correct version, unzip it and then add the 'bin' directory path to the system variable. To verify it, use ffmpeg -version.