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

Graphics acceleration not loading with NixOS 24.05 #234

Closed
autrimpo opened this issue Sep 4, 2024 · 28 comments
Closed

Graphics acceleration not loading with NixOS 24.05 #234

autrimpo opened this issue Sep 4, 2024 · 28 comments

Comments

@autrimpo
Copy link

autrimpo commented Sep 4, 2024

After updating to 2024-09-03 I'm getting issues loading the mesa driver:

LIBGL_DEBUG=verbose glxinfo -B with 2024-07-31:

libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/autrimpo/.drirc: No such file or directory.
using driver asahi for 4
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/autrimpo/.drirc: No such file or directory.
MESA-LOADER: device is not located on the PCI bus
using driver asahi for 4
MESA-LOADER: dlopen(/run/opengl-driver/lib/dri/asahi_dri.so)
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/autrimpo/.drirc: No such file or directory.
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/autrimpo/.drirc: No such file or directory.
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/autrimpo/.drirc: No such file or directory.
Using DRI3 for screen 0
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Mesa (0xffffffff)
    Device: Apple M2 (G14G B0) (0xffffffff)
    Version: 24.2.0
    Accelerated: yes
    Video memory: 15678MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.6
    Max compat profile version: 4.6
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
Memory info (GL_ATI_meminfo):
    VBO free memory - total: 15678 MB, largest block: 15678 MB
    VBO free aux. memory - total: 0 MB, largest block: 0 MB
    Texture free memory - total: 15678 MB, largest block: 15678 MB
    Texture free aux. memory - total: 0 MB, largest block: 0 MB
    Renderbuffer free memory - total: 15678 MB, largest block: 15678 MB
    Renderbuffer free aux. memory - total: 0 MB, largest block: 0 MB
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 15678 MB
    Total available memory: 15678 MB
    Currently available dedicated video memory: 15678 MB
OpenGL vendor string: Mesa
OpenGL renderer string: Apple M2 (G14G B0)
OpenGL core profile version string: 4.6 (Core Profile) Mesa 24.2.0-devel
OpenGL core profile shading language version string: 4.60
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.6 (Compatibility Profile) Mesa 24.2.0-devel
OpenGL shading language version string: 4.60
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 24.2.0-devel
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20

LIBGL_DEBUG=verbose glxinfo -B with 2024-09-03:

MESA-LOADER: dlopen(/run/opengl-driver/lib/dri/swrast_dri.so)
did not find extension DRI_Kopper version 1
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/autrimpo/.drirc: No such file or directory.
libGL: Can't open configuration file /etc/drirc: No such file or directory.
libGL: Can't open configuration file /home/autrimpo/.drirc: No such file or directory.
did not find extension DRI2_Flush version 1
name of display: :0
display: :0  screen: 0
direct rendering: Yes
Extended renderer info (GLX_MESA_query_renderer):
    Vendor: Mesa (0xffffffff)
    Device: llvmpipe (LLVM 17.0.6, 128 bits) (0xffffffff)
    Version: 24.2.0
    Accelerated: no
    Video memory: 15679MB
    Unified memory: yes
    Preferred profile: core (0x1)
    Max core profile version: 4.5
    Max compat profile version: 4.5
    Max GLES1 profile version: 1.1
    Max GLES[23] profile version: 3.2
Memory info (GL_ATI_meminfo):
    VBO free memory - total: 0 MB, largest block: 0 MB
    VBO free aux. memory - total: 12517 MB, largest block: 12517 MB
    Texture free memory - total: 0 MB, largest block: 0 MB
    Texture free aux. memory - total: 12517 MB, largest block: 12517 MB
    Renderbuffer free memory - total: 0 MB, largest block: 0 MB
    Renderbuffer free aux. memory - total: 12517 MB, largest block: 12517 MB
Memory info (GL_NVX_gpu_memory_info):
    Dedicated video memory: 69379 MB
    Total available memory: 85058 MB
    Currently available dedicated video memory: 0 MB
