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

[Informative] Having trouble with OpenGL in miniconda environment (Ubuntu 22) #99

Open
raminjafary opened this issue Apr 15, 2023 · 23 comments
Labels
documentation Improvements or additions to documentation

Comments

@raminjafary
Copy link

raminjafary commented Apr 15, 2023

Hello

if you have GPU on your machine and you are having trouble to run the project on Ubuntu 22 or higher. Run the following commands:

  1. sudo apt-get install libosmesa6-dev freeglut3-dev
  2. sudo apt-get install libglfw3-dev libgles2-mesa-dev
  3. sudo apt-get install libosmesa6
  4. export PYOPENGL_PLATFORM=osmesa (important: inside conda environment)
  5. conda install -c conda-forge libstdcxx-ng
  6. Still not working? try conda install cmake.

No need to downgrade the Python version or any other dep versioning hack.

Hope it helps!

@zcdliuwei
Copy link

Hello

If you are having trouble to run the project on Ubuntu 22 or higher. Run the following commands:

  1. sudo apt-get install libosmesa6-dev freeglut3-dev
  2. sudo apt-get install libglfw3-dev libgles2-mesa-dev
  3. sudo apt-get install libosmesa6
  4. export PYOPENGL_PLATFORM=osmesa
  5. conda -c install conda-forge libstdcxx-ng
  6. Still not working? try conda install cmake.

No need to downgrade the Python version or any other dep versioning hack.

Hope it helps!

Thank you for your suggestion
I tried all the steps, including conda install cmake.
But I still failed, this is an error message:
image
What else should I do?

@raminjafary
Copy link
Author

raminjafary commented Apr 15, 2023

Hello
If you are having trouble to run the project on Ubuntu 22 or higher. Run the following commands:

  1. sudo apt-get install libosmesa6-dev freeglut3-dev
  2. sudo apt-get install libglfw3-dev libgles2-mesa-dev
  3. sudo apt-get install libosmesa6
  4. export PYOPENGL_PLATFORM=osmesa
  5. conda -c install conda-forge libstdcxx-ng
  6. Still not working? try conda install cmake.

No need to downgrade the Python version or any other dep versioning hack.
Hope it helps!

Thank you for your suggestion I tried all the steps, including conda install cmake. But I still failed, this is an error message: image What else should I do?

Did you set export PYOPENGL_PLATFORM=osmesa in your current terminal in which conda environment is activated?

@zcdliuwei
Copy link

Yes, I did everything
image

@zcdliuwei
Copy link

zcdliuwei commented Apr 15, 2023

When I run your fifth step
I encountered an error:
usage: conda [-h] [-V] command ...
conda: error: unrecognized arguments: -c

So I changed the command to: conda install libstdcxx ng - c conda-forge

@raminjafary
Copy link
Author

raminjafary commented Apr 15, 2023

Yes, I did everything image

Can you try this? export DISPLAY=":1"

When I run your fifth step I encountered an error: usage: conda [-h] [-V] command ... conda: error: unrecognized arguments: -c

So I changed the command to: conda install libstdcxx ng - c conda-forge

Sorry. I fixed it: conda install -c conda-forge libstdcxx-ng

If you face any issue try this one too. conda install -c conda-forge libstdcxx-ng=12

@zcdliuwei
Copy link

Still failed, I have executed all your steps from scratch
include:
conda install -c conda-forge libstdcxx-ng=12 and export DISPLAY=":1"

@PouriaSeyfi
Copy link

PouriaSeyfi commented Apr 15, 2023

its working for me
Thank you @raminjafary

@hjessmith hjessmith added the documentation Improvements or additions to documentation label Apr 17, 2023
@raminjafary
Copy link
Author

Still failed, I have executed all your steps from scratch include: conda install -c conda-forge libstdcxx-ng=12 and export DISPLAY=":1"

Try pip uninstall glfw and then pip install glfw and let me know if it works.

@zcdliuwei
Copy link

Still failed, I have executed all your steps from scratch include: conda install -c conda-forge libstdcxx-ng=12 and export DISPLAY=":1"

Try pip uninstall glfw and then pip install glfw and let me know if it works.

NO
I reconstructed a virtual environment according to the project requirements and executed all your commands, but in the end, the same error was reported
I will try changing to an 18.04 environment

@Fei-dong
Copy link

I encountered the same problem on Ubuntu without a display, but when I tried again on a MacBook, I did not encounter the issue. So it's likely a problem with needing a screen display.

@zcdliuwei
Copy link

I encountered the same problem on Ubuntu without a display, but when I tried again on a MacBook, I did not encounter the issue. So it's likely a problem with needing a screen display.

Yes, I encountered the same problem on Ubuntu 22.04 and 18.04
but it can run normally on my Mac local machine with only CPU

@Linriversluv
Copy link

I have a remote Ubuntu18.04 environment. After following all the steps above and setting headless rendering with mesa, my problem is solved.

Many thanks.

@user50lab
Copy link

user50lab commented May 5, 2023

I'm wondering if this method can help solve the issue I encountered on a remote Ubuntu18.04 environment. The problem occurred on Ubuntu18.04 and I followed these steps, but unfortunately they did not resolve the issue.
The error message is as follows:
image

@xpat
Copy link

xpat commented May 10, 2023

Update:

I got it working. I re-ran the 4th command, this time paying attention to the instructions. export PYOPENGL_PLATFORM=osmesa (important: inside conda environment) (I must not have run it from inside conda the first time, hmmm. Or else I ran it from inside conda but not from within the virtual environment.) So now it works, except for the window size; the animation window is only partially visible on my Chromebook screen. Any ideas off-hand how to resize it? If not, I'll slide it over to a second screen when I get to my desk.)

Original post:

