{"id":47714091,"url":"https://github.com/applicative-systems/nixos-gpu-tests","last_synced_at":"2026-04-02T18:47:29.993Z","repository":{"id":347323449,"uuid":"1192758204","full_name":"applicative-systems/nixos-gpu-tests","owner":"applicative-systems","description":"GPU-enabled tests with CUDA in the NixOS integration test driver","archived":false,"fork":false,"pushed_at":"2026-03-27T13:46:59.000Z","size":1594,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-27T23:30:02.501Z","etag":null,"topics":["amd","cuda","nix","nixos","nvidia","nvidia-gpu","radeon","sandbox","test","test-automation","test-automation-framework","test-framework","zluda"],"latest_commit_sha":null,"homepage":"https://nixcademy.com","language":"Nix","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/applicative-systems.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-03-26T14:32:47.000Z","updated_at":"2026-03-27T14:17:35.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/applicative-systems/nixos-gpu-tests","commit_stats":null,"previous_names":["applicative-systems/nixos-gpu-tests"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/applicative-systems/nixos-gpu-tests","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/applicative-systems%2Fnixos-gpu-tests","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/applicative-systems%2Fnixos-gpu-tests/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/applicative-systems%2Fnixos-gpu-tests/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/applicative-systems%2Fnixos-gpu-tests/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/applicative-systems","download_url":"https://codeload.github.com/applicative-systems/nixos-gpu-tests/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/applicative-systems%2Fnixos-gpu-tests/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31313373,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amd","cuda","nix","nixos","nvidia","nvidia-gpu","radeon","sandbox","test","test-automation","test-automation-framework","test-framework","zluda"],"created_at":"2026-04-02T18:47:29.117Z","updated_at":"2026-04-02T18:47:29.980Z","avatar_url":"https://github.com/applicative-systems.png","language":"Nix","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GPU/CUDA in the NixOS integration test driver\n\nThis repository contains everything needed to run CUDA inside the NixOS integration test driver.\n\n- To learn how to configure your system and run this, see [Getting started](#getting-started)\n- In the section [Necessary patches](#necessary-patches), we explain the residual things that are not (*yet*!) in nixpkgs.\n\n![CUDA in the test driver in action](./demo.gif)\n\n## [Getting started]\n\nTo run CUDA inside the sandbox, a list of host paths need to be mapped into the sandbox.\nHence, the first step is configuring the host.\n\n### Host configuration\n\nAt first, make sure that your Nix daemon is configured to run [the relatively new NixOS integration test container feature](https://nixcademy.com/posts/faster-cheaper-nixos-integration-tests-with-containers/) at all:\n\n```nix\n{\n  nix.settings.auto-allocate-uids = true;\n\n  nix.settings.experimental-features = [\n    \"auto-allocate-uids\"\n    \"cgroups\"\n  ];\n\n  nix.settings.extra-system-features = [\n    \"uid-range\"\n  ];\n\n  # this one is only necessary for container \u003c-\u003e VM networking\n  nix.settings.extra-sandbox-paths = [\n    \"/dev/net\"\n  ];\n}\n```\n\n#### NVIDIA\n\nOn NVIDIA hosts, also enable the following configuration to ensure the right paths are visible inside the sandbox:\n\n```nix\n{\n  hardware.graphics.enable = true;\n\n  # ensure proprietary driver\n  boot.blacklistedKernelModules = [ \"nouveau\" ];\n  services.xserver.videoDrivers = [ \"nvidia\" ];\n\n  # ensure proprietary and performance settings and latest driver\n  boot.kernelPackages = pkgs.linuxPackages_latest;\n  hardware.nvidia = {\n    modesetting.enable = true;\n    powerManagement.enable = false;\n    powerManagement.finegrained = false;\n    open = false;\n    nvidiaSettings = true;\n    package = config.boot.kernelPackages.nvidiaPackages.latest;\n  };\n\n  # ensure sandbox paths\n  programs.nix-required-mounts = {\n    enable = true;\n    presets.nvidia-gpu.enable = true;\n  };\n}\n```\n\n#### [AMD]\n\n*(ignore this section if you are only interested in NVIDIA)*\n\nSimilar to the NVIDIA scenario, but slightly different configuration is necessary on AMD GPU hosts.\n\nThis configuration snippet, based on the not-yet-upstreamed [nixpkgs branch](https://github.com/tfc/nixpkgs/tree/zluda-profile), contains the minimal needed configuration for AMD devices:\n\n```nix\n{\n  hardware.graphics.enable = true;\n  hardware.amdgpu.zluda.enable = true;\n\n  programs.nix-required-mounts = {\n    enable = true;\n    presets.zluda.enable = true;\n  };\n}\n```\n\n#### Running GPU/CUDA stuff in the sandbox\n\nTo check if your nix daemon sandbox settings are correct, first run the minimal [saxpy](https://developer.nvidia.com/blog/six-ways-saxpy/) demo app in the sandbox without the NixOS integration test driver:\n\n```console\n$ nix build -L .#cuda-sandbox\nsaxdemo\u003e Start\nsaxdemo\u003e Runtime version: 12090\nsaxdemo\u003e Driver version: 13010\nsaxdemo\u003e Host memory initialized, copying to the device\nsaxdemo\u003e Scheduled a cudaMemcpy, calling the kernel\nsaxdemo\u003e Scheduled a kernel call\nsaxdemo\u003e Max error: 0.000000\n```\n\nIf the output looks roughly like this without errors, your Nix sandbox works with CUDA!\n\nTo run the minimal saxpy demo app in the prepared minimal container test, run:\n\n```console\n$ nix build -L .#cuda-container-test-nvidia\n# ...\nvm-test-run-saxpy-cuda-test\u003e container: (finished: must succeed: saxpy 2\u003e\u00261, in 3.38 seconds)\nvm-test-run-saxpy-cuda-test\u003e (finished: run the VM test script, in 3.38 seconds)\nvm-test-run-saxpy-cuda-test\u003e test script finished in 3.41s\nvm-test-run-saxpy-cuda-test\u003e cleanup\n# ...\n```\n\nThe same test but prepared for AMD GPUs exists as attribute `.#cuda-container-test-amd`.\n\n## [Necessary patches]\n\n### GPU support in the NixOS test driver\n\nThe foregoing work to upstream the necessary capabilities in nixpkgs happened in these PRs, which already **have** been merged:\n\n- [`nixos/nspawn-container: init a new nspawn-container profile` #470248](https://github.com/NixOS/nixpkgs/pull/470248)\n- [`nixos/test-driver: add support for nspawn containers` #478109 ](https://github.com/NixOS/nixpkgs/pull/478109)\n- [`nixos/doc: document systemd-nspawn test containers` #479968](https://github.com/NixOS/nixpkgs/pull/479968)\n- [`nixos-test-driver: Make overridable` #503686](https://github.com/NixOS/nixpkgs/pull/503686)\n\nThis work implements containers in the test driver but does not yet allow for GPU related access in the container.\n\nWhat's missing are the following two things:\n\n- the test driver needs to be patched to provide certain `/run/...` paths from the host sandbox to the container\n  - this flake uses the following [overlay.nix file to inject this change](./overlay.nix)\n- it is necessary to attach `\"cuda\"` as a required feature to the test derivation\n  - this flake does this [here](https://github.com/applicative-systems/nixos-gpu-tests/blob/main/flake.nix#L48)\n\nFor you as an outside user of this feature, this means:\n\n1. Use this [overlay.nix](./overlay.nix) when importing nixpkgs ([like here](https://github.com/applicative-systems/nixos-gpu-tests/blob/main/flake.nix#L36))\n2. Add the `\"cuda\"` feature to the required list of your GPU test derivation ([like here](https://github.com/applicative-systems/nixos-gpu-tests/blob/main/flake.nix#L48))\n\nThese patches will likely disappear in the future - we will keep this repository up2date.\n\n### Sandbox configuration with AMD and ZLUDA\n\n*(ignore this section if you are only interested in NVIDIA)*\n\nThe configuration snippet in the [AMD](#amd) section will only work with upstream nixpkgs after the following PRs have been finalized and merged:\n\n- [`nix-required-mounts: fix paths` #500971](https://github.com/NixOS/nixpkgs/pull/500971)\n  - This PR fixes bugs in `nix-required-mounts`. This application is being used as a prebuild hook that educates the nix daemon about the necessary paths in the sandbox to provde access to the GPU and libraries.\n- [`programs.nix-required-mounts.profiles.zluda.enable: init` #501095](https://github.com/NixOS/nixpkgs/pull/501095)\n  - This PR introduces a handy helper configuration attribute to automatically configure `nix-required-mounts` for AMD GPUs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapplicative-systems%2Fnixos-gpu-tests","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fapplicative-systems%2Fnixos-gpu-tests","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fapplicative-systems%2Fnixos-gpu-tests/lists"}