Change:
services.udev.extraRules = '' # Create /dev/nvidia-uvm when the nvidia-uvm module is loaded. <del> KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c $$(grep nvidia-frontend /proc/devices | cut -d   -f 1) 255'" KERNEL=="nvidia_modeset", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-modeset c $$(grep nvidia-frontend /proc/devices | cut -d   -f 1) 254'" KERNEL=="card*", SUBSYSTEM=="drm", DRIVERS=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia%n c $$(grep nvidia-frontend /proc/devices | cut -d   -f 1) %n'" </del> <ins> KERNEL=="nvidia", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidiactl c 195 255'" KERNEL=="nvidia_modeset", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-modeset c 195 254'" KERNEL=="card*", SUBSYSTEM=="drm", DRIVERS=="nvidia", PROGRAM="${pkgs.gnugrep}/bin/grep 'Device Minor:' /proc/driver/nvidia/gpus/%b/information",  RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia%c{3} c 195 %c{3}" </ins> KERNEL=="nvidia_uvm", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-uvm c $$(grep nvidia-uvm /proc/devices | cut -d   -f 1) 0'" <del> KERNEL=="nvidia_uvm", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-uvm-tools c $$(grep nvidia-uvm /proc/devices | cut -d   -f 1) 0'" </del> <ins> KERNEL=="nvidia_uvm", RUN+="${pkgs.runtimeShell} -c 'mknod -m 666 /dev/nvidia-uvm-tools c $$(grep nvidia-uvm /proc/devices | cut -d   -f 1) 1'" </ins> '' + optionalString cfg.powerManagement.finegrained '' # Remove NVIDIA USB xHCI Host Controller devices, if present ACTION=="add", SUBSYSTEM=="pci", ATTR{vendor}=="0x10de", ATTR{class}=="0x0c0330", ATTR{remove}="1"

