HowTo: Configure a NVIDIA Titan X (or any other GPU that needs proprietary drivers)

{ config, lib, pkgs, ...}:
{
  #legacy naming, not dependent on X11
  services.xserver.videoDrivers = [ "nvidia" ];

  hardware.nvidia = {
    powerManagement.enable = true;
    # fine grained power management, only works on Turing or newer
    powerManagement.finegrained = false;
    # GPU too old
    open = false;
  };
  
  # related user applications
  environment.systemPackages = with pkgs; [
    nvtopPackages.nvidia
  ];
}
1 Like

Thank you for sharing. Consider reviewing and contributing to NVIDIA - Official NixOS Wiki.

1 Like

Gah, all this cargo culting really bothers me.

Don’t follow this guide, and please don’t update the wiki with its contents. It’s misleading, like most posts on nvidia configuration around NixOS.

That’s the default. Don’t re-set defaults, it makes sensible upstream changes not take.

Granted, this isn’t your fault, it’s just nvidia being nvidia, but I’m so over everybody copying that experimental comment into their config.

The feature has been “experimental” for a damn decade at this point. Suspend simply doesn’t work with modern cards on systemd-based systems without it. Enable it if you ever plan to suspend your computer.

If you don’t plan to suspend your computer, this does nothing for you, but you might as well enable it. Worst case suspend fails, which it will do without this option anyway.

The purpose of this option is turning off the GPU fully when it isn’t being used, which only happens if you have a separate iGPU - given you’re not configuring offload, or udev rules for wayland, you shouldn’t be forcing that on.

Also, if your GPU actually was older than Turing, you should not be setting this, as your comment explains. Luckily for you, your GPU is in fact Turing or newer, so…

It is in fact supported. Titan X is a Turing or newer GPU. Set that to true.

Also the default. This one bothers me especially. You’re only setting this because people started disabling it a few years ago because there was a packaging bug for a solid two weeks.

Ever since people have been randomly disabling it because they looked at a 3 year old guide, but a subset of users experiment and notice that that isn’t necessary, so they set it to true even though setting it is a noop, presumably because they’re too lazy to read the options. Then more people come along and are 4th generation cargo-cultists who just copy setting it to true without thinking.

Unfortunately, unnecessarily-set-defaults never get removed from cargo-culted configurations, because you can’t see that removal, so 5th generation cargo cultists who fix this issue will never come along.

Unnecessary, there’s an enabled-by-default option which already sets that for you: hardware.nvidia.videoAcceleration.

Your comment is actually accurate; it doesn’t work without further configuration. Generally, I would not recommend using it. It’s written by a third party, very hacky, and if you want to use it in a browser (which is where 99% of media decoding happens) you must use Firefox (doesn’t work on chrome and its clones, including edge, brave and all the other edgily-named browsers) and disable its media decoding sandbox, which is a security risk.

If you do have an iGPU, use its media decoding, it will be more efficient and cover more codecs. Nvidia GPUs aren’t specialized for media decoding, that’s what iGPUs are for.

All the other configuration you did makes nvidia-modprobe superfluous; that package is for headless systems that don’t want to load the nvidia driver on boot. Don’t randomly include it on a desktop system.

You can use the other two packages if you like, but the nvidia-smi command that’s included by default does the same thing. You can include them in a guide, but I’d at least explain that those are optional software recommendations.

3 Likes

I’m wondering whether nixos-facter and a curated ruleset based on facts could actually help mitigating this cargo culting?!

2 Likes

Me too, and the underlying hardware.nvidia module needs work too.

Eventually I’ll get around to it, until then I’m just going to comment on every one of these posts.

It’s nontrivial because wayland + igpu + varying offload preferences add another layer of choice that isn’t simply represented in nixos-facter, as do details like headless/pure-LLM training/etc.

3 Likes

I removed the unneeded defaults. I like to set default values but then they should be commented out. Some things might be useful to disable when wished, not those ones.

But the Titan X does in fact require proprietary drivers.

1 Like

Right, I must have mistaken the RTX version. For the record, apparently the open module’s github readme has an exhaustive list, including PCI IDs: GitHub - NVIDIA/open-gpu-kernel-modules: NVIDIA Linux open GPU kernel module source · GitHub

1 Like