bulletphysics / bullet3

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
http://bulletphysics.org
Other
12.66k stars 2.88k forks source link

Failed to create an OpenGL context when trying to launch a pybullet example #1681

Closed trougnouf closed 6 years ago

trougnouf commented 6 years ago

Hello, I tried to launch an example but it fails with the following:

/usr/lib/python3.6/site-packages/pybullet_envs/examples>$ python testBike.py 
pybullet build time: May 11 2018 16:36:39
startThreads creating 1 threads.
starting thread 0
started thread 0 
argc=2
argv[0] = --unused
argv[1] = --start_demo_name=Physics Server
ExampleBrowserThreadFunc started
X11 functions dynamically loaded using dlopen/dlsym OK!
Creating context
Failed to create GL 3.0 context ... using old-style GLX context
Failed to create an OpenGL context

I installed pybullet on Arch Linux using the setup.py script which I packaged as https://aur.archlinux.org/packages/python-pybullet-git/ . I also packaged https://aur.archlinux.org/packages/roboschool-git/ which builds with an old version of bullet3 and I was able to run their examples.

trougnouf commented 6 years ago

It works on my laptop using the same installation method. The laptop runs on AMD open-source driver with Wayland while the desktop uses NVIDIA/proprietary driver. They are both up to date and should have approximately the same packages installed.

[trougnouf@uryzen:pybullet_envs/examples]$ python testBike.py     (05-11 17:23)
pybullet build time: May 11 2018 17:14:09
startThreads creating 1 threads.
starting thread 0
started thread 0 
argc=2
argv[0] = --unused
argv[1] = --start_demo_name=Physics Server
ExampleBrowserThreadFunc started
X11 functions dynamically loaded using dlopen/dlsym OK!
Creating context
Created GL 3.0 context
Direct GLX rendering context obtained
Making context current
GL_VENDOR=X.Org
GL_RENDERER=AMD RAVEN (DRM 3.23.0 / 4.16.7-1-ARCH, LLVM 6.0.0)
GL_VERSION=4.5 (Core Profile) Mesa 18.0.3
GL_SHADING_LANGUAGE_VERSION=4.50
pthread_getconcurrency()=0
Version = 4.5 (Core Profile) Mesa 18.0.3
Vendor = X.Org
Renderer = AMD RAVEN (DRM 3.23.0 / 4.16.7-1-ARCH, LLVM 6.0.0)
b3Printf: Selected demo: Physics Server
startThreads creating 1 threads.
starting thread 0
started thread 0 
MotionThreadFunc thread started
ven = X.Org
rpy=" 0.0 -0.0 0.0 " xyz=" -0.07000000029802322 0.0 0.6899999976158142
XIO:  fatal IO error 11 (Resource temporarily unavailable) on X server ":0"
      after 694 requests (694 known processed) with 0 events remaining.
erwincoumans commented 6 years ago

The error is reported: Failed to create GL 3.0 context Are you using a virtual environment, remote desktop connection? You may only be able to run old OpenGL 2 apps. You could modify the code to create a rudimentary OpenGL 2 display, but best is to sort out your graphics drivers.

erwincoumans commented 6 years ago

You can try to modify testbike.py (around line 10) as follows, and report if you see a graphics window: p.connect(p.GUI, options="--opengl2")

Note that the OpenGL 2.x implementation is rudimentary and doesn't have all features.

trougnouf commented 6 years ago

I don't know what happened but it works on the desktop computer after a reboot, using a GL 3.0 context. Thank you for looking into it!

shlok-agarwal commented 6 years ago

I am facing a similar issue and running on laptop and rebooting did not fix it for me. I guess my graphics drivers are set correctly.

Graphics

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.67                 Driver Version: 390.67                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Quadro M1200        Off  | 00000000:01:00.0 Off |                  N/A |
| N/A   38C    P8    N/A /  N/A |    251MiB /  4043MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0      1162      G   /usr/lib/xorg/Xorg                           182MiB |
|    0      2042      G   compiz                                        65MiB |
+-----------------------------------------------------------------------------+

