After cuda9.2 installed, got error when run nobody sample

Using ubuntu 18.04, cuda9.2 was installed.

Trying to compile nobody sample without error. But got error in ./nobody

Compute 5.2 CUDA device: [GeForce GTX TITAN X]
CUDA error at bodysystemcuda_impl.h:183 code=30(cudaErrorUnknown) “cudaGraphicsGLRegisterBuffer(&m_pGRes[i], m_pbo[i], cudaGraphicsMapFlagsNone)”

Any suggestion, thanks.

I’m seeing the same problem with nbody and Mandelbrot. A graphics pane opens briefly for both, then the error message. deviceQuery works fine. Also running on ubuntu 18.04

Running Mandelbrot, I get:

bill@hal:~$ ./cuda-9.2/NVIDIA_CUDA-9.2_Samples/2_Graphics/Mandelbrot/Mandelbrot
[CUDA Mandelbrot/Julia Set] - Starting…
GPU Device 0: “TITAN V” with compute capability 7.0

Data initialization done.
Initializing GLUT…
OpenGL window created.
Creating GL texture…
Texture created.
Creating PBO…
CUDA error at Mandelbrot.cpp:971 code=30(cudaErrorUnknown) “cudaGraphicsGLRegisterBuffer(&cuda_pbo_resource, gl_PBO, cudaGraphicsMapFlagsWriteDiscard)”

Can confirm I get same issue with nbody and Mandelbrot on Ubuntu 18.04, CUDA toolkit 9.2:

Windowed mode
Simulation data stored in video memory
Single precision floating point simulation
1 Devices used for simulation
GPU Device 0: “GeForce GTX 750 Ti” with compute capability 5.0

Compute 5.0 CUDA device: [GeForce GTX 750 Ti]
CUDA error at bodysystemcuda_impl.h:183 code=30(cudaErrorUnknown) “cudaGraphicsGLRegisterBuffer(&m_pGRes[i], m_pbo[i], cudaGraphicsMapFlagsNone)”

Any updates?

The usual reason for failure of this is when the OpenGL context and the CUDA context are not on the same GPU. If you are running on a laptop, or have 2 or more GPUs in the system (including other GPUs like intel integrated graphics) then that would be the first thing to check.

@txbob thanks for the hint! You set me on the right track. This took the better part of an afternoon to solve and I’ll document here in case it helps the others.

I’m not on a laptop nor do I have multiple GPUs. But this was the initial result from running glxinfo | grep -i opengl:

OpenGL vendor string: VMware, Inc.
OpenGL renderer string: Gallium 0.4 on llvmpipe

Ok so OpenGL was clearly not using my GPU. There were several threads on the Ubuntu launchpad forums for this:

But none of these solved my problem. I then checked my ‘/var/log/Xorg.0.log’ and found this issue:

[    47.013] (EE) NVIDIA(0): Failed to initialize the GLX module; please check in your X
[    47.013] (EE) NVIDIA(0):     log file that the GLX module has been loaded in your X
[    47.013] (EE) NVIDIA(0):     server, and that the module is the NVIDIA GLX module.  If
[    47.013] (EE) NVIDIA(0):     you continue to encounter problems, Please try
[    47.013] (EE) NVIDIA(0):     reinstalling the NVIDIA driver.

and this:

[    46.743] (II) LoadModule: "glx"
[    46.820] (II) Loading /usr/lib/xorg/modules/extensions/libglx.so
[    46.823] (II) Module glx: vendor="X.Org Foundation"
[    46.823] 	compiled for 1.19.6, module version = 1.0.0
[    46.823] 	ABI class: X.Org Server Extension, version 10.0

which led me this thread:

https://devtalk.nvidia.com/default/topic/830711/linux/failed-to-initialize-the-glx-module-please-check-in-your-x-log-file-that-the-glx-module-has-been-lo/

Long story short, the X server was loading /usr/lib/xorg/modules/extensions/libglx.soinstead of /usr/lib/nvidia-396/xorg/libglx.so.

Per the thread, I backed up and replaced the Xorg version with a symlink to the nvidia version:

sudo mv /usr/lib/xorg/modules/extensions/libglx.so /usr/lib/xorg/modules/extensions/libglx.so.bac

sudo ln -s /usr/lib/nvidia-396/xorg/libglx.so /usr/lib/xorg/modules/extensions/libglx.so

I then rebooted, ran glxinfo | grep -i opengl again, and got the correct values this time:

OpenGL vendor string: NVIDIA Corporation
OpenGL renderer string: GeForce GTX 750 Ti/PCIe/SSE2
OpenGL core profile version string: 4.6.0 NVIDIA 396.26

and now Mandelbrot, nbody, simpleGL etc are all working beautifully.

Wonderful afternoon of yak shaving…hope this helps someone :p

Good one! On Fedora 27, I failed by trying

sudo mv /usr/lib64/xorg/modules/extensions/libglx.so /usr/lib64/xorg/modules/extensions/libglx.so.bac

sudo ln -s /usr/lib64/xorg/modules/extensions/libglx.so.396.51 /usr/lib64/xorg/modules/extensions/libglx.so

Is anyone savy to know about the difference between /usr/lib and /usr/lib64 wrt libglx.so i.e. which one to fix or both?

Thanks!

Such obvious problems should be reported upstream. Does NVIDIA have a bug reporting platform?

related problem: https://devtalk.nvidia.com/default/topic/1038755/cuda-setup-and-installation/cuda-error-cudagraphicsglregisterbuffer/post/5277676/#5277676

to report a bug to NVIDIA

  • go to developer.nvidia.com
  • log in as a registered developer (so, you may need to join)\
  • click on your name in the upper right hand corner
  • click on my account
  • click on my bugs

FYI: the pure driver installation does not ask the question whether to install OpenGL - just the integrated cuda driver installation does so! The question about DKMS is only asked by the driver stand-alone but not in the integrated Cuda version.