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

Hyprland Does Refuses to Use Hardware GPU from boot #159

Closed
BagMan9 opened this issue Feb 13, 2024 · 19 comments
Closed

Hyprland Does Refuses to Use Hardware GPU from boot #159

BagMan9 opened this issue Feb 13, 2024 · 19 comments

Comments

@BagMan9
Copy link

BagMan9 commented Feb 13, 2024

Hardware is M1 MacBook Pro 13".

I have gotten the experimental driver working with gdm & gnome (via Wayland) . In fact, when running, I'm able to launch hyprland from my terminal and it runs in a small window. However, as soon as I attempt to launch Hyprland directly as the default login session, it crashes.

Here is one of many crash logs:

This seems very similar to #149, however the thread did not seem to be helpful.

I know this is a commonly reported issue, and I have done my best to take as many troubleshooting steps as possible before posting.

GPU / Desktop Manager Config: (configuration.nix)

{ config, lib, pkgs, inputs, ... }:

{
  imports =
    [
      inputs.apple-silicon.nixosModules.apple-silicon-support
    ];

  nix.settings.experimental-features = [ "nix-command" "flakes" ];

  nixpkgs.overlays = [
        inputs.apple-silicon.overlays.apple-silicon-overlay
  ];
  hardware = {
          asahi = {
                  peripheralFirmwareDirectory = ./firmware;
          withRust = true;
                  addEdgeKernelConfig = true;
                  useExperimentalGPUDriver = true;
                  experimentalGPUInstallMode = "replace";
            };
    opengl = {
      enable = true;
      driSupport = true;
      };
    };



  # Use the systemd-boot EFI boot loader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = false;

  networking.hostName = "IsaacMBP";
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "America/Indiana/Indianapolis";
  time.hardwareClockInLocalTime = true;

  xdg.portal = {
    enable = true;
    extraPortals = [ pkgs.xdg-desktop-portal-hyprland ];
    };
  # Enable the X11 windowing system.
  services.xserver.enable = true;
  services.xserver.desktopManager.gnome.enable = true;
  services.xserver.displayManager.gdm = {
      enable = true;
      wayland = true;

    };
  #services.xserver.displayManager.defaultSession = "hyprland";



#services.greetd = {
#  enable = true;
#  settings = {
#    default_session = {
#      command = "${pkgs.greetd.tuigreet}/bin/tuigreet --time --time-format '%I:%M %p | %a • %h | %F' --cmd Hyprland";
#      user = "greeter";
#      };
#    };
#  };

Cycling through experimentalGPUInstallMode options has had varying-but-mostly-unhelpful result:

  • "replace" has seemed to work best, with gdm/gnome running smoothly via hardware gpu on boot up. Here is the crash I get:
[LOG] Creating the HookSystem!
[LOG] Creating the KeybindManager!
[LOG] [hookSystem] New hook event registered: configReloaded
[LOG] Creating the AnimationManager!
[LOG] Created a bezier curve, baked 255 points, mem usage: 4.08kB, time to bake: 8.25µs. Estimated average calc time: 0.03µs.
[LOG] Creating the ConfigManager!
[LOG] NOTE: further logs to stdout / logfile are disabled by default. Use debug:disable_logs and debug:enable_stdout_logs to override this.
[LOG] Creating the CHyprError!
[LOG] [hookSystem] New hook event registered: focusedMon
[LOG] [hookSystem] New hook event registered: preRender
[LOG] Creating the LayoutManager!
[LOG] [hookSystem] New hook event registered: preConfigReload
[LOG] Reloading the config!
[LOG] Created a bezier curve, baked 255 points, mem usage: 4.08kB, time to bake: 4.92µs. Estimated average calc time: 0.01µs.
[LOG] Using config: ~/.config/hypr/hyprland.conf
[LOG] Registered dynamic var "$terminal" -> alacritty
[LOG] Registered dynamic var "$fileManager" -> dolphin
[LOG] Registered dynamic var "$menu" -> wofi --show drun
[LOG] Created a bezier curve, baked 255 points, mem usage: 4.08kB, time to bake: 4.92µs. Estimated average calc time: 0.01µs.
[LOG] Registered dynamic var "$mainMod" -> SUPER
[LOG] Disabling stdout logs! Check the log for further logs.
[EGL] command: eglQueryDeviceStringEXT, error: EGL_BAD_PARAMETER (0x300c), message: "eglQueryDeviceStringEXT"
[EGL] command: eglQueryDeviceStringEXT, error: EGL_BAD_PARAMETER (0x300c), message: "eglQueryDeviceStringEXT"
[EGL] command: eglQueryDeviceStringEXT, error: EGL_BAD_PARAMETER (0x300c), message: "eglQueryDeviceStringEXT"
[EGL] command: eglQueryDeviceStringEXT, error: EGL_BAD_PARAMETER (0x300c), message: "eglQueryDeviceStringEXT"
[render/egl.c:320] Software rendering detected, please use the WLR_RENDERER_ALLOW_SOFTWARE environment variable to proceed
[render/egl.c:572] Failed to initialize EGL context
[render/gles2/renderer.c:510] Could not initialize EGL
[CRITICAL] m_sWLRRenderer was NULL! This usually means wlroots could not find a GPU or enountered some issues.
[CRITICAL] Critical error thrown: wlr_gles2_renderer_create_with_drm_fd() failed!
  • "driver" causes gdm/gnome to switch to software rendering. It does not seem to effect Hyprland.
  • "overlay" fails in nixos-rebuild with "infinite recursion encountered" and appears to take issue with a mesa declaration. I did not record the specific output, and will add to this post asap with it. I could not find the error in general seems to have many causes, and I could not find anyone with a similar issue.

In addition, I attempted to isolate gdm as a potential problem. I tried both using greeter (see commented out portion of configuration.nix) to launch HL and also tried launching it from just the basic tty (no x server running) and was unsuccessful with the same error as above.

I have disabled the xdg options, gnome, gdm and tried pretty much every combination of the above options.

Here is the Coredump of one of the crashes when attempting to launch as a session from gdm:

 [🡕] Process 1879 (.Hyprland-wrapp) of user 1000 dumped core.

Module libxml2.so.2 without build-id.
Module libncursesw.so.6 without build-id.
Module libzstd.so.1 without build-id.
Module libxshmfence.so.1 without build-id.
Module libxcb-sync.so.1 without build-id.
Module libxcb-dri2.so.0 without build-id.
Module libX11-xcb.so.1 without build-id.
Module libpcre.so.1 without build-id.
Module libbrotlicommon.so.1 without build-id.
Module libgraphite2.so.3 without build-id.
Module libdatrie.so.1 without build-id.
Module libselinux.so.1 without build-id.
Module libpcre2-8.so.0 without build-id.
Module libgudev-1.0.so.0 without build-id.
Module libbrotlidec.so.1 without build-id.
Module libbz2.so.1 without build-id.
Module libxcb-randr.so.0 without build-id.
Module libexpat.so.1 without build-id.
Module libpangoft2-1.0.so.0 without build-id.
Module libharfbuzz.so.0 without build-id.
Module libthai.so.0 without build-id.
Module libfribidi.so.0 without build-id.
Module libGLX.so.0 without build-id.
Module libcap.so.2 without build-id.
Module libXdmcp.so.6 without build-id.
Module libXau.so.6 without build-id.
Module libwacom.so.9 without build-id.
Module libevdev.so.2 without build-id.
Module libmtdev.so.1 without build-id.
Module libGLdispatch.so.0 without build-id.
Module libXrender.so.1 without build-id.
Module libXext.so.6 without build-id.
Module libX11.so.6 without build-id.
Module libfreetype.so.6 without build-id.
Module libfontconfig.so.1 without build-id.
Module libpng16.so.16 without build-id.
Module libz.so.1 without build-id.
Module libxcb-errors.so.0 without build-id.
Module libxcb-res.so.0 without build-id.
Module libxcb-icccm.so.4 without build-id.
Module libxcb-ewmh.so.2 without build-id.
Module libxcb-composite.so.0 without build-id.
Module libxcb-xinput.so.0 without build-id.
Module libxcb-xfixes.so.0 without build-id.
Module libxcb-shm.so.0 without build-id.
Module libxcb-render-util.so.0 without build-id.
Module libxcb-render.so.0 without build-id.
Module libxcb-present.so.0 without build-id.
Module libxcb-dri3.so.0 without build-id.
Module libliftoff.so.0 without build-id.
Module libdisplay-info.so.1 without build-id.
Module libseat.so.1 without build-id.
Module libudev.so.1 without build-id.
Module libvulkan.so.1 without build-id.
Module libGLESv2.so.2 without build-id.
Module libffi.so.8 without build-id.
Module libgcc_s.so.1 without build-id.
Module libstdc++.so.6 without build-id.
Module libpangocairo-1.0.so.0 without build-id.
Module libpango-1.0.so.0 without build-id.
Module libGL.so.1 without build-id.
Module libudis86.so.0 without build-id.
Module libsystemd.so.0 without build-id.
Module libxcb.so.1 without build-id.
Module libinput.so.10 without build-id.
Module libxkbcommon.so.0 without build-id.
Module libEGL.so.1 without build-id.
Module libdrm.so.2 without build-id.
Module libwlroots.so.13 without build-id.
Module .Hyprland-wrapped without build-id.
 Stack trace of thread 1879:
 #0  0x0000ffffacd859c0 __pthread_kill_implementation (libc.so.6 + 0x859c0)
 #1  0x0000ffffacd3f0ec raise (libc.so.6 + 0x3f0ec)
 #2  0x0000ffffacd2adbc abort (libc.so.6 + 0x2adbc)
 #3  0x0000000000485978 _Z25handleUnrecoverableSignali (.Hyprland-wrapped + 0x85978)
 #4  0x0000ffffadbf480c n/a (linux-vdso.so.1 + 0x80c)
 #5  0x0000ffffadbf480c n/a (linux-vdso.so.1 + 0x80c)
 #6  0x0000ffffacd859ac __pthread_kill_implementation (libc.so.6 + 0x859ac)
 #7  0x0000ffffad8fe080 n/a (n/a + 0x0)
 ELF object binary architecture: AARCH64

Additionally, most of the crashes seem to be surrounded by these errors (from journalctl:)

Feb 12 18:46:43 IsaacMBP /nix/store/2sys23606bb3i1y0lyvwxiv9djm16mn4-gdm-45.0.1/libexec/gdm-wayland-session[1879]:   what():  wlr_gles2_renderer_create_with_drm_fd() failed!
Feb 12 18:46:43 IsaacMBP /nix/store/2sys23606bb3i1y0lyvwxiv9djm16mn4-gdm-45.0.1/libexec/gdm-wayland-session[1879]: terminate called after throwing an instance of 'std::runtime_error'
Feb 12 18:46:43 IsaacMBP /nix/store/2sys23606bb3i1y0lyvwxiv9djm16mn4-gdm-45.0.1/libexec/gdm-wayland-session[1879]: MESA-LOADER: failed to open adp: /run/opengl-driver/lib/dri/adp_dri.so: cannot open shared object file: No such file or directory (search paths /run/opengl-driver/lib/d>

I think this is relavent because it looks similar to #67, but I could be wrong.

Let me know what other information would be helpful.

@BagMan9
Copy link
Author

BagMan9 commented Feb 13, 2024

Here is the overlay option build failure:

error:
       … while calling the 'head' builtin

         at /nix/store/599wy5snf00pn1apmsnzmiy0ysdpds03-source/lib/attrsets.nix:960:11:

          959|         || pred here (elemAt values 1) (head values) then
          960|           head values
             |           ^
          961|         else

       … while evaluating the attribute 'value'

         at /nix/store/599wy5snf00pn1apmsnzmiy0ysdpds03-source/lib/modules.nix:809:9:

          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

       (stack trace truncated; use '--show-trace' to show the full trace)

       error: infinite recursion encountered

       at /nix/store/xdy8zk9w82cp59jhf0b1lagjhq4d4fa5-source/apple-silicon-support/modules/mesa/default.nix:30:11:

           29|         (final: prev: {
           30|           mesa = final.mesa-asahi-edge;
             |           ^
           31|         })

@BagMan9 BagMan9 changed the title Hyprland Does Not Recognize GPU Hyprland Does Not Refuses to Use Hardware GOU Feb 13, 2024
@BagMan9 BagMan9 changed the title Hyprland Does Not Refuses to Use Hardware GOU Hyprland Does Not Refuses to Use Hardware GPU from boot Feb 13, 2024
@BagMan9 BagMan9 changed the title Hyprland Does Not Refuses to Use Hardware GPU from boot Hyprland Does Refuses to Use Hardware GPU from boot Feb 13, 2024
@thedaringdev
Copy link

I have trying to get this to work as well to no avail. I have tried using the mesa overlay (final: prev: { mesa = final.mesa-asahi-edge; }) but Hyprland still failed to use the driver.

@n3oney
Copy link

n3oney commented Mar 19, 2024

maybe try doing this
#136 (comment)

@thedaringdev
Copy link

@n3oney I tried using your nixos config but Hyprland still failed to launch. I wonder if its a model problem as I am using the same model as @BagMan9.

@zvolin
Copy link

zvolin commented Apr 10, 2024

I'm also experiencing this issue and trying to dig. I have macbook pro m2. So far I've tried:

  • all the possible hardware.asahi combinations
  • rolling back to different tags since January + different nixpks-unstable / stable
  • full macos update and reinstall

I'm mostly debugging this with sway tho, as it happens to give bit more info. In general I see that I get software renderer on all wayland compositors and plasma.

I can see the module is correctly loaded and present in lsmod, also dmesg | grep asahi doesn't show any errors, and the CONFIG_DRM_ASAHI=m seems present in kernel builds.

I can also see card0, card1, card2 and renderD128 in ls /dev/dri output.

I have no idea why does mesa select the software renderer and I don't know how should I debug it, so I'm mostly trying next things of my mind. Right now I found all the kernel configs set in fedora, added them to the kernel-asahi and I'm trying to build, removing each module which fails one by one.

@zvolin
Copy link

zvolin commented Apr 10, 2024

btw I'm now sticking to the 'overlay' mode, from what I understand it requires more compiling but it should be the purest way to get this working

@BagMan9
Copy link
Author

BagMan9 commented Apr 10, 2024

@zvolin Let me know how successful you are - a couple days ago I was cleaning up my configuration & seem to be able to actually build overlay mode now - though I did not finish because it took adding 30 GB (!) of swap to even get halfway through w/o OOM errors. If that's what fixes it, I'll bite the bullet.

@zvolin
Copy link

zvolin commented Apr 10, 2024

Regarding oom I have just 16gb swap and the oom killer haven't woken up so far, but my config is very minimal since I'm just starting with nix. Nevertheless if you don't mind longer compilations you could likely limit jobs with -j, should reduce ram peaks

@BagMan9
Copy link
Author

BagMan9 commented Apr 11, 2024

Thanks for the tip, I didn't know that flag existed & I was able to successfully rebuild overnight. I'll start re-troubleshooting my issues this afternoon / tomorrow and report back.

@zvolin
Copy link

zvolin commented Apr 13, 2024

I was finally able to get everything running when manually guiding wlroots to choose correct gpu device:

WLR_DRM_DEVICES=/dev/dri/card0 Hyprland

Then glxinfo reports correct driver

nix-shell -p glxinfo --run 'glxinfo | grep "OpenGL renderer"'
OpenGL renderer string: Apple M2 (G14G B0)

I'm afraid this is mostly a workaround, not a correct solution, but I haven't yet researched more why doesn't it choose correct device. I have the kernel config tweaked a lot currently, will revert to the stock one and check if still the workaround works.

@zvolin
Copy link

zvolin commented Apr 13, 2024

can confirm this workaround works on a default kernel config, reverted all my changes

@zvolin
Copy link

zvolin commented Apr 13, 2024

I've set this variable in

environment.sessionVariables = {
  WLR_DRM_DEVICES = "/dev/dri/card0";
};

and it seems to work but apparently it launches sddm on the touchbar instead of edp-1 😅

@BagMan9
Copy link
Author

BagMan9 commented Apr 13, 2024

Interesting, I have not had that variable set, but when I have tried to use sddm it also displays to the touch bar.

I can confirm this works for me as well!

@zvolin
Copy link

zvolin commented Apr 13, 2024

I've been able to get rid of displaying on touchbar by plugging in the tiny-dfr as systemd service like:

    systemd.services.tiny-dfr = {
      description = "Tiny Apple silicon touch bar daemon";
      after = [
        "[email protected]"
      ];
      before = [
        "desktop-manager.service"
      ];

for now it just crashes for me, but it's enough to somehow 'reserve' the touchbar 😅

@thedaringdev
Copy link

@zvolin You are the man!!! Its working for me as well. Found this in the hyprland wiki about multi gpu.

@arminius-smh
Copy link

WLR_DRM_DEVICES=/dev/dri/card0 Hyprland

Also had this problem and tried to test it with this workaround, however setting it like this didn't work

environment.sessionVariables = {
  WLR_DRM_DEVICES = "/dev/dri/card0";
};

But with it being set explicitly in environment.sessionVariables it's working, thanks!

@n3oney
Copy link

n3oney commented May 16, 2024

I'm assuming this is an issue for people with a touchbar device? Is the touchbar being detected as a second gpu?

@BagMan9
Copy link
Author

BagMan9 commented May 16, 2024

@n3oney

I'm assuming this is an issue for people with a touchbar device? Is the touchbar being detected as a second gpu?

I think you are probably right! It looks like the unifying factor of problem devices are touchbar models.

@tpwrules Might it be worth putting something in the uefi-standalone doc about this? As the touch bar models age, more people are likely to install asahi & end up using this project, and having a blurb about this multi-gpu issue for touch bar models may save people a ton of time.

In the meantime, I'm closing this issue because it seems the problem & solution have been found.

@BagMan9 BagMan9 closed this as completed May 16, 2024
@arminius-smh
Copy link

Just in case this issue persists, WLR_DRM_DEVICES will have to be replaced with AQ_DRM_DEVICES for hyprlands switch away from wlroots to aquamarine

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

5 participants