Error:

startThreads creating 1 threads.
starting thread 0
started thread 0 
argc=3
argv[0] = --unused
argv[1] = ./main
argv[2] = --start_demo_name=Physics Server
ExampleBrowserThreadFunc started
X11 functions dynamically loaded using dlopen/dlsym OK!
glewXInit dynamically loaded using dlopen/dlsym OK
glewXInit OK
Creating context
Failed to create GL 3.0 context ... using old-style GLX context
Failed to create an OpenGL context

Can you please recommend a fix?

DanielTakeshi commented 4 years ago

@trougnouf How do you "use a GL 3.0 context" here?

Using pip install pybullet==2.8.4, here are my drivers for my Ubunut 18.04 virtual machine (i.e., a remote machine) though I faked a desktop which leads to Xorg visible:

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 450.51.05    Driver Version: 450.51.05    CUDA Version: 11.0     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  Tesla T4            On   | 00000000:00:04.0 Off |                    0 |
| N/A   37C    P8    10W /  70W |     11MiB / 15109MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      3312      G   /usr/lib/xorg/Xorg                 10MiB |
+-----------------------------------------------------------------------------+

Message from my PyBullet script:

startThreads creating 1 threads.
starting thread 0
started thread 0
argc=2
argv[0] = --unused
argv[1] = --start_demo_name=Physics Server
ExampleBrowserThreadFunc started
X11 functions dynamically loaded using dlopen/dlsym OK!
X11 functions dynamically loaded using dlopen/dlsym OK!
Creating context
Failed to create GL 3.3 context ... using old-style GLX context
Failed to create an OpenGL context
AdityaKapoor74 commented 4 years ago

I am facing the same issue. I am using Ubuntu 18.04 on my VirtualBox. Any updates?

Sicelukwanda commented 4 years ago

Was facing the same issue on Ubuntu 16.04, in my case the cause was these two lines:

export MESA_GL_VERSION_OVERRIDE=3.2
export MESA_GLSL_VERSION_OVERRIDE=150

In my bashrc file, I removed them now everything works fine.

AdityaKapoor74 commented 4 years ago

I am using virtualbox with Ubuntu 20.04 and whenever I try to run an example, I get the following error:


pybullet build time: Aug 14 2020 02:51:12
startThreads creating 1 threads.
starting thread 0
started thread 0 
argc=2
argv[0] = --unused
argv[1] = --start_demo_name=Physics Server
ExampleBrowserThreadFunc started
X11 functions dynamically loaded using dlopen/dlsym OK!
X11 functions dynamically loaded using dlopen/dlsym OK!
Creating context
Failed to create GL 3.3 context ... using old-style GLX context
Direct GLX rendering context obtained
Making context current
GL_VENDOR=VMware, Inc.
GL_RENDERER=SVGA3D; build: RELEASE;  LLVM;
GL_VERSION=2.1 Mesa 20.0.8
GL_SHADING_LANGUAGE_VERSION=1.20
pthread_getconcurrency()=0
Version = 2.1 Mesa 20.0.8
Vendor = VMware, Inc.
Renderer = SVGA3D; build: RELEASE;  LLVM;
Compile failed:
0:1(10): error: GLSL 1.50 is not supported. Supported versions are: 1.10, 1.20, and 1.00 ES

Segmentation fault (core dumped)

Can someone help me with how to rectify this error?

AdityaKapoor74 commented 4 years ago

Hey yeah I will be happy to know how you did it?

On Sat, Aug 15, 2020 at 3:47 AM Daniel Seita notifications@github.com wrote:

I fixed my error by creating a fake display. There are a number of steps involved but happy to explain in more detail if I can.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bulletphysics/bullet3/issues/1681#issuecomment-674294313, or unsubscribe https://github.com/notifications/unsubscribe-auth/AJRDXZRWXS6WGYLLW26WJ3DSAWZYJANCNFSM4E7OOROQ .

