Cuda not working

When I type nvidia-smi, I get


NVIDIA-SMI has failed because it couldn’t communicate with the NVIDIA driver. Make sure that the latest NVIDIA driver is installed and running.`

Based on the wiki, I did this for enabling cuda:

{
  pkgs,
  ...
}:
{

  environment.systemPackages = with pkgs; [
    libva
    libva-utils
  ];

  hardware.graphics = {
    enable = true;
  };

  services.xserver.videoDrivers = [ "nvidia" ];
  nix.settings.system-features = [ "cuda" ];

  hardware.nvidia = {
    modesetting.enable = true;
    open = true;
    nvidiaSettings = true;

  };
}

The GPU is GeForce MX330.

What am I doing wrong?

…we’ve been ignoring most of these questions on Discourse lately, that’s really a shame.

Seems like mx330 is a Pascal (cudaCapabilities = [ "6.0" ]) device. You’ll need hardware.nvidia.package = kernelPackages.nvidiaPackages.legacy_580 for that. It seems you also need an older kernel, one of

nix-repl> lib.filterAttrs (x: y: (lib.hasPrefix "linuxPackages" x) && (builtins.tryEval (builtins.isAttrs y)).success && y.nvidiaPackages.legacy_580 or null != null) pkgs |> lib.attrNames
[
  "linuxPackages"
  "linuxPackages_5_10"
  "linuxPackages_5_15"
  "linuxPackages_6_1"
  "linuxPackages_6_12"
  "linuxPackages_6_18"
  "linuxPackages_6_6"
  "linuxPackages_7_1"
  "linuxPackages_7_2"
  "linuxPackages_latest"
  "linuxPackages_rpi0"
  "linuxPackages_rpi02w"
  "linuxPackages_rpi1"
  "linuxPackages_rpi2"
  "linuxPackages_rpi3"
  "linuxPackages_rpi4"
  "linuxPackages_testing"
  "linuxPackages_xanmod"
  "linuxPackages_xanmod_latest"
  "linuxPackages_xanmod_stable"
  "linuxPackages_zen"
]

Today’s Nixpkgs has dropped support for old CUDAToolkit releases because they depend on gcc and clang versions that already had been end of life for years then. You can try just combining today’s nixos with the old nixpkgs (expect libc compatibility issues, can talk about those if they actually happen): nix repl -f "channel:nixos-25.05" --arg config '{ allowUnfree = true; cudaCapabilities = [ "6.0" ]; }'. You can also have a look at GitHub - nixos-cuda/cuda-legacy: Select CUDA package sets which have aged out of Nixpkgs. [maintainers=@ConnorBaker, @SomeoneSerge] · GitHub, but tbh I’ve no idea what state it’s in right now, better ask Connor

Appreciate all the info, thanks.