Mujoco_py配置問題匯總

問題1

Creating window glfw
ERROR: GLEW initalization error: Missing GL version

參考GitHub issues:https://github.com/openai/mujoco-py/issues/432

方法1:在.bashrc中添加一下內(nèi)容
sudo gedit ~/.bashrc
export PATH=/usr/local/cuda-11.6/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.6/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so:/usr/lib/nvidia-390/libGL.so
# 特別注意:如果使用vim,或者gedit打開,保存后,要不關(guān)閉窗口,要不使用source一下,不然有時(shí)候不行,這是linux知識,我也不知道為啥,反正就是讓生效
source ~/.bashrc

以上第三行我的沒有l(wèi)ibGL.so,所以改成:

export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libGLEW.so

我首先需要安裝GLew
命令:
先命令查看glew:
apt-cache search glew

顯示結(jié)果:

(rl_ultrasound) litao@litao-X11DAi-N:~/Documents/robotic-ultrasound-imaging-master-1$ apt-cache search glew
fonts-glewlwyd - OAuth2 authentication server providing Json Web Tokens - font files
glew-utils - OpenGL Extension Wrangler - utilities
glewlwyd - OAuth2 authentication server providing Json Web Tokens
glewlwyd-common - OAuth2 authentication server providing Json Web Tokens - common files
libglew-dev - OpenGL Extension Wrangler - development environment
libglew2.1 - OpenGL Extension Wrangler - runtime environment
libglewmx-dev - OpenGL Extension Wrangler MX - development environment
libglewmx1.13 - OpenGL Extension Wrangler (Multiple Rendering Contexts)

報(bào)錯(cuò):

(rl_ultrasound) litao@litao-X11DAi-N:~/Documents/robotic-ultrasound-imaging-master-1$ sudo apt-get install glew-utils glewlwyd glewlwyd-common libglew-dev libglew2.1 libglewmx-dev libglewmx1.13
[sudo] password for litao: 
Reading package lists... Done
Building dependency tree       
Reading state information... Done
libglew-dev is already the newest version (2.1.0-4).
libglew2.1 is already the newest version (2.1.0-4).
libglew2.1 set to manually installed.
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libglewmx-dev : Conflicts: libglew-dev but 2.1.0-4 is to be installed
E: Unable to correct problems, you have held broken packages.

安裝過程提示:

  The glewlwyd package can be configured to use one of several database types. 
Below, you will be presented with the available choices.                                                                                                                                                                                    
  If other database types are supported by glewlwyd but not shown here, the reason for their omission is that the corresponding dbconfig-<database type> packages are not   
    │ installed. If you know that you want the package to use another supported database type, your best option is to back out of the dbconfig-common questions and opt out of   
    │ dbconfig-common assistance for this package for now. Install your preferred dbconfig-<database type> option from the list in the package dependencies, and then        
    │ "dpkg-reconfigure glewlwyd" to select it.                                                                                                                                                                                                                                                                                                           
    │ Database type to be used by glewlwyd:              

問題2

ValueError: numpy.ndarray size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

原因分析:
numpy安裝版本和llvmlite版本文件沖突。(以上報(bào)錯(cuò)只反映numpy版本過低)
解決方案:升級版本,但是遇到了新的報(bào)錯(cuò),如下問題3

問題3

ERROR:Cannot uninstall ‘llvmlite‘. It is a distutils installed project and thus we cannot accurately deter

查看了多種方法,嘗試用conda或者pip uninstall的方式但是并不管用,還是會有相同報(bào)錯(cuò)。網(wǎng)上最直接的方式是直接將llvmlite的包強(qiáng)制刪除,具體路徑在/home/litao/anaconda3/envs/rl_ultrasound/lib/python3.8/site-packages我在該路徑下直接找到所有的llvmlite文件包,直接刪除,問題解決,然后再安裝自己需要的版本。但是直接使用pip的方式安裝后又遇到問題4,解決方法如下:

問題4

AttributeError: module 'numba' has no attribute 'jit'

