tf_agents 下 mujoco_py 报错 CompileError 解决记录
摘要:
最近强化学习需要用到 tf-agents ,记录一下使用过程遇到的问题。
版本说明:
tensorflow 2.14.0 gym 0.23.0 tf-agents 0.17.0 numpy 1.24.0 ale-py 0.8.1
报错1:
File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/mujoco_py/builder.py", line 149, in build_extensions build_ext.build_extensions(self) File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions _build_ext.build_ext.build_extensions(self) File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 467, in build_extensions self._build_extensions_serial() File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 493, in _build_extensions_serial self.build_extension(ext) File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 548, in build_extension objects = self.compiler.compile( File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/setuptools/_distutils/ccompiler.py", line 600, in compile self._compile(obj, src, ext, cc_args, extra_postargs, pp_opts) File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/setuptools/_distutils/unixccompiler.py", line 187, in _compile raise CompileError(msg) distutils.errors.CompileError: command '/usr/bin/gcc' failed with exit code 1
解决方案:
该原因是因为使用 pip 安装了 mujoco 和 mujoco_py , 应该从 github 上手动下载并创建目录,这里参考 https://blog.csdn.net/qq_47997583/article/details/125400418 即可。注意要先 pip 卸载掉 mujoco 和 mujoco_py 否则会冲突
报错2:
File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/ale_py/env/gym.py", line 155, in __init__ self.seed() File "/home/ys/.conda/envs/gaoshd_tf/lib/python3.9/site-packages/ale_py/env/gym.py", line 206, in seed raise error.Error( gym.error.Error: We're Unable to find the game "Breakout". Note: Gym no longer distributes ROMs.
If you own a license to use the necessary ROMs for research purposes you can download them via `pip install gym[accept-rom-license]`.
Otherwise, you should try importing "Breakout" via the command `ale-import-roms`. If you believe this is a mistake perhaps your copy of
"Breakout" is unsupported. To check if this is the case try providing the environment variable `PYTHONWARNINGS=default::ImportWarning:ale_py.roms`.
For more information see: https://github.com/mgbellemare/Arcade-Learning-Environment#rom-management
解决方案:
按照报错提示
`pip install gym[accept-rom-license]` 即可,安装后执别忘了执行 AutoROM