Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cudaPackages: drop some runfile dependencies and fix a few builds #272063

Merged
merged 24 commits into from
Dec 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
5bda2ec
cudaPackagesGoogle: init, a package-set for jax and tf
SomeoneSerge Nov 24, 2023
3ee37e4
tensorrt: dont break eval for unrelated packages
SomeoneSerge Nov 24, 2023
e5b174b
opensubdiv: drop the cudatoolkit.run file, and respect cudaFlags
SomeoneSerge Nov 27, 2023
2381384
blender: drop cudatoolkit.runfile
SomeoneSerge Nov 27, 2023
5c2a368
catboost: downgrade to cudaPackages_11 because of unsupported archite…
SomeoneSerge Nov 27, 2023
361d7da
ctranslate2: fix the cuda 12 build
SomeoneSerge Nov 27, 2023
6c63202
cudaPackages.cuda_nvcc: fix (getExe cuda_nvcc)
SomeoneSerge Nov 27, 2023
0dc161b
cudaPackages_12.cutensor: init and fix
SomeoneSerge Nov 27, 2023
ee10810
python3Packages.cupy: fix (use older cutensor)
SomeoneSerge Nov 27, 2023
58819d6
ucx: fix the cudaPackages_12 variant; drop the cudatoolkit runfile de…
SomeoneSerge Nov 27, 2023
31f1b51
gromacs: drop cudatoolkit.run
SomeoneSerge Nov 28, 2023
0c4b1fc
openvino: opencvConfig.cmake attempts to find_package(CUDA)
SomeoneSerge Nov 28, 2023
9cc210a
nvidia-thrust: rm as deprecated
SomeoneSerge Nov 28, 2023
3e37f3c
ucc: drop the cudatoolkit runfile
SomeoneSerge Dec 3, 2023
0f047c2
ucc: respect cudaFlags
SomeoneSerge Dec 3, 2023
4c6d2b8
openmpi: drop the cudatoolkit runfile
SomeoneSerge Dec 3, 2023
9d729f2
python311Packages.torchWithCuda: drop cuda_cudart.static at runtime
SomeoneSerge Dec 4, 2023
a7891f2
cudaPackages.setupCudaHook: fix cudart flags
SomeoneSerge Dec 4, 2023
182e6b4
cudaPackages.setupCudaHook: rewrite cudartFlags, remove infinite recu…
SomeoneSerge Dec 4, 2023
e084a6c
cudaPackages_11_3.saxpy: fallback to the cudatoolkit runfile
SomeoneSerge Dec 4, 2023
d031523
cudaPackages.cuda_nvcc: fix hook's offsets (-1, -1) -> (-1, 0)
SomeoneSerge Dec 4, 2023
37ec2cb
cudaPackages.setupCudaHook: source only from nativeBuildInputs
SomeoneSerge Dec 4, 2023
b9635cf
tiny-cuda-nn: cuda_cccl required with the newer cuda
SomeoneSerge Dec 5, 2023
18a2e51
tiny-cuda-nn: prune runtime closure
SomeoneSerge Dec 5, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions pkgs/applications/misc/blender/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,10 @@ stdenv.mkDerivation (finalAttrs: rec {
nativeBuildInputs =
[ cmake makeWrapper python310Packages.wrapPython llvmPackages.llvm.dev
]
++ lib.optionals cudaSupport [ addOpenGLRunpath ]
++ lib.optionals cudaSupport [
addOpenGLRunpath
cudaPackages.cuda_nvcc
]
++ lib.optionals waylandSupport [ pkg-config ];
buildInputs =
[ boost ffmpeg gettext glew ilmbase
Expand Down Expand Up @@ -87,7 +90,7 @@ stdenv.mkDerivation (finalAttrs: rec {
llvmPackages.openmp SDL Cocoa CoreGraphics ForceFeedback OpenAL OpenGL
])
++ lib.optional jackaudioSupport libjack2
++ lib.optional cudaSupport cudaPackages.cudatoolkit
++ lib.optionals cudaSupport [ cudaPackages.cuda_cudart ]
++ lib.optional colladaSupport opencollada
++ lib.optional spaceNavSupport libspnav;
pythonPath = with python310Packages; [ numpy requests zstandard ];
Expand Down
32 changes: 27 additions & 5 deletions pkgs/applications/science/molecular-dynamics/gromacs/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
{ lib, stdenv, fetchurl, cmake, hwloc, fftw, perl, blas, lapack, mpi, cudatoolkit
{ lib
, stdenv
, fetchurl
, cmake
, hwloc
, fftw
, perl
, blas
, lapack
, mpi
, cudaPackages
, plumed
, singlePrec ? true
, config
Expand All @@ -9,6 +19,8 @@
}:

let
inherit (cudaPackages.cudaFlags) cudaCapabilities dropDot;

# Select reasonable defaults for all major platforms
# The possible values are defined in CMakeLists.txt:
# AUTO None SSE2 SSE4.1 AVX_128_FMA AVX_256 AVX2_256
Expand Down Expand Up @@ -52,7 +64,7 @@ in stdenv.mkDerivation rec {
nativeBuildInputs =
[ cmake ]
++ lib.optional enablePlumed plumed
;
++ lib.optionals enableCuda [ cudaPackages.cuda_nvcc ];

buildInputs = [
fftw
Expand All @@ -61,13 +73,17 @@ in stdenv.mkDerivation rec {
blas
lapack
] ++ lib.optional enableMpi mpi
++ lib.optional enableCuda cudatoolkit
;
++ lib.optionals enableCuda [
cudaPackages.cuda_cudart
cudaPackages.libcufft
cudaPackages.cuda_profiler_api
];

propagatedBuildInputs = lib.optional enableMpi mpi;
propagatedUserEnvPkgs = lib.optional enableMpi mpi;

cmakeFlags = [
(lib.cmakeBool "GMX_HWLOC" true)
"-DGMX_SIMD:STRING=${SIMD cpuAcceleration}"
"-DGMX_OPENMP:BOOL=TRUE"
"-DBUILD_SHARED_LIBS=ON"
Expand All @@ -87,7 +103,13 @@ in stdenv.mkDerivation rec {
else [
"-DGMX_MPI:BOOL=FALSE"
]
) ++ lib.optional enableCuda "-DGMX_GPU=CUDA";
) ++ lib.optionals enableCuda [
"-DGMX_GPU=CUDA"
(lib.cmakeFeature "CMAKE_CUDA_ARCHITECTURES" (builtins.concatStringsSep ";" (map dropDot cudaCapabilities)))

# Gromacs seems to ignore and override the normal variables, so we add this ad hoc:
(lib.cmakeFeature "GMX_CUDA_TARGET_COMPUTE" (builtins.concatStringsSep ";" (map dropDot cudaCapabilities)))
];

postInstall = ''
moveToOutput share/cmake $dev
Expand Down
17 changes: 17 additions & 0 deletions pkgs/development/compilers/cudatoolkit/extension.nix
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,28 @@ final: prev: let
{
name = "setup-cuda-hook";

# Point NVCC at a compatible compiler
substitutions.ccRoot = "${backendStdenv.cc}";

# Required in addition to ccRoot as otherwise bin/gcc is looked up
# when building CMakeCUDACompilerId.cu
substitutions.ccFullPath = "${backendStdenv.cc}/bin/${backendStdenv.cc.targetPrefix}c++";

# Required by cmake's enable_language(CUDA) to build a test program
# When implementing cross-compilation support: this is
# final.pkgs.targetPackages.cudaPackages.cuda_cudart
# Given the multiple-outputs each CUDA redist has, we can specify the exact components we
# need from the package. CMake requires:
# - the cuda_runtime.h header, which is in the dev output
# - the dynamic library, which is in the lib output
# - the static library, which is in the static output
substitutions.cudartFlags = let cudart = final.cuda_cudart; in
builtins.concatStringsSep " " (final.lib.optionals (final ? cuda_cudart) ([
"-I${final.lib.getDev cudart}/include"
"-L${final.lib.getLib cudart}/lib"
] ++ final.lib.optionals (builtins.elem "static" cudart.outputs) [
"-L${cudart.static}/lib"
]));
}
./hooks/setup-cuda-hook.sh)
{ });
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# shellcheck shell=bash

# Only run the hook from nativeBuildInputs
(( "$hostOffset" == -1 && "$targetOffset" == 0)) || return 0

echo Sourcing setup-cuda-hook >&2

extendCUDAToolkit_ROOT() {
Expand Down Expand Up @@ -55,8 +58,9 @@ setupCUDAToolkitCompilers() {

# CMake's enable_language(CUDA) runs a compiler test and it doesn't account for
# CUDAToolkit_ROOT. We have to help it locate libcudart
if [[ -z "${nvccDontPrependCudartFlags-}" ]] ; then
export NVCC_APPEND_FLAGS+=" -L@cudartLib@/lib -L@cudartStatic@/lib -I@cudartInclude@/include"
local cudartFlags="@cudartFlags@"
if [[ -z "${nvccDontPrependCudartFlags-}" ]] && [[ -n "${cudartFlags:-}" ]] ; then
export NVCC_APPEND_FLAGS+=" $cudartFlags"
fi
}

Expand Down
35 changes: 6 additions & 29 deletions pkgs/development/compilers/cudatoolkit/redist/overrides.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,37 +51,14 @@ in
]
);

cuda_nvcc = prev.cuda_nvcc.overrideAttrs (_: {
# Required by cmake's enable_language(CUDA) to build a test program
# When implementing cross-compilation support: this is
# final.pkgs.targetPackages.cudaPackages.cuda_cudart
env = {
# Given the multiple-outputs each CUDA redist has, we can specify the exact components we
# need from the package. CMake requires:
# - the cuda_runtime.h header, which is in the dev output
# - the dynamic library, which is in the lib output
# - the static library, which is in the static output
cudartInclude = "${final.cuda_cudart.dev}";
cudartLib = "${final.cuda_cudart.lib}";
cudartStatic = "${final.cuda_cudart.static}";
};

# Point NVCC at a compatible compiler

# Desiredata: whenever a package (e.g. magma) adds cuda_nvcc to
# nativeBuildInputs (offsets `(-1, 0)`), magma should also source the
# setupCudaHook, i.e. we want it the hook to be propagated into the
# same nativeBuildInputs.
#
# Logically, cuda_nvcc should include the hook in depsHostHostPropagated,
# so that the final offsets for the propagated hook would be `(-1, 0) +
# (0, 0) = (-1, 0)`.
#
# In practice, TargetTarget appears to work:
# https://gist.github.com/fd80ff142cd25e64603618a3700e7f82
depsTargetTargetPropagated = [
cuda_nvcc = prev.cuda_nvcc.overrideAttrs (oldAttrs: {
propagatedBuildInputs = [
final.setupCudaHook
];

meta = (oldAttrs.meta or { }) // {
mainProgram = "nvcc";
};
});

cuda_nvprof = prev.cuda_nvprof.overrideAttrs (oldAttrs: {
Expand Down
22 changes: 12 additions & 10 deletions pkgs/development/compilers/cudatoolkit/saxpy/default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
{ autoAddOpenGLRunpathHook
, backendStdenv
, cmake
, cuda_cccl
, cuda_cudart
, cuda_cccl ? null
, cuda_cudart ? null
, cudaFlags
, cuda_nvcc
, cuda_nvcc ? null
, cudatoolkit ? null
, lib
, libcublas
, libcublas ? null
, setupCudaHook
, stdenv
}:
Expand All @@ -17,23 +18,24 @@ backendStdenv.mkDerivation {

src = ./.;

buildInputs = [
buildInputs = lib.optionals (cuda_cudart != null) [
libcublas
cuda_cudart
cuda_cccl
] ++ lib.optionals (cuda_cudart == null) [
cudatoolkit
];
nativeBuildInputs = [
cmake

# NOTE: this needs to be pkgs.buildPackages.cudaPackages_XX_Y.cuda_nvcc for
# cross-compilation to work. This should work automatically once we move to
# spliced scopes. Delete this comment once that happens
cuda_nvcc

# Alternatively, we could remove the propagated hook from cuda_nvcc and add
# directly:
# setupCudaHook
autoAddOpenGLRunpathHook
] ++ lib.optionals (cuda_nvcc != null) [
cuda_nvcc
] ++ lib.optionals (cuda_nvcc == null) [
cudatoolkit
];

cmakeFlags = [
Expand Down
1 change: 1 addition & 0 deletions pkgs/development/libraries/ctranslate2/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ stdenv.mkDerivation rec {
buildInputs = lib.optionals withMkl [
mkl
] ++ lib.optionals withCUDA [
cudaPackages.cuda_cccl # <nv/target> required by the fp16 headers in cudart
cudaPackages.cuda_cudart
cudaPackages.libcublas
cudaPackages.libcurand
Expand Down
5 changes: 3 additions & 2 deletions pkgs/development/libraries/hwloc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ stdenv.mkDerivation rec {
];

# XXX: libX11 is not directly needed, but needed as a propagated dep of Cairo.
nativeBuildInputs = [ pkg-config ];
nativeBuildInputs = [ pkg-config ]
++ lib.optionals enableCuda [ cudaPackages.cuda_nvcc ];

buildInputs = [ expat ncurses ]
++ lib.optionals x11Support [ cairo libX11 ]
++ lib.optionals stdenv.isLinux [ numactl ]
++ lib.optional enableCuda cudaPackages.cudatoolkit;
++ lib.optionals enableCuda [ cudaPackages.cuda_cudart ];

# Since `libpci' appears in `hwloc.pc', it must be propagated.
propagatedBuildInputs = lib.optional stdenv.isLinux pciutils;
Expand Down
102 changes: 0 additions & 102 deletions pkgs/development/libraries/nvidia-thrust/default.nix

This file was deleted.

2 changes: 2 additions & 0 deletions pkgs/development/libraries/opencv/4.x.nix
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,8 @@ effectiveStdenv.mkDerivation {
'';

passthru = {
cudaSupport = enableCuda;

tests = {
inherit (gst_all_1) gst-plugins-bad;
}
Expand Down
Loading