-- Aditya Kapoor Mob. no.:+91 9869037643 / +91 9082008452 Personal mail: adityakapoor074@gmail.com [image: Inline image 1]

Birla Institute of Technology & Science, Pilani

K K Birla Goa CampusNH 17 B, ZuarinagarGoa, India. 403726

shanki98 commented 4 years ago

Hi @AdityaKapoor74 , were you able to solve this issue because I have a similar SEGFAULT before it connects to OpenGL

erwincoumans commented 4 years ago

The OpenGL3 visualizer requires OpenGL 3.x. Most virtual environments don't work well, so it is best to just use DIRECT mode and getCameraImage using the default CPU renderer. Otherwise use a regular non-virtual OS with an up-to-date NVIDIA or AMD display driver.

aamorel commented 4 years ago

hello @AdityaKapoor74, @shanki98 I have exactly the same problem as you on my VM environment, Ubuntu 20.04.1. Did you eventually solve the problem ? When using p.DIRECT, I don't get a graphics window. I want to be able to see what my simulation does. Thank you

Robertreido commented 3 years ago

I am having the same problem on my Nvidia Jetson TX2, running ubuntu 18.04, which has just been rebooted. Have tried what seems to be everything. please help....

Error:

pybullet build time: Dec  9 2020 15:39:08
startThreads creating 1 threads.
starting thread 0
started thread 0 
argc=2
argv[0] = --unused
argv[1] = --start_demo_name=Physics Server
ExampleBrowserThreadFunc started
X11 functions dynamically loaded using dlopen/dlsym OK!
X11 functions dynamically loaded using dlopen/dlsym OK!
Failed to retrieve a framebuffer config
erwincoumans commented 3 years ago

It should work on TX2 (have it running here), probably an issue with the display drivers. Also, I assume you run it with a display monitor attached, right (it won't work otherwise). What does nvidia-smi tell?

Robertreido commented 3 years ago

@erwincoumans this is all i get when running 'watch nvidia-smi'. And yes i am running with a display monitor attached.

sh: 1: nvidia-smi: not found

I am also able to run the same program on a VM so really unsure why its not working

erwincoumans commented 3 years ago

OpenGL 3 won't work well without a proper installed NVIDIA driver on TX2.

Robertreido commented 3 years ago

Could you please point me in the right direction on how to do that? i am feeling quite out of my depth sorry

Robertreido commented 3 years ago

@erwincoumans would really appreciate it please, really stuck at the moment

CHbloom commented 1 year ago

I am using virtualbox with Ubuntu 20.04 and whenever I try to run an example, I get the following error:


pybullet build time: Aug 14 2020 02:51:12
startThreads creating 1 threads.
starting thread 0
started thread 0 
argc=2
argv[0] = --unused
argv[1] = --start_demo_name=Physics Server
ExampleBrowserThreadFunc started
X11 functions dynamically loaded using dlopen/dlsym OK!
X11 functions dynamically loaded using dlopen/dlsym OK!
Creating context
Failed to create GL 3.3 context ... using old-style GLX context
Direct GLX rendering context obtained
Making context current
GL_VENDOR=VMware, Inc.
GL_RENDERER=SVGA3D; build: RELEASE;  LLVM;
GL_VERSION=2.1 Mesa 20.0.8
GL_SHADING_LANGUAGE_VERSION=1.20
pthread_getconcurrency()=0
Version = 2.1 Mesa 20.0.8
Vendor = VMware, Inc.
Renderer = SVGA3D; build: RELEASE;  LLVM;
Compile failed:
0:1(10): error: GLSL 1.50 is not supported. Supported versions are: 1.10, 1.20, and 1.00 ES

Segmentation fault (core dumped)

Can someone help me with how to rectify this error?

have you solve it?I met the same problem,could you help me.

CHbloom commented 1 year ago

@erwincoumans would really appreciate it please, really stuck at the moment

have you solve it?I met the same problem,could you help me.