OpenGL vendor string: Mesa
OpenGL renderer string: llvmpipe (LLVM 17.0.6, 128 bits)
OpenGL core profile version string: 4.5 (Core Profile) Mesa 24.2.0-devel
OpenGL core profile shading language version string: 4.50
OpenGL core profile context flags: (none)
OpenGL core profile profile mask: core profile

OpenGL version string: 4.5 (Compatibility Profile) Mesa 24.2.0-devel
OpenGL shading language version string: 4.50
OpenGL context flags: (none)
OpenGL profile mask: compatibility profile

OpenGL ES profile version string: OpenGL ES 3.2 Mesa 24.2.0-devel
OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.20
@jmastr
Copy link

jmastr commented Sep 4, 2024

can confirm. same here

@matteocavestri
Copy link

I am experiencing the same issue. I also noticed that home-manager outputs the following warning: libEGL warning: egl: failed to create dri2 screen.

During the update, there was the following diff of packages (perhaps one of the removed packages is causing the problem):

Version changes:
[U.]  #1  asahi-audio   2.2 -> 2.3
[U*]  #2  cpupower      6.9.12-asahi -> 6.10.6-asahi
[U.]  #3  initrd-linux  6.9.12-asahi -> 6.10.6-asahi
[U.]  #4  linux         6.9.12-asahi, 6.9.12-asahi-modules, 6.9.12-asahi-modules-shrunk -> 6.10.6-asahi, 6.10.6-asahi-modules, 6.10.6-asahi-modules-shrunk
[C.]  #5  udev-rules    <none> x2 -> <none>
Removed packages:
[R.]  #1  extra-utils                   <none>
[R.]  #2  initrd-fsinfo                 <none>
[R.]  #3  initrd-kmod-blacklist-ubuntu  <none>
[R.]  #4  keymap                        <none>
[R.]  #5  link-units                    <none>
[R.]  #6  rust-lib-src                  <none>
[R.]  #7  stage                         1-init.sh

@rowanG077
Copy link
Contributor

rowanG077 commented Sep 5, 2024

I cannot reproduce this with a NixOS unstable + M2 Max + non-homemanger hyprland. Could someone post their kernel log?

@jmastr
Copy link

jmastr commented Sep 5, 2024

I use NixOS stable on an M1. Here is the kernel.log

@matteocavestri
Copy link

I believe the issue lies in the following error: apple-dcp 38bc00000.dcp: RTKit: syslog message: PPipeDCP_H13P.cpp:11109: IOMFB updateFrequencies EDT ERROR: getClockFrequency(0) (237333328) < videoClock 402278400! Giving up on frequencies. This error points to a mismatch between getClockFrequency() and videoClock, indicating that the system is unable to properly synchronize the display frequency. The system is attempting to set a clock frequency of 237.333328 MHz, while the expected video clock is 402.278400 MHz.
I will also review my kernel log to check for any additional details.

@matteocavestri
Copy link

My kernel log is different, but I am still encountering errors related to getClockFrequency(). Specifically, I find this error: PPipeDCP_H13P.cpp:11092: IOMFB updateFrequencies: minimum-frequency property not found, using getClockFrequency(0) instead. It seems to be connected to the kernel log of @jmastr.
kernel.log

@autrimpo
Copy link
Author

autrimpo commented Sep 5, 2024

Here's mine, I also see the frequency error. kernel.log

@matteocavestri
Copy link

