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

Render Error for Pyglet #29

Closed
huybery opened this issue Jan 16, 2020 · 21 comments
Closed

Render Error for Pyglet #29

huybery opened this issue Jan 16, 2020 · 21 comments

Comments

@huybery
Copy link

huybery commented Jan 16, 2020

Render training sequences
cv2 >= 3
Traceback (most recent call last):
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyrender/platforms/pyglet.py", line 32, in init_context
    width=1, height=1)
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyglet/window/xlib/__init__.py", line 170, in __init__
    super(XlibWindow, self).__init__(*args, **kwargs)
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyglet/window/__init__.py", line 573, in __init__
    display = pyglet.canvas.get_display()
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyglet/canvas/__init__.py", line 95, in get_display
    return Display()
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyglet/canvas/xlib.py", line 119, in __init__
    raise NoSuchDisplayException('Cannot connect to "%s"' % name)
pyglet.canvas.xlib.NoSuchDisplayException: Cannot connect to "None"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run_training.py", line 92, in <module>
    main()
  File "run_training.py", line 89, in main
    model.train()
  File "/home/mesh/voca/utils/voca_model.py", line 189, in train
    , data_specifier='training')
  File "/home/mesh/voca/utils/voca_model.py", line 249, in _render_sequences
    self._render_helper(out_folder, data_specifier)
  File "/home/mesh/voca/utils/voca_model.py", line 274, in _render_helper
    self._render_sequences_helper(video_fname, raw_audio[i_seq], processed_audio[i_seq], templates[i_seq], vertices[i_seq], condition_idx)
  File "/home/mesh/voca/utils/voca_model.py", line 306, in _render_sequences_helper
    gt_img = render_mesh_helper(Mesh(seq_verts[i_frame], self.template_mesh.f), center)
  File "/home/mesh/voca/utils/rendering.py", line 107, in render_mesh_helper
    r = pyrender.OffscreenRenderer(viewport_width=frustum['width'], viewport_height=frustum['height'])
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyrender/offscreen.py", line 31, in __init__
    self._create()
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyrender/offscreen.py", line 134, in _create
    self._platform.init_context()
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyrender/platforms/pyglet.py", line 38, in init_context
    'internal error message was "{}"'.format(e)
ValueError: Failed to initialize Pyglet window with an OpenGL >= 3+ context. If you're logged in via SSH, ensure that you're running your script with vglrun (i.e. VirtualGL). The internal error message was "Cannot connect to "None""

I didn't access it through SSH. I connected to the standard desktop environment through teamviewer and it still reported an error.
This seems to be a problem of dependence. How can I solve it?

@huybery
Copy link
Author

huybery commented Jan 16, 2020

I guess it could be dump from the OpenGL version.
Here's my information:

>> glxinfo | grep OpenGL
OpenGL vendor string: VMware, Inc.
OpenGL renderer string: Gallium 0.4 on llvmpipe (LLVM 3.8, 256 bits)
OpenGL core profile version string: 3.3 (Core Profile) Mesa 11.2.0
OpenGL core profile shading language version string: 3.30
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile
OpenGL core profile extensions:
OpenGL version string: 3.0 Mesa 11.2.0
OpenGL shading language version string: 1.30
OpenGL context flags: (none)
OpenGL extensions:
OpenGL ES profile version string: OpenGL ES 3.0 Mesa 11.2.0
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.00
OpenGL ES profile extensions:

@huybery
Copy link
Author

huybery commented Jan 17, 2020

I'm trying to fix this problem. I think it's a problem of pyrender. I'm looking forward to getting help.

cv2 >= 3
Traceback (most recent call last):
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyrender/platforms/pyglet.py", line 32, in init_context
    width=1, height=1)
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyglet/window/xlib/__init__.py", line 170, in __init__
    super(XlibWindow, self).__init__(*args, **kwargs)
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyglet/window/__init__.py", line 592, in __init__
    config = screen.get_best_config(config)
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyglet/canvas/base.py", line 197, in get_best_config
    raise window.NoSuchConfigException()