My error message: "miniconda3/envs/animated_drawings/lib/python3.8/site-packages/OpenGL/contextdata.py", line 40, in getContext raise error.Error( OpenGL.error.Error: Attempt to retrieve context when no valid context

This doesn't seem to have been the problem: animated-drawings 0.0.0 requires glfw==2.5.5, but you have glfw 2.5.9 which is incompatible

pip install glfw==2.5.5 Collecting glfw==2.5.5 Using cached glfw-2.5.5-py2.py27.py3.py30.py31.py32.py33.py34.py35.py36.py37.py38-none-manylinux2014_x86_64.whl (207 kB) Installing collected packages: glfw Attempting uninstall: glfw Found existing installation: glfw 2.5.9 Uninstalling glfw-2.5.9: Successfully uninstalled glfw-2.5.9 Successfully installed glfw-2.5.5

Chromebook
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye

conda 23.3.1
OpenGL version string: 3.1 Mesa 21.2.6

I've run all the suggested conda install -c commands and export DISPLAY=":1"

@yuleiqin
Copy link

yuleiqin commented May 19, 2023

I run all the instructions above but still get errors with my CentOS7 system (headless rendering):

Can anyone helps please? Thank you in advance.

File "AnimatedDrawings/animated_drawings/view/shaders/shader.py", line 29, in _compile_shader
assert False, msg
AssertionError: Compile failed for GL_VERTEX_SHADER (GL_VERTEX_SHADER)
0:5(10): error: GLSL 3.30 is not supported. Supported versions are: 

1: // Copyright (c) Meta Platforms, Inc. and affiliates.
2: // This source code is licensed under the MIT license found in the
3: // LICENSE file in the root directory of this source tree.
4: 
5: #version 330 core
6: uniform mat4 model;
7: uniform mat4 view;
8: uniform mat4 proj;
9: 
10: layout(location = 0) in vec3 pos;
11: layout(location = 1) in vec3 color;
12: 
13: flat out int vertex_id;
14: 
15: out vec3 ourColor;
16: 
17: void main(){
18:    gl_Position = proj * view * model * vec4(pos, 1);
19: 
20:    vertex_id = gl_VertexID;
21: 
22:    ourColor = color;
23: } 

@xpat
Copy link

xpat commented May 25, 2023

@yuleiqin Did you figure it out? I've only looked at the mvc folder and when I ran into an error I resolved it by setting the USE_MESA flag to true. Had you already done that?

@Chiangdongdong

This comment was marked as resolved.

@howardgriffin
Copy link

I'm wondering if this method can help solve the issue I encountered on a remote Ubuntu18.04 environment. The problem occurred on Ubuntu18.04 and I followed these steps, but unfortunately they did not resolve the issue. The error message is as follows: image

Same promblem. Have you solve it?

@laughxing
Copy link

I'm wondering if this method can help solve the issue I encountered on a remote Ubuntu18.04 environment. The problem occurred on Ubuntu18.04 and I followed these steps, but unfortunately they did not resolve the issue. The error message is as follows: image

Same promblem. Have you solve it?

same

@xpat
Copy link

xpat commented Aug 21, 2023

Just to rule out that what worked for me isn't working for you @laughxing @howardgriffin @yuleiqin #169

@aoyang-hd
Copy link

also meet same promblem
Python 3.8.13 (default, Oct 21 2022, 23:50:54)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.

from animated_drawings import render
render.start('./examples/config/mvc/export_mp4_example.yaml')
/home/cv/.conda/envs/animated_drawings/lib/python3.8/site-packages/glfw/init.py:912: GLFWError: (65544) b'X11: Failed to open display localhost:13.0'
warnings.warn(message, GLFWError)
/home/cv/.conda/envs/animated_drawings/lib/python3.8/site-packages/glfw/init.py:912: GLFWError: (65537) b'The GLFW library is not initialized'
warnings.warn(message, GLFWError)
Traceback (most recent call last):
File "", line 1, in
File "/data/cv/aoyang/AnimatedDrawings/animated_drawings/render.py", line 17, in start
view = View.create_view(cfg.view)
File "/data/cv/aoyang/AnimatedDrawings/animated_drawings/view/view.py", line 47, in create_view
return WindowView(view_cfg)
File "/data/cv/aoyang/AnimatedDrawings/animated_drawings/view/window_view.py", line 34, in init
self._create_window(*cfg.window_dimensions) # pyright: ignore[reportGeneralTypeIssues]
File "/data/cv/aoyang/AnimatedDrawings/animated_drawings/view/window_view.py", line 126, in _create_window
logging.info(f'OpenGL Version: {GL.glGetString(GL.GL_VERSION).decode()}') # pyright: ignore[reportGeneralTypeIssues]
AttributeError: 'NoneType' object has no attribute 'decode

@aoyang-hd
Copy link

aoyang-hd commented Sep 8, 2023

I solve it ,you can try
1
In mesa_view.py add
os.environ['MUJOCO_GL'] = "osmesa"
2
python3 -m pip install PyOpenGL_accelerate
apt-get update && apt-get install ffmpeg libsm6 libxext6 -y
apt-get install -y python3-opengl
apt-get install -y libosmesa6
3
In export_gif_example.yaml or any /mvc/ *.yaml
view:
USE_MESA: True

@javier-pkg-mda
Copy link

I solve it ,you can try 1 In mesa_view.py add os.environ['MUJOCO_GL'] = "osmesa" 2 python3 -m pip install PyOpenGL_accelerate apt-get update && apt-get install ffmpeg libsm6 libxext6 -y apt-get install -y python3-opengl apt-get install -y libosmesa6 3 In export_gif_example.yaml or any /mvc/ *.yaml view: USE_MESA: True

like a charm, thanks

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

No branches or pull requests