Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenGL.error.NullFunctionError: Attempt to call an undefined function OSMesaCreateContextExt, check for bool(OSMesaCreateContextExt) before calling #1

Open
dilshan-dev opened this issue Mar 1, 2023 · 5 comments

Comments

@dilshan-dev
Copy link

Hello,
I tried to run the experiment using python vpg_train.py task=reach_site and I get the following error.

/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/torch/utils/tensorboard/init.py:3: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
if not hasattr(tensorboard, 'version') or LooseVersion(tensorboard.version) < LooseVersion('1.15'):
/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/torch/utils/tensorboard/init.py:3: DeprecationWarning: distutils Version classes are deprecated. Use packaging.version instead.
if not hasattr(tensorboard, 'version') or LooseVersion(tensorboard.version) < LooseVersion('1.15'):
ic| cfg: {'task_name': 'reach_site', 'seed': 3, 'device': 'cuda', 'gpu_id': 2, 'save_video': True, 'use_tb': False, 'episodes': 200, 'steps_per_episode': 2000, 'max_ep_len': 500, 'lr_actor': 0.0003, 'lr_critic': 0.001, 'train_v_iters': 80, 'save_freq': 10, 'gamma': 0.99, 'lam': 0.95, 'experiment': 'exp', 'obs_dim': '???', 'act_dim': '???', 'hidden_dim_1': 512, 'hidden_dim_2': 256, 'hidden_dim_3': 128}
workspace: /home/acar/Documents/RMBench-2022/01_VPG/exp_local/reach_site_seed_3/2023.03.01_130720
Init a log at /home/acar/Documents/RMBench-2022/01_VPG/exp_local/reach_site_seed_3/2023.03.01_130720
output_file: <_io.TextIOWrapper name='/home/acar/Documents/RMBench-2022/01_VPG/exp_local/reach_site_seed_3/2023.03.01_130720/progress.txt' mode='a' encoding='UTF-8'>
seed: 3
device: cuda:2