pyglet.window.NoSuchConfigException

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "run_training.py", line 94, in <module>
    main()
  File "run_training.py", line 91, in main
    model.train()
  File "/home/mesh/voca/utils/voca_model.py", line 189, in train
    , data_specifier='training')
  File "/home/mesh/voca/utils/voca_model.py", line 249, in _render_sequences
    self._render_helper(out_folder, data_specifier)
  File "/home/mesh/voca/utils/voca_model.py", line 274, in _render_helper
    self._render_sequences_helper(video_fname, raw_audio[i_seq], processed_audio[i_seq], templates[i_seq], vertices[i_seq], condition_idx)
  File "/home/mesh/voca/utils/voca_model.py", line 306, in _render_sequences_helper
    gt_img = render_mesh_helper(Mesh(seq_verts[i_frame], self.template_mesh.f), center)
  File "/home/mesh/voca/utils/rendering.py", line 108, in render_mesh_helper
    r = pyrender.OffscreenRenderer(viewport_width=frustum['width'], viewport_height=frustum['height'])
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyrender/offscreen.py", line 31, in __init__
    self._create()
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyrender/offscreen.py", line 134, in _create
    self._platform.init_context()
  File "/home/mesh/.virtualenvs/voca/lib/python3.6/site-packages/pyrender/platforms/pyglet.py", line 40, in init_context
    'internal error message was "{}"'.format(e)
ValueError: Failed to initialize Pyglet window with an OpenGL >= 3+ context. If you're logged in via SSH, ensure that you're running your script with vglrun (i.e. VirtualGL). The internal error message was ""

@Jumponthemoon
Copy link

Same problem.Don't know how to fix it.

@Jumponthemoon
Copy link

Are you running on a server as well?

@huybery
Copy link
Author

huybery commented Jan 23, 2020

Are you running on a server as well?

yep, ubuntu 16.04.

@Banayaki
Copy link

Banayaki commented Jan 23, 2020

Are you running on a server as well?

yep, ubuntu 16.04.

The same

@TimoBolkart
Copy link
Owner

TimoBolkart commented Jan 23, 2020

Sorry, but I cannot reproduce the problem.
Just to clarify, you are all able to output the meshes but only the rendering is an issue @huybery @qianchenghao @Banayaki ?

@Banayaki
Copy link

I found the answer. Just use PYOPENGL_PLATFORM=osmesa. For example:
PYOPENGL_PLATFORM=osmesa python run_voca.py

@huybery
Copy link
Author

huybery commented Jan 24, 2020

Sorry, but I cannot reproduce the problem.
Just to clarify, you are all able to output the meshes but only the rendering is an issue @huybery @qianchenghao @Banayaki ?

yes, the mesh could be generated, but the video can not be output.

@huybery
Copy link
Author

huybery commented Jan 24, 2020

I found the answer. Just use PYOPENGL_PLATFORM=osmesa. For example:
PYOPENGL_PLATFORM=osmesa python run_voca.py

I have try it... it doesn't work..

@TimoBolkart
Copy link
Owner

@huybery does a visualization with OpenGL work for you? I.e. are you able to load one of these meshes with the mesh package and visualize it? Something along these lines
from psbody.mesh import Mesh
mesh = Mesh(filename='xxxxxxxxxx.obj')
mesh.show()
Does this work?

@huybery
Copy link
Author

huybery commented Jan 27, 2020

@huybery does a visualization with OpenGL work for you? I.e. are you able to load one of these meshes with the mesh package and visualize it? Something along these lines
from psbody.mesh import Mesh
mesh = Mesh(filename='xxxxxxxxxx.obj')
mesh.show()
Does this work?

yes, it works well. I can not generate video on ubuntu16.04, but I could do it on macos...

@plmsmile
Copy link

plmsmile commented Mar 11, 2020

I use my own wav files to run_voca.py. And I also meet a problem