全網(wǎng)找到比較靠譜的處理辦法為以下:
參考:https://github.com/dereneaton/ipyrad/issues/180

博主說可能由于是conda本身導(dǎo)致的,miniconda沒有這樣的問題,我嘗試先一個(gè)個(gè)按要求安裝numba、numpy、llvmlite但是沒有解決問題。也許較大堆棧中的某些東西會導(dǎo)致問題。
另外看到有大佬說numba 被稱為 finnicky,這就是為什么通常不建議嘗試使用 pip 或 setup.py 安裝它的原因。不過,通常它會被 conda 很好地處理。

注意:llvm 或 llvmpy 安裝可能會阻止 numba 安裝它需要的 llvmlite。所以使用conda來做如下:

#先移除舊的packages
conda remove numba
conda remove llvm
conda remove llvmpy

##使用conda安裝 numba anew
conda install numba

然后關(guān)閉會話并完全重新啟動(dòng)它。

問題5

在渲染時(shí)候遇到的具體問題:無法渲染包含可變形對象的模型

Creating window glfw
Segmentation fault (core dumped)

這個(gè)是Mujoco_py的官方bug,使用這個(gè)包做軟體仿真的時(shí)候可能會遇到這個(gè)問題(官方現(xiàn)在沒有給出解決方案),但是在mujoco_py的github網(wǎng)站上的issues里邊找到一些方式,每個(gè)人最后解決的方式不太一樣。
參考GitHub issues:https://github.com/openai/mujoco-py/issues/373
方法一:
在issues的問題下有個(gè)大佬的文章發(fā)布了個(gè)解決方案,有人用這個(gè)解決了問題,我之前一次配置是用這個(gè)解決的,但是這第二次配置,我的最后好像也沒用:
大佬文章鏈接:https://github.com/wutter/mujoco-py-to-c-viewer
使用方法:

  1. Modify your model (copy), so it does not use skin.
  2. Use your python code with the model without skin to generate the sim.data.qpos (and than export it to csv by file.writerow(sim.data.qpos).
  3. Use the csv with qpos + model with skin as inputs for the viewer (.cpp).

方法二:
重裝并編譯mujoco-py

pip3 uninstall  -y mujoco_py

git clone git@github.com:fantasyRqg/mujoco-py.git

cd mujoco-py

python3 setup.py build

python3 setup.py install

方法三:
參考:
https://github.com/ARISE-Initiative/robosuite/issues/217
渲染具有皮膚屬性的可變形對象會引發(fā)分段錯(cuò)誤 #217
大佬表示就算升級了最新版本的mujoco-py 2.0.2.13,也會遇到分段錯(cuò)誤,所以他的解決辦法是使用 Herman大神的mujoco代碼可以解決問題。https://github.com/hermanjakobsen/mujoco-py
安裝方式:

pip3 install --user --force-reinstall --no-compile git+https://github.com/hermanjakobsen/mujoco-py

這里的包使用的不再是官方的包,而是一個(gè)大佬自己的包,嘗試后有用。
具體如下:

(rl_ultrasound) litao@litao-X11DAi-N:~/Documents/robotic-ultrasound-imaging-master-1$ pip3 install --user --force-reinstall --no-compile git+https://github.com/hermanjakobsen/mujoco-py
Collecting git+https://github.com/hermanjakobsen/mujoco-py
  Cloning https://github.com/hermanjakobsen/mujoco-py to /tmp/pip-req-build-r1iu3zew
  Running command git clone -q https://github.com/hermanjakobsen/mujoco-py /tmp/pip-req-build-r1iu3zew
  Resolved https://github.com/hermanjakobsen/mujoco-py to commit cb8d3fba4b5aae7e50bf733ca5253f89ab96cbf4
  Installing build dependencies ... done
  WARNING: Missing build requirements in pyproject.toml for git+https://github.com/hermanjakobsen/mujoco-py.
  WARNING: The project does not specify a build backend, and pip cannot fall back to setuptools without 'wheel'.
  Getting requirements to build wheel ... done
  Installing backend dependencies ... done
    Preparing wheel metadata ... done
Collecting fasteners~=0.15
  Using cached fasteners-0.17.3-py3-none-any.whl (18 kB)
Collecting glfw>=1.4.0
  Using cached glfw-2.5.1-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_x86_64.whl (205 kB)
Collecting imageio>=2.1.2
  Using cached imageio-2.16.1-py3-none-any.whl (3.3 MB)
Collecting cffi>=1.10
  Using cached cffi-1.15.0-cp38-cp38-manylinux_2_12_x86_64.manylinux2010_x86_64.whl (446 kB)
Collecting numpy>=1.11
  Using cached numpy-1.22.3-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (16.8 MB)
Collecting Cython>=0.27.2
  Using cached Cython-0.29.28-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl (1.9 MB)
Collecting pycparser
  Using cached pycparser-2.21-py2.py3-none-any.whl (118 kB)
Collecting pillow>=8.3.2
  Using cached Pillow-9.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (4.3 MB)
Building wheels for collected packages: mujoco-py
  Building wheel for mujoco-py (PEP 517) ... done
  Created wheel for mujoco-py: filename=mujoco_py-2.0.2.13-py3-none-any.whl size=5174777 sha256=79dda1d5305b95b50f785584d714f01588efa6ecf7368393c2508392c8fcbb81
  Stored in directory: /tmp/pip-ephem-wheel-cache-fdljxtm8/wheels/eb/6d/a5/e058ecbfa49884139621692160f2f42b2ec4760123f5b28301
Successfully built mujoco-py
Installing collected packages: pycparser, pillow, numpy, imageio, glfw, fasteners, Cython, cffi, mujoco-py
  WARNING: The scripts f2py, f2py3 and f2py3.8 are installed in '/home/litao/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  Attempting uninstall: imageio
    Found existing installation: imageio 2.16.1
    Uninstalling imageio-2.16.1:
      Successfully uninstalled imageio-2.16.1
  WARNING: The scripts imageio_download_bin and imageio_remove_bin are installed in '/home/litao/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  Attempting uninstall: glfw
    Found existing installation: glfw 2.5.1
    Uninstalling glfw-2.5.1:
      Successfully uninstalled glfw-2.5.1
  Attempting uninstall: fasteners
    Found existing installation: fasteners 0.17.3
    Uninstalling fasteners-0.17.3:
      Successfully uninstalled fasteners-0.17.3
  WARNING: The scripts cygdb, cython and cythonize are installed in '/home/litao/.local/bin' which is not on PATH.
  Consider adding this directory to PATH or, if you prefer to suppress this warning, use --no-warn-script-location.
  Attempting uninstall: cffi
    Found existing installation: cffi 1.15.0
    Uninstalling cffi-1.15.0:
      Successfully uninstalled cffi-1.15.0
  Attempting uninstall: mujoco-py
    Found existing installation: mujoco-py 2.0.2.13
    Uninstalling mujoco-py-2.0.2.13:
      Successfully uninstalled mujoco-py-2.0.2.13
Successfully installed Cython-0.29.28 cffi-1.15.0 fasteners-0.17.3 glfw-2.5.1 imageio-2.16.1 mujoco-py-2.0.2.13 numpy-1.22.3 pillow-9.0.1 pycparser-2.21

在這一步過程后,沒有分段錯(cuò)誤,但是有包沖突(應(yīng)該是之前安裝改變的),所以使用命令再次安裝了如下的強(qiáng)化學(xué)習(xí)的包:

git+https://github.com/DLR-RM/stable-baselines3
git+https://github.com/hermanjakobsen/robosuite
安裝方法還是一樣的:

pip3 install --user --force-reinstall --no-compile git+https://github.com/DLR-RM/stable-baselines3
pip3 install --user --force-reinstall --no-compile git+https://github.com/hermanjakobsen/robosuite

報(bào)錯(cuò)

Missing path to your environment variable. 
Current values LD_LIBRARY_PATH=
Please add following line to .bashrc:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/litao/.mujoco/mujoco200/bin
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容