Home Explore Blog Models CI



nixpkgs

8th chunk of `doc/languages-frameworks/cuda.section.md`
8e7a28f3ef5002077938a873d8f354a8db7eaa1b64b6d7d90000000100000a6a
   - NOTE: Typically, we use the Ubuntu runfile. It is unclear if the runfile for other distributions will work.

3. Take the link provided by the installer instructions on the webpage after selecting the installer type and get its hash by running:

   ```bash
   nix store prefetch-file --hash-type sha256 <link>
   ```

4. Update `pkgs/development/cuda-modules/cudatoolkit/releases.nix` to include the release.

#### Updating the CUDA package set {#cuda-updating-the-cuda-package-set}

1. Include a new `cudaPackages_<major>_<minor>` package set in `pkgs/top-level/all-packages.nix`.

   - NOTE: Changing the default CUDA package set should occur in a separate PR, allowing time for additional testing.

2. Successfully build the closure of the new package set, updating `pkgs/development/cuda-modules/cuda/overrides.nix` as needed. Below are some common failures:

| Unable to ...  | During ...                       | Reason                                           | Solution                   | Note                                                         |
| -------------- | -------------------------------- | ------------------------------------------------ | -------------------------- | ------------------------------------------------------------ |
| Find headers   | `configurePhase` or `buildPhase` | Missing dependency on a `dev` output             | Add the missing dependency | The `dev` output typically contains the headers               |
| Find libraries | `configurePhase`                 | Missing dependency on a `dev` output             | Add the missing dependency | The `dev` output typically contains CMake configuration files |
| Find libraries | `buildPhase` or `patchelf`       | Missing dependency on a `lib` or `static` output | Add the missing dependency | The `lib` or `static` output typically contains the libraries |

Failure to run the resulting binary is typically the most challenging to diagnose, as it may involve a combination of the aforementioned issues. This type of failure typically occurs when a library attempts to load or open a library it depends on that it does not declare in its `DT_NEEDED` section. Try the following debugging steps:

1. First ensure that dependencies are patched with [`autoAddDriverRunpath`](https://search.nixos.org/packages?channel=unstable&type=packages&query=autoAddDriverRunpath).
2. Failing that, try running the application with [`nixGL`](https://github.com/guibou/nixGL) or a similar wrapper tool.
3. If that works, it likely means that the application is attempting to load a library that is not in the `RPATH` or `RUNPATH` of the binary.

### Writing tests {#cuda-writing-tests}

Title: Updating CUDA Package Sets and Troubleshooting Build/Runtime Failures in Nixpkgs
Summary
This chunk concludes the instructions for updating the deprecated CUDA Toolkit runfile installer, detailing how to obtain its hash and update `pkgs/development/cuda-modules/cudatoolkit/releases.nix`. It then outlines the process for updating the CUDA package set in `pkgs/top-level/all-packages.nix`, emphasizing the need for successful builds and updates to `pkgs/development/cuda-modules/cuda/overrides.nix`. A table is provided to address common build failures (e.g., missing headers or libraries) during `configurePhase` or `buildPhase`. The document also offers advanced debugging steps for challenging runtime failures, suggesting the use of `autoAddDriverRunpath`, `nixGL`, and checking `RPATH`/`RUNPATH` issues, before introducing a new section on 'Writing tests'.