Use standard file APIs to check for files with this prefix.
Traceback (most recent call last):
File "/Users/plm/app/anaconda3/envs/voca/lib/python3.6/site-packages/pyrender/platforms/pyglet_platform.py", line 32, in init_context
width=1, height=1)
File "/Users/plm/app/anaconda3/envs/voca/lib/python3.6/site-packages/pyglet/window/init.py", line 632, in init
self._create()
File "/Users/plm/app/anaconda3/envs/voca/lib/python3.6/site-packages/pyglet/window/cocoa/init.py", line 194, in create
self.context.attach(self.canvas)
File "/Users/plm/app/anaconda3/envs/voca/lib/python3.6/site-packages/pyglet/gl/cocoa.py", line 291, in attach
self.nscontext.setView(canvas.nsview)
AttributeError: 'NoneType' object has no attribute 'setView
'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "run_voca.py", line 45, in
inference(tf_model_fname, ds_fname, audio_fname, template_fname, condition_idx, out_path)
File "/Users/plm/pro/voca/utils/inference.py", line 112, in inference
render_sequence_meshes(audio_fname, predicted_vertices, template, out_path)
File "/Users/plm/pro/voca/utils/inference.py", line 70, in render_sequence_meshes
img = render_mesh_helper(Mesh(sequence_vertices[i_frame], template.f), center)
File "/Users/plm/pro/voca/utils/rendering.py", line 107, in render_mesh_helper
r = pyrender.OffscreenRenderer(viewport_width=frustum['width'], viewport_height=frustum['height'])
File "/Users/plm/app/anaconda3/envs/voca/lib/python3.6/site-packages/pyrender/offscreen.py", line 31, in init
self._create()
File "/Users/plm/app/anaconda3/envs/voca/lib/python3.6/site-packages/pyrender/offscreen.py", line 134, in _create
self.platform.init_context()
File "/Users/plm/app/anaconda3/envs/voca/lib/python3.6/site-packages/pyrender/platforms/pyglet_platform.py", line 38, in init_context
'internal error message was "{}"'.format(e)
ValueError: Failed to initialize Pyglet window with an OpenGL >= 3+ context. If you're logged in via SSH, ensure that you're running your script with vglrun (i.e. VirtualGL). The internal error message was "'NoneType' object has no attribute 'setView
'"

@tegusi
Copy link

tegusi commented Apr 10, 2020

I also met this problem... I logged with remote ssh with vglrun working well, it seems that the problem lies in rendering?

@TimoBolkart
Copy link
Owner

TimoBolkart commented Apr 28, 2020

@huybery @qianchenghao @plmsmile @tegusi by default executing run_voca.py outputs the animated meshes AND renders the meshes to a video using pyrender. Pyrender however seems to cause problems for several different configurations (e.g. when running remotely, etc.). I don't know how to fix this issue, but the rendering itself is not essential for running VOCA, as the meshes are output anyways. As a workaround, pull the newest changes and the script with --visualize False. This will solely output the meshes which then can be visualized or rendered with any other tool. Does this work for you?

@tegusi
Copy link

tegusi commented Apr 29, 2020

@huybery @qianchenghao @plmsmile @tegusi by default executing run_voca.py outputs the animated meshes AND renders the meshes to a video using pyrender. Pyrender however seems to cause problems for several different configurations (e.g. when running remotely, etc.). I don't know how to fix this issue, but the rendering itself is not essential for running VOCA, as the meshes are output anyways. As a workaround, pull the newest changes and the script with --visualize False. This will solely output the meshes which then can be visualized or rendered with any other tool. Does this work for you?

Thanks! It is a workaround for generating meshes while I am still seeking a tool to visualize them, do you have any suggestion?

@sultanovazamat
Copy link

sultanovazamat commented Jul 4, 2020

I'm trying to fix this problem. I think it's a problem of pyrender. I'm looking forward to getting help.

I found a solution:

  1. Firstly, follow the installation guide for OSMESA here;
  2. Secondly, use the code from here (original visualize_sequence.py throws a segmentation fault with osmesa, so I slightly modified it).

Hope it helps!

@Changlin-Lee
Copy link

I'm trying to fix this problem. I think it's a problem of pyrender. I'm looking forward to getting help.

I found a solution:

  1. Firstly, follow the installation guide for OSMESA here;
  2. Secondly, use the code from here (original visualize_sequence.py throws a segmentation fault with osmesa, so I slightly modified it).

Hope it helps!

That's really help! Thanks!

@Adorablepet
Copy link

@sultanovazamat @Changlin-Lee I replaced visualize_sequence.py code with the deb file with osmesa installed. But I still get this kind of error(pyrender: Falied rendering frame). Is there anything else I need to correct? Thank you.

ubuntu 18.04
cuda 10.1

@TimoBolkart
Copy link
Owner

Adding following lines to the rendering.py seems to solve the problem for some people:

import os
os.environ['PYOPENGL_PLATFORM'] = 'egl' # Uncommnet this line while running remotely

I updated the script accordingly

@joemaliszewski
Copy link

I found the answer. Just use PYOPENGL_PLATFORM=osmesa. For example:
PYOPENGL_PLATFORM=osmesa python run_voca.py

WORKS for me :D

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

10 participants