Text2Reward学习笔记
1. 环境配置
1.1 安装 PyTorch-1.13.1
pip install torch==1.13.1+cu116 torchvision==0.14.1+cu116 \
torchaudio==0.13.1 --extra-index-url https://download.pytorch.org/whl/cu116
1.2 安装工具库
pip install stable-baselines3==1.8.0 wandb tensorboard \
-i https://pypi.tuna.tsinghua.edu.cn/simple
pip install langchain chromadb==0.4.0 \
-i https://pypi.tuna.tsinghua.edu.cn/simple
2. Troubleshooting
(1)出现错误“mujoco_py/gl/eglshim.c:4:10: fatal error: GL/glew.h: 没有那个文件或目录 4 | #include <GL/glew.h>”
错误信息如下:
>>> import mujoco_py
~/anaconda3/envs/text2reward/lib/python3.7/site-packages/mujoco_py/gl/eglshim.c:4:10: fatal error: GL/glew.h: 没有那个文件或目录
4 | #include <GL/glew.h>
| ^~~~~~~~~~~
compilation terminated.
Traceback (most recent call last):
File "~/anaconda3/envs/text2reward/lib/python3.7/site-packages/setuptools/_distutils/unixccompiler.py", line 186, in _compile
self.spawn(compiler_so + cc_args + [src, '-o', obj] + extra_postargs)
File "~/anaconda3/envs/text2reward/lib/python3.7/site-packages/setuptools/_distutils/ccompiler.py", line 1007, in spawn
spawn(cmd, dry_run=self.dry_run, **kwargs)
File "~/anaconda3/envs/text2reward/lib/python3.7/site-packages/setuptools/_distutils/spawn.py", line 71, in spawn
"command {!r} failed with exit code {}".format(cmd, exitcode)
distutils.errors.DistutilsExecError: command '/usr/bin/gcc' failed with exit code 1
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/anaconda3/envs/text2reward/lib/python3.7/site-packages/mujoco_py/__init__.py", line 2, in <module>
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
... # 中间代码省略
File "~/anaconda3/envs/text2reward/lib/python3.7/site-packages/setuptools/_distutils/unixccompiler.py", line 188, in _compile
raise CompileError(msg)
distutils.errors.CompileError: command '/usr/bin/gcc' failed with exit code 1
由错误信息可以看出,这里其实是缺少GL工具,安装一下即可;
Gemini 2.0 Flash:GLEW(OpenGL Extension Wrangler Library)是一个OpenGL扩展管理库,用来管理和使用 OpenGL的新功能。
Note:
glew
可以尝试用conda安装。
可以参考官方命令;
也可以尝试使用以下命令安装:
sudo apt-get install libglew-dev libosmesa6-dev
(2)出现错误“FileNotFoundError: [Errno 2] No such file or directory: ‘patchelf’: ‘patchelf’”
错误信息如下:
>>> import mujoco_py
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "~/anaconda3/envs/myenv/lib/python3.7/site-packages/mujoco_py/__init__.py", line 2, in <module>
from mujoco_py.builder import cymj, ignore_mujoco_warnings, functions, MujocoException
File "~/anaconda3/envs/myenv/lib/python3.7/site-packages/mujoco_py/builder.py", line 504, in <module>
cymj = load_cython_ext(mujoco_path)
File "~/anaconda3/envs/myenv/lib/python3.7/site-packages/mujoco_py/builder.py", line 110, in load_cython_ext
cext_so_path = builder.build()
File "~/anaconda3/envs/myenv/lib/python3.7/site-packages/mujoco_py/builder.py", line 226, in build
built_so_file_path = self._build_impl()
File "~/anaconda3/envs/myenv/lib/python3.7/site-packages/mujoco_py/builder.py", line 297, in _build_impl
fix_shared_library(so_file_path, 'libOpenGL.so', 'libOpenGL.so.0')
File "~/anaconda3/envs/myenv/lib/python3.7/site-packages/mujoco_py/builder.py", line 154, in fix_shared_library
subprocess.check_call(['patchelf', '--remove-rpath', so_file])
File "~/anaconda3/envs/myenv/lib/python3.7/subprocess.py", line 358, in check_call
retcode = call(*popenargs, **kwargs)
File "~/anaconda3/envs/myenv/lib/python3.7/subprocess.py", line 339, in call
with Popen(*popenargs, **kwargs) as p:
File "~/anaconda3/envs/myenv/lib/python3.7/subprocess.py", line 800, in __init__
restore_signals, start_new_session)
File "~/anaconda3/envs/myenv/lib/python3.7/subprocess.py", line 1551, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'patchelf': 'patchelf'
这里其实就是提示缺少patchelf
工具,安装一下即可;
Note:
patchelf
可以用conda来安装。
海螺AI: 在这里,
patchelf
是一个用于修改 ELF 可执行文件和库的实用工具。在你的错误信息中,MuJoCo在构建时使用patchelf
来修改共享库(主要是动态链接库.so
文件)的运行时路径(rpath)。