Using nvidia open-source drivers

Since I didn’t really understand what action to take in my last question I’m still stuck with a Lenovo W520 that runs rather slowly with 22.11. The Nouveau drivers don’t work (they drive only the two external screens, leaving the laptop’s own display blank) so I wondered about the Nvidia open-source drivers. There’s a reference to them here but what actually do I have to change in /etc/nixos/configuration.nix to use the open source drivers? My configuration is this and my kernel is 5.15, so I suppose linuxKernel.packages.linux_5_15.nvidia_x11_production_open is the one I want but where does that go in /etc/nixos/configuration.nix?

From a blog that I read a while ago https://www.howtogeek.com/805004/nvidia-releases-open-source-linux-gpu-drivers-with-a-catch/, it said the open-source driver only supports graphics cards that use Nvidia’s Ampere and Turing architectures, which includes the GeForce 16-series, RTX 20-series, and newer GPUs. Anyone with a GTX 10-series card or other older hardware don’t have access to the new driver at all. So I’m not sure how nvidia open source drivers will help here.

I suspect that optimus just doesn’t work on Linux with your W520. I think your best bet is:

  1. Configure Xorg to use only your NVIDIA dGPU; See the first example on Nvidia - NixOS Wiki
  2. Build NixOS and set this new configuration to boot: nixos-rebuild boot
  3. Reboot and go into the BIOS and make the NVIDIA dGPU the default: Config → Display → Graphics Device → Discrete Graphics
  4. Cross your fingers and boot into NixOS.

It worked perfectly with 21.11.

If you want to use the official opensource nvidia driver, just configure everything else as usual, then flip hardware.nvidia.open to true. Still as suggested by @user2358, it has limited hardware support and is not as feature rich as the proprietary one.

2 Likes

Sorry to be dim but I’m not clear what you mean by configure everything as usual. Do you mean just insert in my configuration a line

open = true;

at about line 12?

Or (more likely, now I think about it), exclude that file altogether from the configuration, and include just the declaration hardware.nvidia.open = true; in my configuration.nix ?

As usual means leaving your current configuration as is, only adding the single line for open.

OK, I wasn’t certain because part of my current configuration seems to specify the proprietary drivers. I’ll just add the hardware.nvidia.open = true; declaration to that file.

You’d better check if your hardware is supported by the open source driver first (a full list is at GitHub - NVIDIA/open-gpu-kernel-modules: NVIDIA Linux open GPU kernel module source), that would likely be a no as you are now using the legacy_390 driver.

2 Likes

Yeah, the new drivers should not be usable for your GPU either. ooi, when you used nouveau, what was your configuration? It supposedly doesn’t use the same variables as nvidia to manage offload rendering, and I imagine the prime options are either noops or problematic.

I suspect by the symptoms that you ended up just using the nvidia GPU. What does glxinfo give you when using the nouveau driver?

Nouveau still doesn’t have powermanagement for anything though, you probably won’t have a fun time with it either. I think your best bet is just using the proprietary driver in sync mode, which I think it’s capable of (?).

As I’ve mentioned twice already, my current configuration is here.

Yep, I saw that, but that configuration isn’t using nouveau, and afaict there is no branch with nouveau either, so I can’t see what your configuration was when you were using it.

Looking at the nouveau documentation for optimus, and the NixOS implementation, NixOS currently just doesn’t support nouveau for offload rendering. It in fact blacklists the nouveau driver, which is probably why one of your displays isn’t working.

Sorry for my bluntness and thank you for your patience in the face of it. It is borne of frustration that Nvidia used to work perfectly, with 21.11, but for other reasons I could not just stay on that release.

The 22.11 Nouveau configuration is here. The fault is that it drives only the two external displays; the laptop display is blank, although with a text-mode blinking input caret at the top-left. Oh, and the 4k screen appears to be scaled to FHD, not in its native resolution.

The official closed-source drivers do kind-of work, but they suck CPU (the laptop fan runs constantly) and one external screen blinks every ten seconds or so. I can ameliorate the CPU load by renice on the X process but top doesn’t show anything else sucking CPU so it must be kernel + drivers.

If you’re completely stuck, maybe you can slowly bisect to see what upstream commit broke things? instead of going to 22.11 immediately, starting by going to 22.05, and then going only by commits (binary search style).

I don’t really have the time to get into that. I’ll just put up with it and try Nouveau every six months or so. Thanks again for your help.

I did find the time to install 22.05. It fixes the problem. 22.11 was almost workably slow but 22.05 works just fine.
TLater mentions bisecting. How does that work with NixOS, where so far as I am aware, the only method of updating is nixos-rebuild ?

You’ve effectively already started; bisecting is just the process of building various commits (in a binary search-like pattern) until you find the one that causes it, using some specific git tooling to help do this.

You can use nix-bisect for that. There’s an announcement for it here with some additional info: Nix-bisect -- Bisect Nix Builds

It seems to me it’s going to be difficult to use git-bisect because I can’t really write a test that git can find. I can only to bisect onto the problem commit myself, as I have to log in to the desktop and run it for a couple of minutes to work out whether or not the problem is present.
I have here a W520 running 22.05 and doing so well. I understand that rather than using nixos-rebuild switch --upgrade I can somehow use git commands to bisect between 22.05 and 22.11. Can you give me some pointers on that, since I was not even aware that nix packages were stored in a versioned repository.

I don’t think you necessarily need to use git here, you can just “upgrade” to intermediate unstable revisions between 22.05 and 22.11 to find the revision that broke the drivers for you.

Basically what nixos-rebuild switch --upgrade does is to upgrade the root channel before running nixos-rebuild switch normally. You can just set the channel to specific revisions, rebuild, and see if the drivers work or not.

Could you show your output of sudo nix-channel --list and nix-channel --list? Just so I can give you more correct instructions.

Also be aware that 23.05 was released in the meantime, so if you try upgrading once more, maybe you’re lucky and it’s fixed again?

Additionally, in case you don’t want to put in the effort into bisecting and just want a working system with the latest software otherwise, you can install older working drivers on a new release of NixOS as well.

1 Like

I did try 23.05 and the problem is not fixed, so here goes:

[mounty@pingala:~]$ sudo nix-channel --list
nixos https://nixos.org/channels/nixos-22.05

[mounty@pingala:~]$ nix-channel --list

[mounty@pingala:~]$

Thank you.