Skip to content

Commit

Permalink
tiny-cuda-nn: fix a couple of build issues
Browse files Browse the repository at this point in the history
The CUDA architecture detection code in tiny-cuda-nn's Torch bindings
convert CUDA capabilities to `int`s, which breaks with 9.0a. Filter
9.0a from the CUDA capabilities passed to TCNN_CUDA_ARCHITECTURES. Also
patch the Torch bindings to replace the hardcoded `-std=c++14` argument
to nvcc with `-std=c++17` for CUDA 11+ to fix the build.
  • Loading branch information
al3xtjames committed Nov 27, 2024
1 parent a3a6786 commit 4f6eafb
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions pkgs/by-name/ti/tiny-cuda-nn/package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
which,
}: let
inherit (lib) lists strings;
inherit (cudaPackages) backendStdenv flags;
inherit (cudaPackages) backendStdenv cudaVersion flags;

cuda-common-redist = with cudaPackages; [
(lib.getDev cuda_cudart) # cuda_runtime.h
Expand All @@ -36,6 +36,14 @@
name = "cuda-redist";
paths = cuda-common-redist;
};

unsupportedCudaCapabilities = [
"9.0a"
];

cudaCapabilities = lists.subtractLists unsupportedCudaCapabilities flags.cudaCapabilities;

cudaArchitecturesString = strings.concatMapStringsSep ";" flags.dropDot cudaCapabilities;
in
stdenv.mkDerivation (finalAttrs: {
pname = "tiny-cuda-nn";
Expand All @@ -52,6 +60,13 @@ in
hash = "sha256-qW6Fk2GB71fvZSsfu+mykabSxEKvaikZ/pQQZUycOy0=";
};

# Remove this once a release is made with
# https://github.com/NVlabs/tiny-cuda-nn/commit/78a14fe8c292a69f54e6d0d47a09f52b777127e1
postPatch = lib.optionals (strings.versionAtLeast cudaVersion "11.0") ''
substituteInPlace bindings/torch/setup.py --replace-fail \
"-std=c++14" "-std=c++17"
'';

nativeBuildInputs =
[
cmake
Expand Down Expand Up @@ -89,7 +104,7 @@ in
doCheck = false;

preConfigure = ''
export TCNN_CUDA_ARCHITECTURES="${flags.cmakeCudaArchitecturesString}"
export TCNN_CUDA_ARCHITECTURES="${cudaArchitecturesString}"
export CUDA_HOME="${cuda-native-redist}"
export LIBRARY_PATH="${cuda-native-redist}/lib/stubs:$LIBRARY_PATH"
export CC="${backendStdenv.cc}/bin/cc"
Expand Down

0 comments on commit 4f6eafb

Please sign in to comment.