Gnome login freeze after enabling nvidia driver

Hi, I’m new to nixos and I’m trying to enable the nvidia driver for my GTX 650 GPU on my desktop.

According to the nixos wiki on nvidia and the nvidia legacy driver list I need a configuration alike the following:

  hardware.graphics = {
    enable = true;
  };

  services.xserver.videoDrivers = [ "nvidia" ];

  hardware.nvidia = {
    modesetting.enable = true;

    powerManagement.enable = false;
    powerManagement.finegrained = false;

    open = false;

    nvidiaSettings = true;

    # the gtx 650 can use legacy driver 470
    package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
  };

This install the driver, yes, but for the first 30 seconds it shows tty1 (frozen) and then switches to tty7. Gnome on tty7 is also frozen and I therefore cannot login. The screen is frozen for maybe 10 minutes at a time, unfreezes for 5 seconds and then is frozen for 10 minutes again. This repeats.

After it has initially switched to tty7, I can freely switch to tty1 and use the terminal (unfrozen thankfully!).

Using tty1 I can login and see the nvidia driver is installed, at least according to nvidia-smi:

$ nvidia-smi
NVIDIA-SMI 470.256.02   Driver Version: 470.256.02   CUDA Version: 11.4

GPU  Name        Persistence-M
Fan  Temp  Perf  Pwr:Usage/Cap
  0  NVIDIA GeForce ...  Off
10%   45C    P8    N/A /  N/A

Bus-Id        Disp.A
        Memory-Usage
00000000:08:00.0 N/A
    93MiB /   978MiB

Volatile Uncorr. ECC
GPU-Util  Compute M.
              MIG M.
                 N/A
    N/A      Default
                 N/A

Processes:
...
No running processes found

(sorry for the nvidia-smi formatting, I had to manually type it out!)

What steps can I take to resolve the issue of Gnome on tty7 freezing and also install the nvidia driver?

2 Likes

Welcome to NixOs :wave:

If you also have an integrated GPU then Gnome might be forcefully trying to use the Nvidia driver as reported in this issue and that could be causing issues since the driver is pretty outdated.

You can forcing it to use the integrated GPU by default and see if that fixes it:

    environment.variables = {
      # Use integrated GPU for gnome-shell
      # See https://gitlab.gnome.org/GNOME/mutter/-/issues/2969
      __EGL_VENDOR_LIBRARY_FILENAMES = "${pkgs.mesa.drivers.outPath}/share/glvnd/egl_vendor.d/50_mesa.json";
      __GLX_VENDOR_LIBRARY_NAME = "mesa";
      # Choose your correct Vulkan icd loader
      VK_DRIVER_FILES = "/run/opengl-driver/share/vulkan/icd.d/radeon_icd.x86_64.json";
      # VK_DRIVER_FILES = "/run/opengl-driver/share/vulkan/icd.d/intel_icd.x86_64.json";
    };

If you don’t have an integrated GPU or if that doesn’t work, does this still happen when you don’t use the proprietary drivers? I believe the open source nouveau drivers are enabled by default, so you just need to remove the hardware.nvidia block to test it.

2 Likes

Thanks for your time!

I only have the dedicated GPU and the DVI video cable is directly connected to it.

If I remove the hardware.nvidia = {...} block and also remove the services.xserver.videoDrivers = [ "nvidia" ];. It still launches in tty1 and is frozen for around 30 seconds. However, after switching to tty7 i can actually log in with gnome.

1 Like

After just keeping a minimal config

  hardware.graphics = {
    enable = true;
  };

  services.xserver.videoDrivers = [ "nvidia" ];

  hardware.nvidia = {
    package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
  };

It boots to tty1, freezes for 2 minutes and when it finally automatically switches to tty7 the screen resolution is very long and i cannot open gnome settings, alacritty nor any other installed terminal. Firefox works fine, but the mousepointer loading icon leaves artifacts across the screen.

If i then enable the mode setting option (modesetting.enable = true;) in the hardware.nvidia block. I get the previous error where i cannot login with tty7 and gnome.

1 Like

Can you try with the proprietary drivers again but with nouveau blacklisted?

boot.extraModprobeConfig = ''
  blacklist nouveau
  options nouveau modeset=0
'';

Also, you can run nvidia-bug-report.sh in tty1 then switch to tty7 to collect more information. After some time, it should create a log file in the same directory.

Something else you might want to try. Apparently gdm default to using Wayland instead of X11, but that might cause issues with the 470 drivers. Does Gnome still freeze with services.xserver.displayManager.gdm.wayland = false; ?

1 Like

Disabling nouveau unfortunately did not change anything, same issue.

I got the nvidia log file, although it is quite long (even too long for pastebin lol)

Should I paste it here? Or are there any specific interesting parts I should paste?

If it’s too long you can maybe split it and paste those separately to pastebin. If you can see something interesting like an error or something that would make it easier to only include relevant parts.

That said, you should try setting Wayland to false for gdm first.

1 Like

Thanks eljamm! Disabling gdm wayland seems to have resolved it.

I ended up with the following nvidia config:

hardware.graphics = {
    enable = true;
  };

  services.xserver.videoDrivers = [ "nvidia" ];

  hardware.nvidia = {
    package = config.boot.kernelPackages.nvidiaPackages.legacy_470;
  };

services.xserver.displayManager.gdm.wayland = false;
1 Like

Glad it’s working fine now.

Just as a general Gnome tip, you can apply the dynamic triple buffering patch, which will give you better performance. The only downside is you’d have to re-compile mutter each time it’s updated or if you update the patch, but that doesn’t happen that frequently, thankfully.

Hope you have a great time configuring your system :snowflake:

I will definitely take a look at that and the rest of the GNOME wiki. Great help man!

1 Like