The issue does not seem to be related to getClockFrequency() as I initially thought, because it occurs in both kernels. However, when comparing the kernel logs between versions 6.9.12 and 6.10.6, the following differences emerge:

  1. Missing initialization of the Asahi GPU in kernel 6.10.6:

    • In kernel 6.9.12, the Asahi GPU is detected and initialized correctly, with messages confirming the activation of the MMU and device tree configurations. An excerpt from the kernel log showing the GPU initialization in version 6.9.12:
      [    2.336925] asahi 206400000.gpu: MMU: initialized
      [    2.336927] asahi 206400000.gpu: GPU ID registers: 0x4021100 0x40a04 0x30808 0x40404 0x1320300 0x101311
      [    2.336931] asahi 206400000.gpu: GPU Information:
      [    2.336932] asahi 206400000.gpu:   Type: G13G
      [    2.336933] asahi 206400000.gpu:   Clusters: 1
      [    2.336934] asahi 206400000.gpu:   Cores: 8 (8)
      [    2.336934] asahi 206400000.gpu:   Frags: 8 (8)
      [    2.336935] asahi 206400000.gpu:   GPs: 4 (4)
      [    2.336936] asahi 206400000.gpu: Getting configuration from device tree...
      [    2.337151] asahi 206400000.gpu: Dynamic configuration fetched
      
    • In kernel 6.10.6, there are no messages related to the Asahi GPU, indicating that the driver is not being loaded or that the GPU is not being recognized.
  2. Initialization of the simpledrm framebuffer:

    • The simpledrm framebuffer is initialized correctly in both kernel versions. However, in kernel 6.10.6, it seems to be the only display-related component that is loaded, with no further initialization of the GPU.

kernel-6.9.12.log

@jmastr
Copy link

jmastr commented Sep 5, 2024

This is my kernel.log when switching to nixos-unstable. after that GPU is working fine, which means it is "just" a missing dependency on stable?

@matteocavestri
Copy link

Does anyone have an idea about how to fix this dependency issue on stable 24.05?

@dxwil
Copy link

dxwil commented Sep 15, 2024

Same thing happens to me, Hyprland doesn't launch

@nick-disiere
Copy link

Do we know what packages are causing the issue? I can try various overlays in my flake if not.

@mogery
Copy link

mogery commented Sep 19, 2024

Setting

hardware.asahi = {
    useExperimentalGPUDriver = true;
};

fixed this for me. (I'm also using unstable.)

@jmastr
Copy link

jmastr commented Sep 19, 2024

@mogery can't confirm. i have useExperimentalGPUDriver = true; set as well and on nixos-24.05 GPU driver does not load

@dxwil
Copy link

dxwil commented Sep 19, 2024

@mogery I have that set aswell, still does not load

@mogery
Copy link

mogery commented Sep 19, 2024

@mogery I have that set aswell, still does not load

Are you on unstable nixpkgs or 24.05? Is that + unstable a universal workaround for now?

@dxwil
Copy link

dxwil commented Sep 19, 2024

@mogery I have that set aswell, still does not load

Are you on unstable nixpkgs or 24.05? Is that + unstable a universal workaround for now?

I'm on 24.05 with a few unstable packages

@jmastr
Copy link

jmastr commented Sep 19, 2024

@mogery my workaround is to switch my nixos and home-manager channels to nixos-unstable resp. master, i.e.:

$ sudo nix-channel --list
apple-silicon-support https://github.com/tpwrules/nixos-apple-silicon/archive/main.tar.gz
home-manager https://github.com/nix-community/home-manager/archive/master.tar.gz
nixos https://nixos.org/channels/nixos-unstable
nixos-unstable https://nixos.org/channels/nixos-unstable

Note:

$ uname -a
Linux apple-macbook-pro 6.10.6-asahi #1-NixOS SMP PREEMPT_DYNAMIC Tue Jan  1 00:00:00 UTC 1980 aarch64 GNU/Linux

I wait until 24.11 gets released and then I will switch back to stable channels.

@lukaslihotzki
Copy link

The issue probably is that NixOS 24.05 ships Rust 1.77, but kernel 6.10 requires Rust 1.78 for CONFIG_RUST. Therefore, CONFIG_RUST is disabled when building the current kernel on 24.05. This can be verified with zcat /proc/config.gz | grep CONFIG_RUST (empty with 24.05, set to yes with unstable).

@mogery
Copy link

mogery commented Sep 25, 2024

Wow, finding that must've been hell. Thank you!

@autrimpo
Copy link
Author

@lukaslihotzki You're spot on, thank you! I made a local overlay for the kernel:

(final: prev: let
  nixpkgs-asahi = import inputs.apple-silicon.inputs.nixpkgs {};
in {
  linux-asahi = nixpkgs-asahi.callPackage "${inputs.apple-silicon}/apple-silicon-support/packages/linux-asahi" { };
})

and things work fine now.

@dvaerum
Copy link

dvaerum commented Sep 29, 2024

I am using nixos-unstable and when I try to use

hardware.asahi.useExperimentalGPUDriver = true;

I get the following error, have anyone else encountered this? or have any good ways of fixing it/tracking it down?

         at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/pkgs/build-support/replace-dependency.nix:70:18:

           69|
           70|   dependsOnOld = drv: dependsOnOldMemo.${discard (toString drv)};
             |                  ^
           71|

       error: 'builtins.storePath' is not allowed in pure evaluation mode

       at «none»:0: (source not available)
The entire log, using `--show-trace`
building the system configuration...
error:
     … while calling anonymous lambda

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/attrsets.nix:1571:24:

       1570|     let f = attrPath:
       1571|       zipAttrsWith (n: values:
           |                        ^
       1572|         let here = attrPath ++ [n]; in

     … while calling anonymous lambda

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/attrsets.nix:1205:18:

       1204|         mapAttrs
       1205|           (name: value:
           |                  ^
       1206|             if isAttrs value && cond value

     … from call site

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/attrsets.nix:1208:18:

       1207|             then recurse (path ++ [ name ]) value
       1208|             else f (path ++ [ name ]) value);
           |                  ^
       1209|     in

     … while calling anonymous lambda

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/modules.nix:254:72:

        253|           # For definitions that have an associated option
        254|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
           |                                                                        ^
        255|

     … while evaluating the option `system.build.toplevel':

     … while calling anonymous lambda

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/modules.nix:836:28:

        835|         # Process mkMerge and mkIf properties.
        836|         defs' = concatMap (m:
           |                            ^
        837|           map (value: { inherit (m) file; inherit value; }) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

     … while evaluating definitions from `/nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/nixos/modules/system/activation/top-level.nix':

     … from call site

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/modules.nix:837:128:

        836|         defs' = concatMap (m:
        837|           map (value: { inherit (m) file; inherit value; }) (addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
           |                                                                                                                                ^
        838|         ) defs;

     … while calling 'dischargeProperties'

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/modules.nix:908:25:

        907|   */
        908|   dischargeProperties = def:
           |                         ^
        909|     if def._type or "" == "merge" then

     … from call site

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/nixos/modules/system/activation/top-level.nix:71:12:

         70|   # Replace runtime dependencies
         71|   system = foldr ({ oldDependency, newDependency }: drv:
           |            ^
         72|       pkgs.replaceDependency { inherit oldDependency newDependency drv; }

     … while calling 'foldr'

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/lists.nix:121:20:

        120|   */
        121|   foldr = op: nul: list:
           |                    ^
        122|     let

     … from call site

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/lists.nix:128:8:

        127|         else op (elemAt list n) (fold' (n + 1));
        128|     in fold' 0;
           |        ^
        129|

     … while calling 'fold''

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/lists.nix:124:15:

        123|       len = length list;
        124|       fold' = n:
           |               ^
        125|         if n == len

     … from call site

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/lists.nix:127:14:

        126|         then nul
        127|         else op (elemAt list n) (fold' (n + 1));
           |              ^
        128|     in fold' 0;

     … while calling anonymous lambda

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/nixos/modules/system/activation/top-level.nix:71:53:

         70|   # Replace runtime dependencies
         71|   system = foldr ({ oldDependency, newDependency }: drv:
           |                                                     ^
         72|       pkgs.replaceDependency { inherit oldDependency newDependency drv; }

     … from call site

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/lib/trivial.nix:957:7:

        956|     { # TODO: Should we add call-time "type" checking like built in?
        957|       __functor = self: f;
           |       ^
        958|       __functionArgs = args;

     … while calling anonymous lambda

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/pkgs/build-support/replace-dependency.nix:20:1:

         19| # (and all of its dependencies) without rebuilding further.
         20| { drv, oldDependency, newDependency, verbose ? true }:
           | ^
         21|

     … while calling 'dependsOnOld'

       at /nix/store/y6205wq8hxvpqvl8l9d1n9xah01kg0lq-source/pkgs/build-support/replace-dependency.nix:70:18:

         69|
         70|   dependsOnOld = drv: dependsOnOldMemo.${discard (toString drv)};
           |                  ^
         71|

     error: 'builtins.storePath' is not allowed in pure evaluation mode

     at «none»:0: (source not available)

Update:

I figured it out, it is because I am using flakes. To make it comparable with flakes, one also needs to add experimentalGPUInstallMode = "overlay"; which does require a re-compile of multiple packages and some of the are quite time-consuming to build.

  hardware.asahi = {
    useExperimentalGPUDriver = true;
    experimentalGPUInstallMode = "overlay";
  };

Source:

options.hardware.asahi.experimentalGPUInstallMode = lib.mkOption {
type = lib.types.enum [ "driver" "replace" "overlay" ];
default = "replace";
description = ''
Mode to use to install the experimental GPU driver into the system.
driver: install only as a driver, do not replace system Mesa.
Causes issues with certain programs like Plasma Wayland.
replace (default): use replaceRuntimeDependencies to replace system Mesa with Asahi Mesa.
Does not work in pure evaluation context (i.e. in flakes by default).
overlay: overlay system Mesa with Asahi Mesa
Requires rebuilding the world.
'';
};

@jackoe
Copy link

jackoe commented Oct 2, 2024

@dvaerum I have useExperimentalGPUDriver as true and experimentalGPUInstallMode unset and it doesn't error when I build. If you want you can post/link your config somewhere and I'll build/diff it with mine. Might save you some compile time.

@lloeki
Copy link

lloeki commented Oct 3, 2024

The issue probably is that NixOS 24.05 ships Rust 1.77, but kernel 6.10 requires Rust 1.78 for CONFIG_RUST. Therefore, CONFIG_RUST is disabled when building the current kernel on 24.05.

What if there were two linux-asahi kernel packages? One that would track the latest Asahi patches and one that would track a more stable kernel with a non-latest Asahi patchset but compatible with stable NixOS channels?

(This would tie in nicely with #182 (comment), that comment having a bit more details)

@dvaerum
Copy link

dvaerum commented Oct 3, 2024

@dvaerum I have useExperimentalGPUDriver as true and experimentalGPUInstallMode unset and it doesn't error when I build. If you want you can post/link your config somewhere and I'll build/diff it with mine. Might save you some compile time.

Are you using flakes? Because I am using flakes and the documentation said that replace (the default) does not work with flakes.

@xeniagda
Copy link

xeniagda commented Oct 5, 2024

For flakes, one has to run nixos-rebuild with the --impure option to let the replace-option work properly.

@dvaerum
Copy link

dvaerum commented Oct 9, 2024

Interesting @xeniagda, do you know if I can declare that inside flake as some variable? Something like

{
  flake-settings.impure = true;
  inputs = { ... };
  outputs = { ... };
}

@tpwrules
Copy link
Owner

This is likely due to NixOS stable having a too-old version of Rust.

As mentioned, stable support is on a best-effort basis. 24.11 is almost here so I do not plan to address this. If you need graphics acceleration before then, please downgrade the Apple Silicon support module.

@tpwrules tpwrules closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2024
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