Discussion:
PRIME render offload stopped working on the latest update both on 20.09 channel and unstable channel, I've found that changing the bootloader and removing nvidia-drm.modeset=1 sometimes makes it work and sometimes don't, but maybe it's something else I changed. xrandr --listproviders nvidia-offload glxinfo nvidia-smi Install 20.09 or 21.03 Run nixos-rebuild boot --upgrade Reboot Please run and paste the result. system: host os: multi-user?: sandbox: version: channels(root): nixpkgs:
output? GPU? I'm not really sure how to go about making it more resilient. I personally have a 1050 TI and have never had any problems (though I never go on stable since I'm following master so that might be where the source of issues are). It looks like you're missing from your providers, might be a issue regarding glamor then from an initial look?
Sorry, I have a 1050 4gb, I've been using this same since some months ago and never failed to work, so I'm assuming this is an issue with a recent update, here are the journalctl and journalctl -xe outputs:
I see the following in the log: I also see that if I enable modesetting. But have the same issue if I don't. It seems like the GPU is available and online but the GLX is not set up. For example I can see . But if I pass the I get:
just got it working at
I had the same issue with gdm, switching to lightdm fixed it. (I'm currently searching how to fix it for gdm).
Weird, it works fine for me with gdm.
I've tested the solution on and doesn't work for me, the issue I'm having is that gdm fails to initialize the GPU and consequently it can't configure prime render offload, I'm pretty sure this had to be an update to something (quite probably gdm) because the days before it worked fine with the same configuration. This is basically the root of the issue:
this may be relevant: I am without my notebook for now, but as soon as I can I will try to test PRIME on unstable.
on checking the logs there is some info regarding it in nvidia docs.

Will try some stuff and give an update.
I had to enable nvidiaPersistenced to get it working. I am also using gdm currently.
Awesome! I didn't have a lot of time to work on it these days but I will test it as soon as possible on my laptop. Interestingly, having to force the GPU to stay on means that at some point the GDM is failing to discover/activate the GPU...
Here's the curious thing. With wayland (not x11) everything works, except the NVIDIA settings app, with GDM. Things do not work with lightdm. displays the gears, lists the NVIDIA GPU (while plain lists the other GPU). Given NVIDIA shenanigans, this will probably change. I have an AMD (Renior) and NVIDIA laptop. My config:
Curious, I got access to my PRIME laptop again and did a quick test with GDM and LightDM testing only X11. In GDM I have the following error: ! I was using gdm only with . In LightDM it works perfectly. I did these tests in the same round without rebooting. I did this to see if other DMs had the error: . I'm using AwesomeWM (X11 Only) with NixOS Hardware settings for NVIDIA ().
Same with me AMD (Renoir) laptop with NVIDIA GPU works fine in wayland with somewhat the same config.
Somewhat related
I don't know if it's related, but I have this issue on my laptop as well. The reason was that the X server started up way too fast before the nvidia GPU was even ready. I fixed it by following article on ArchWiki which adds a systemd service which makes the login manager wait for nvidia GPU to be ready.
Interesting... It may be necessary to add in the NVIDIA module as well. To confirm: Are you using GDM? Did you add udev rules manually too?
No I am using SDDM. It worked fine on GDM since it runs on Wayland and by the time u login to the desktop, the GPU is ready anyway. And yes I these rules manually.
Hi, after an uncountable number of conf tries, reboots, I have found a few things that might help understand the issue: I have a Dell Inc.

XPS 15 9560, with: Mesa Intel HD Graphics 630 (KBL GT2) , connected to the integrated and external display NVIDIA GeForce GTX 1050/PCIe/SSE2, not connected to any display (muxless) I know this hardware can work well with primus because it does on Ubuntu, both in and modes. On NixOS, neither nor work for me however I found a few things. with this conf: The desktop starts in X11 mode even though I explicitly asked for wayland. And both and fail with errors. The nvidia kernel module is not even loaded anyway. Loading the nvidia module doesn't solve the issue, the only reliable way to make work that I found, is to run once. Then, will run fine without sudo, but will still not work. To make it work, you need to . However wayland still doesn't work... and it should! First, wayland doesn't fail or anything, it's just that something, somewhere tells gnome-shell explicitly to run with X11. To prove that wayland can indeed work with this conf, just launch gnome-shell directly from a tty: You'll get minimal a session, but: wayland is working! checked in gnome-settings, and with firefox-wayland in is working too! checked with Now I would love to be able to understand and fix display-manager to make it stop forcing gnome-shell to run with X11. Here is what I understand so far: lightdm has the same issue $XDGSESSIONTYPE is explicity set to "X11" somewhere, and it then disables gnome-wayland because of the line in :
I'm still trying to figure out where this XDGSESSIONTYPE is set to "x11". I have searched though my nix store and found nothing interesting searched through and found nothing interesting too searched through many packages' source code, like gnome-shell, gnome-session, gdm... and nothing The only thing I found is this: But even monkeypatching this to force wayland doesn't change anything
My previous investigations might be incorrect because I assumed the choice between wayland and x11 was constant when no changes was made to the system.

This is apparently not true on my system, with this conf: I get: wayland when booting, then after x11, then after wayland.. x11 wayland x11 ... So this is not random, after an even number of launches, I get wayland odd number of launches, I get x11 Am I the only one being cursed by this? EDIT: doing instead of restarting solves this issue...
To get back to the first issue, here's my method to get nvidia offloading: Start a session with a conf without nvidia, like: when logged in, change the conf to add the nvidia drivers, like so: then run:
Hello, I understood a few more things today: I d nvidia-smi to understand what made it succeed or fail as a user, and what made it help things when launched in rootIt appears that tried to open and if this node is not present: if not : fail if root: mknod it other programs using the nvidia libs will also try to open . is supposed to be created through this udev rule: , but: sometimes it works and nvidia0 is created sometimes it doesn't and nothing is created if the card has id 0 in , then creating the node manually or with will make work if the card has another id, I dont know how to make things work, just reboot and hope that the id will be 0 the next time sometimes nvidia1 is created and creating nvidia0 manually will not help.. again, reboot and hope for the best
New findings: so for prime to work we need to have , which means, we need to have the nvidia card being detected before the intel one in when I get card0 =nvidia and card1 =intel when I get card0 =intel and card1 =nvidia It feels cursed but that's what I found!
I just updated to latest nixos-unstable today with a turing GPU, and have power management and finegrained power management both enabled. The card will completely power off when not in use in this circumstance and become invisible to the kernel unless you also enable the nvidia persistence daemon, which I found in the Nvidia docs. After doing this, offload works fine for X11, so unless I'm missing something, I think we can probably close this.

Actually, it might be better to reopen since the only thing not working is wayland native applications. I can offload xwayland programs just fine though, although Unigine Superposition still thought it was using the Intel card in this case, but based on the benchmark score, it was definitely using the Nvidia card. This is probably an upstream issue though, and we'll probably have to wait for a driver level fix before we can offload wayland apps unfortunately.
NICE! I haven't used my PRIME for some time now (on NVIDIA desktop for now), but I think we need to just give a update in the docs, especially a note about the Wayland thing, and we are ready to go :P
This issue has been mentioned on NixOS Discourse. There might be relevant details there:
didn't seem to affect the order for me. Do we know how DRM decides what order to do?
I agree with everything that said. W.r.t. Wayland, I am getting very good and consistent results with everything working perfectly except for (which just completely fails to open). However, to even boot into Wayland, I also had to add: or else it would always crash on load, and fallback to X11. I've found that if you log in to a Wayland Gnome session, and it has and mounted, it's likely that it "failed" to load the Wayland session and defaulted to X11 -- I'm not sure why it decides to mount those two, however. By the way, It appears that Gnome on Wayland does not yet support systems with multiple GPUs (including hybrid GPUs fully), however, we can get by just fine if our display is only connected to a single GPU (e.g., our integrated GPUs) through enabling that flag (but, again, we forego ).

Describe the bug On my system the nvidia card is . However the udev rules create and . To Reproduce system where nvidia is card1 nvidia system and try to use card (e.g. run nvidia-smi) Expected behavior is created Screenshots Additional context Add any other context about the problem here. Notify maintainers Metadata
That is the line, where the nvidiaX file is created. Ubuntu is calling nvidia-smi to create the node files But there is a pull request to stop doing it, because it is a workaround see
I marked this as stale due to inactivity. &rarr;
I think I might have just had this issue. I reset my bios settings and it took me a while to realize it had re-enabled the Intel iGPU, and the display manager was failing to show up. I didn't realize until I saw 2 nodes in /dev/dri. It was working some of the time, I think it could be due to random module loading order? I think could be a related issue too.
Thanks for the ping. On workstation with Nvidia cards (dual Xeon, dual Nvidia 1070s), I'm using the Nouveau driver, and have the following /dev entries: I'm not sure how to see what this looks like using the Nvidia driver, since it can't boot into a usable state.
I think you would have a 3rd render node if you had the Intel driver loading like I had, but maybe there is an issue in general with Nvidia and multiple GPUs.
might be related, too? (I may be wrong since I'm just starting to dig into this because I think I'm having a very similar problem with one GPU not being accessible after boot.)