Init environment: reach_site
ic| domain: 'reach', task: 'site'
ic| name: 'reach_site_vision'
Error executing job with overrides: ['task=reach_site']
Traceback (most recent call last):
File "/home/acar/Documents/RMBench-2022/01_VPG/vpg_train.py", line 296, in main
env = dmc.make(name = cfg.task_name,
File "/home/acar/Documents/RMBench-2022/01_VPG/../dmc.py", line 248, in make
env = manipulation.load(name, seed=seed)
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/manipulation/init.py", line 76, in load
return _composer.Environment(task, time_limit=time_limit, random_state=seed)
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/composer/environment.py", line 324, in init
super().init(
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/composer/environment.py", line 221, in init
self._recompile_physics_and_update_observables()
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/composer/environment.py", line 243, in _recompile_physics_and_update_observables
self._observation_updater.reset(self._physics_proxy, self._random_state)
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/composer/observation/updater.py", line 165, in reset
enabled.observation_callable())
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/composer/observation/observable/mjcf.py", line 242, in get_observation
pixels = physics.render(
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/mujoco/engine.py", line 206, in render
camera = Camera(
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/mujoco/engine.py", line 675, in init
if self._physics.contexts.mujoco is not None:
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/mujoco/engine.py", line 514, in contexts
self._make_rendering_contexts()
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/mujoco/engine.py", line 497, in _make_rendering_contexts
render_context = _render.Renderer(
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/_render/base.py", line 63, in init
ctx.call(self._platform_init, max_width, max_height)
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/_render/executor/render_executor.py", line 194, in call
return self._call_locked(func, *args, **kwargs)
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/_render/executor/render_executor.py", line 204, in _call_locked
return self._executor.submit(func, *args, **kwargs).result()
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/concurrent/futures/_base.py", line 446, in result
return self.__get_result()
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
raise self._exception
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/_render/pyopengl/osmesa_renderer.py", line 49, in _platform_init
self._context = osmesa.OSMesaCreateContextExt(
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/OpenGL/platform/baseplatform.py", line 423, in call
raise error.NullFunctionError(
OpenGL.error.NullFunctionError: Attempt to call an undefined function OSMesaCreateContextExt, check for bool(OSMesaCreateContextExt) before calling

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.
Error in atexit._run_exitfuncs:
Traceback (most recent call last):
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/_render/executor/render_executor.py", line 212, in terminate
self._call_locked(cleanup_callable)
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/_render/executor/render_executor.py", line 204, in _call_locked
return self._executor.submit(func, *args, **kwargs).result()
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/concurrent/futures/thread.py", line 167, in submit
raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown
Exception ignored in: <function ContextBase.del at 0x7fa541fab160>
Traceback (most recent call last):
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/_render/base.py", line 115, in del
self._free_unconditionally()
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/_render/base.py", line 112, in _free_unconditionally
self._render_executor.terminate(self._free_on_executor_thread)
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/_render/executor/render_executor.py", line 212, in terminate
self._call_locked(cleanup_callable)
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/site-packages/dm_control/_render/executor/render_executor.py", line 204, in _call_locked
return self._executor.submit(func, *args, **kwargs).result()
File "/home/acar/anaconda3/envs/rmb1/lib/python3.9/concurrent/futures/thread.py", line 167, in submit
raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown

I tried various solutions related to PyOpenGL and osmesa but I couldn't resolve it. I am using Ubuntu 22.04 and I created a conda env with the packages. The same error is present when running with other algorithms such as SAC and DrQv2.
Any help that can be offered is much appreciated.
Thank you!

@xiangyanfei212
Copy link
Owner

xiangyanfei212 commented Mar 1, 2023 via email

@dilshan-dev
Copy link
Author

Hello,
Thank you for your reply.
Actually I have done a clean installation of the OS (after the error occurred) and I have tried dm_control and DrQv2 (repo) separately, which work fine (earlier dm_control did not work in the base system and DrQv2 did not work with conda).

I then came back to this repository and in the conda env I separately installed all three backends with the use of your reply, and when I run the experiment I am faced with the following error.

Traceback (most recent call last):
File "/home/acar/Documents/RMBench-2022/00_DrQv2/drqv2_train.py", line 24, in
import dmc
File "/home/acar/Documents/RMBench-2022/00_DrQv2/../dmc.py", line 11, in
from dm_control import manipulation, suite
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/dm_control/manipulation/init.py", line 20, in
from dm_control import composer as _composer
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/dm_control/composer/init.py", line 18, in
from dm_control.composer.arena import Arena
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/dm_control/composer/arena.py", line 20, in
from dm_control import mjcf
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/dm_control/mjcf/init.py", line 18, in
from dm_control.mjcf.attribute import Asset
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/dm_control/mjcf/attribute.py", line 28, in
from dm_control.mujoco.wrapper import util
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/dm_control/mujoco/init.py", line 18, in
from dm_control.mujoco.engine import action_spec
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/dm_control/mujoco/engine.py", line 41, in
from dm_control import _render
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/dm_control/_render/init.py", line 67, in
Renderer = import_func() # pylint: disable=invalid-name
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/dm_control/_render/init.py", line 46, in _import_osmesa
from dm_control._render.pyopengl.osmesa_renderer import OSMesaContext
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/dm_control/_render/pyopengl/osmesa_renderer.py", line 35, in
from OpenGL import GL
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/OpenGL/GL/init.py", line 4, in
from OpenGL.GL.VERSION.GL_1_1 import *
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/OpenGL/GL/VERSION/GL_1_1.py", line 14, in
from OpenGL.raw.GL.VERSION.GL_1_1 import *
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/OpenGL/raw/GL/VERSION/GL_1_1.py", line 7, in
from OpenGL.raw.GL import _errors
File "/home/acar/anaconda3/envs/rmb/lib/python3.9/site-packages/OpenGL/raw/GL/_errors.py", line 4, in
_error_checker = _ErrorChecker( _p, _p.GL.glGetError )
AttributeError: 'NoneType' object has no attribute 'glGetError'

I faced this error before as well and I sidestepped it with the instructions given in MPI-IS/mesh#23 (comment), which then lead to the error I first mentioned.

When I do the same now, I am still faced with the initial error.
Any further help you can offer is highly appreciated.

Thank you!

@xiangyanfei212
Copy link
Owner

xiangyanfei212 commented Mar 3, 2023 via email

@dilshan-dev
Copy link
Author

Hello,

Thank you for your reply.

I was able to proceed without errors and run the experiments by using GLFW instead of OSMesa (setting os.environ['MUJOCO_GL'] = 'glfw' instead of os.environ['MUJOCO_GL'] = 'osmesa' in the [ALGORITHM_NAME].py file).

I also had to change the gpu_id: to 0 (in my case) in config.yaml file under /[ALGORITHM_FOLDER]/cfgs/.

Many thanks for your prompt replies and for making this work available.

Cheers.

@xiangyanfei212
Copy link
Owner

xiangyanfei212 commented Mar 8, 2023 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants