AMD GPU: Couldn't find RGB GLX visual or fbconfig

My main workstation has an recent AMD GPU (RX 6800 XT) which I’ve set up to work with Nix and it seems to have worked perfectly fine until I encountered some OpenGL issues today.

While compiling an application that uses OpenGL, I noticed it instantly segfaulted upon starting:

Failed to initialize OpenGL loader!
Segmentation fault (core dumped)

The very first thing I did was check what glxinfo had to say. Unfortunately, it didn’t tell me much at all:

[nix-shell:~]$ glxinfo
name of display: :0
Error: couldn't find RGB GLX visual or fbconfig

[nix-shell:~]$ eglinfo
EGL client extensions string:

Default display:
eglinfo: eglInitialize failed

[nix-shell:~]$ glxgears
Error: couldn't get an RGB, Double-buffered visual

I checked the wiki to see if I had set up everything currently, and stumbled upon the following line on the OpenGL article:


Use glxinfo to load 3D acceleration debug information.

If glxinfo returns Error: couldn't find RGB GLX visual or fbconfig , ensure you have extraPackages = [ pkgs.mesa.drivers ]; set.

I assume that the extraPackages here refers to hardware.opengl.extraPackages? If so, this did not fix the problem.

I’m on Gnome-Shell Wayland. Here are some of the important parts of my configuration.

boot.kernelModules = [ "kvm-amd" "amdgpu" ];

services.xserver.videoDrivers = [ "amdgpu" ];
services.xserver.enable = true;
services.xserver.autorun = true;

# Enable the GNOME Desktop Environment.
services.xserver.displayManager.gdm.enable = true;
services.xserver.displayManager.gdm.wayland = true;
services.xserver.desktopManager.gnome.enable = true;

# Enable Vulkan support
hardware.opengl.enable = true;
hardware.opengl.driSupport = true;
hardware.opengl.driSupport32Bit = true;

# The `pkgs.mesa.drivers` is here because of the wiki article
hardware.opengl.extraPackages = [ pkgs.mesa.drivers pkgs.amdvlk ];
hardware.opengl.extraPackages32 = [ pkgs.driversi686Linux.amdvlk ];

From what I can tell though, my system has indeed loaded everything correctly:
(Apologies for the incoming wall of text, I included all I could think of)


𝝺 modinfo amdgpu
filename:       /run/booted-system/kernel-modules/lib/modules/5.19.4/kernel/drivers/gpu/drm/amd/amdgpu/amdgpu.ko.xz
license:        GPL and additional rights
description:    AMD GPU
author:         AMD linux driver team
𝝺 cat /proc/modules | grep amdgpu
amdgpu 8491008 25 - Live 0x0000000000000000
iommu_v2 24576 1 amdgpu, Live 0x0000000000000000
gpu_sched 49152 1 amdgpu, Live 0x0000000000000000
drm_ttm_helper 16384 1 amdgpu, Live 0x0000000000000000
ttm 86016 2 amdgpu,drm_ttm_helper, Live 0x0000000000000000
drm_display_helper 163840 1 amdgpu, Live 0x0000000000000000
drm_kms_helper 180224 4 amdgpu,drm_display_helper, Live 0x0000000000000000
i2c_algo_bit 16384 1 amdgpu, Live 0x0000000000000000
drm 630784 16 amdgpu,gpu_sched,drm_ttm_helper,ttm,drm_display_helper,drm_kms_helper, Live 0x0000000000000000
backlight 24576 5 amdgpu,asus_wmi,drm_display_helper,video,drm, Live 0x0000000000000000
i2c_core 106496 10 ucsi_ccg,amdgpu,drm_display_helper,drm_kms_helper,i2c_algo_bit,i2c_designware_pci,i2c_designware_core,i2c_piix4,i2c_ccgx_ucsi,drm, Live 0x0000000000000000
𝝺 lsmod | grep amd
amdgpu               8491008  25
iommu_v2               24576  1 amdgpu
gpu_sched              49152  1 amdgpu
drm_ttm_helper         16384  1 amdgpu
edac_mce_amd           40960  0
ttm                    86016  2 amdgpu,drm_ttm_helper
drm_display_helper    163840  1 amdgpu
drm_kms_helper        180224  4 drm_display_helper,amdgpu
i2c_algo_bit           16384  1 amdgpu
gpio_amdpt             20480  0
gpio_generic           20480  1 gpio_amdpt
drm                   630784  16 gpu_sched,drm_kms_helper,drm_display_helper,amdgpu,drm_ttm_helper,ttm
backlight              24576  5 video,drm_display_helper,asus_wmi,amdgpu,drm
i2c_core              106496  10 ucsi_ccg,i2c_designware_core,drm_kms_helper,i2c_ccgx_ucsi,i2c_algo_bit,drm_display_helper,amdgpu,i2c_piix4,i2c_designware_pci,drm
𝝺 lspci -v
0a:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 21 [Radeon RX 6800/6800 XT / 6900 XT] (rev c1) (prog-if 00 [VGA controller])
	Subsystem: Advanced Micro Devices, Inc. [AMD/ATI] Device 0e3a
	Flags: bus master, fast devsel, latency 0, IRQ 114, IOMMU group 18
	Memory at d0000000 (64-bit, prefetchable) [size=256M]
	Memory at e0000000 (64-bit, prefetchable) [size=2M]
	I/O ports at f000 [size=256]
	Memory at fc500000 (32-bit, non-prefetchable) [size=1M]
	Expansion ROM at 000c0000 [disabled] [size=128K]
	Capabilities: <access denied>
	Kernel driver in use: amdgpu
	Kernel modules: amdgpu

And finally, the only additional info I could find was in Firefox’s about:support section:

WebGL 2 Driver
WebGL 2 Driver Renderer:	AMD -- AMD Radeon RX 6800 XT (sienna_cichlid, LLVM 13.0.1, DRM 3.47, 5.19.4)
WebGL 2 Driver Version:	    4.6 (Core Profile) Mesa 22.0.4

GPU #1
Active	         Yes
Description      AMD Radeon RX 6800 XT (sienna_cichlid, LLVM 13.0.1, DRM 3.47, 5.19.4)
Vendor ID        0x1002
Device ID        0x73bf
Driver Vendor	 mesa/radeonsi
Driver Version
RAM	             0

The only issue I can see there is that no VRAM is listed, but I don’t think it’s a big deal. dmesg certainly seems to indicate that the amdgpu driver has been successfully loaded and lists the correct amount of VRAM, so I don’t think there’s any issue there either.

𝝺 dmesg
[   12.364121] [drm] amdgpu: 16368M of VRAM memory ready
[   12.364122] [drm] amdgpu: 15996M of GTT memory ready.
[   15.133907] amdgpu 0000:0a:00.0: amdgpu: Using BACO for runtime pm
[   15.134186] [drm] Initialized amdgpu 3.47.0 20150101 for 0000:0a:00.0 on minor 0
[   15.145433] fbcon: amdgpudrmfb (fb0) is primary device
[   15.416701] amdgpu 0000:0a:00.0: [drm] fb0: amdgpudrmfb frame buffer device

Any ideas anyone?

I have an RX 6700 XT and I’m using sway and it’s working fine for me.
I get similar output for your commands (firefox shows RAM=0 as well).
Is Vulkan working for you?
I.e. does vulkaninfo from the vulkan-tools package work (should also work on a tty)?

$ vulkaninfo --summary
	apiVersion         = 4206804 (1.3.212)
	driverVersion      = 8388834 (0x8000e2)
	vendorID           = 0x1002
	deviceID           = 0x73df
	deviceName         = AMD Radeon RX 6700 XT
	driverID           = DRIVER_ID_AMD_OPEN_SOURCE
	driverName         = AMD open-source driver
	driverInfo         = 2022.Q2.2
	conformanceVersion =
	deviceUUID         = 00000000-0400-0000-0000-000000000000
	driverUUID         = 414d442d-4c49-4e55-582d-445256000000
1 Like

Yup, that does work, but your advice inadvertently led my to the solution. I was running both glxinfo and vulkaninfo from a nix-shell -p glxinfo vulkaninfo. That doesn’t seem to work. Setting up the packages via traditional means (system configuration) seems to work perfectly fine.

Do you have an explanation for why this is the case? The best I can think of is that I’m using nix-shell while my system configuration is built from a flake output, so nix-shell is probably using a version of nixpkgs that is different from the pinned input of my system config flake, causing some incompatibility with glibc versions or something?

If so, is there an easy way for to have nix-shell default to that pinned nixpkgs version instead?

(Sorry if I’m being dumb here)

Hm, interesting. There is some state involved in graphics drivers, which is the hardware.opengl.extraPackages option that populates the /run/opengl-driver/ directory with files pointing to OpenGL, Vulkan and OpenCL drivers. But you set that already, so that shouldn’t be the reason.
I don’t know why it doesn’t work from a nix shell.

When using flakes, you can pin the system registry nixpkgs (for nix shell nixpkgs#vulkan-tools) and channel (for nix-shell -p vulkan-tools) with

# Flake registry
nix.registry = {
  nixpkgs.flake = nixpkgs;
# Channels
nix.nixPath = [