NVIDIA / cuda-samples

Samples for CUDA Developers which demonstrates features in CUDA Toolkit
Other
6.47k stars 1.83k forks source link

CDP is not detected when building samples on Nix #264

Open brynblack opened 6 months ago

brynblack commented 6 months ago

Details

When trying to compile cuda-samples under nixos-unstable, it will always error with undefined references to CDP related libraries and functions.

flake.nix

{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs = { nixpkgs, ... }:
    let
      system = "x86_64-linux";

      pkgs = import nixpkgs {
        inherit system;
        config = {
          allowUnfree = true;
          permittedInsecurePackages = [
            "freeimage-unstable-2021-11-01"
          ];
        };
      };

      shell = pkgs.mkShell {
        name = "cuda-env-shell";
        buildInputs = with pkgs; [
          cudatoolkit
          # samples
        ];
        shellHook = ''
          export CUDA_PATH=${pkgs.cudatoolkit}
          export EXTRA_LDFLAGS="-L/lib -L${pkgs.linuxPackages.nvidia_x11}/lib"
          export EXTRA_CCFLAGS="-I/usr/include"
          export LD_LIBRARY_PATH="${pkgs.linuxPackages.nvidia_x11}/lib"
        '';
      };
    in
    {
      devShells.${system}.default = shell;
      packages.${system}.cuda-samples = pkgs.callPackage ./generic.nix {
        cudaVersion = "12.4.1";
        hash = "sha256-vJmqAIrOiYTXuPLcqBXDdayQvdLpJGJYK60KEDT1sgo=";
        backendStdenv = pkgs.cudaPackages.backendStdenv;
      };
    };
}

Error

make[1]: Leaving directory '/build/source/Samples/3_CUDA_Features/bindlessTexture'
make[1]: Entering directory '/build/source/Samples/3_CUDA_Features/cdpAdvancedQuicksort'
>>> GCC Version is greater or equal to 5.0.0 <<<
/nix/store/cxb6q2wdmlxbhxsxhqz5s96q5vjniig4-cuda-merged-12.2/bin/nvcc -ccbin g++ -I../../../Common -m64 -dc -maxrregcount=64 --std=c++14 --threads 0 -gencode arch=compute_50,code=sm_50 -genco>
/nix/store/cxb6q2wdmlxbhxsxhqz5s96q5vjniig4-cuda-merged-12.2/bin/nvcc -ccbin g++ -I../../../Common -m64 -dc -maxrregcount=64 --std=c++14 --threads 0 -gencode arch=compute_50,code=sm_50 -genco>
/nix/store/cxb6q2wdmlxbhxsxhqz5s96q5vjniig4-cuda-merged-12.2/bin/nvcc -ccbin g++ -m64 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_>
nvlink error   : Undefined reference to '__cudaCDP2GetLastError' in 'cdpAdvancedQuicksort.o' (target: sm_50)
nvlink error   : Undefined reference to '__cudaCDP2PeekAtLastError' in 'cdpAdvancedQuicksort.o' (target: sm_50)
nvlink error   : Undefined reference to '__cudaCDP2GetErrorString' in 'cdpAdvancedQuicksort.o' (target: sm_50)
nvlink error   : Undefined reference to '__cudaCDP2StreamCreateWithFlags' in 'cdpAdvancedQuicksort.o' (target: sm_50)
nvlink error   : Undefined reference to '__cudaCDP2MemcpyAsync' in 'cdpAdvancedQuicksort.o' (target: sm_50)
nvlink error   : Undefined reference to '__cudaCDP2GetParameterBufferV2' in 'cdpAdvancedQuicksort.o' (target: sm_50)
nvlink error   : Undefined reference to '__cudaCDP2LaunchDeviceV2' in 'cdpAdvancedQuicksort.o' (target: sm_50)
make[1]: *** [Makefile:370: cdpAdvancedQuicksort] Error 255
make[1]: Leaving directory '/build/source/Samples/3_CUDA_Features/cdpAdvancedQuicksort'
make: *** [Makefile:45: Samples/3_CUDA_Features/cdpAdvancedQuicksort/Makefile.ph_build] Error 2
MarbolanGos commented 2 months ago

I have the same error in RHEL94 under an ARM64 with GH200:

[archambaf@pm5-nod68 cdpAdvancedQuicksort]$ make
>>> GCC Version is greater or equal to 5.0.0 <<<
/usr/local/cuda/bin/nvcc -ccbin g++ -I../../../Common -m64 -dc -maxrregcount=64 --std=c++14 --threads 0 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_87,code=sm_87 -gencode arch=compute_90,code=sm_90 -gencode arch=compute_90,code=compute_90 -o cdpAdvancedQuicksort.o -c cdpAdvancedQuicksort.cu
/usr/local/cuda/bin/nvcc -ccbin g++ -I../../../Common -m64 -dc -maxrregcount=64 --std=c++14 --threads 0 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_87,code=sm_87 -gencode arch=compute_90,code=sm_90 -gencode arch=compute_90,code=compute_90 -o cdpBitonicSort.o -c cdpBitonicSort.cu
/usr/local/cuda/bin/nvcc -ccbin g++ -m64 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_70,code=sm_70 -gencode arch=compute_75,code=sm_75 -gencode arch=compute_80,code=sm_80 -gencode arch=compute_86,code=sm_86 -gencode arch=compute_87,code=sm_87 -gencode arch=compute_90,code=sm_90 -gencode arch=compute_90,code=compute_90 -o cdpAdvancedQuicksort cdpAdvancedQuicksort.o cdpBitonicSort.o -lcudadevrt
nvlink error   : Undefined reference to '__cudaCDP2GetLastError' in 'cdpAdvancedQuicksort.o' (target: sm_87)
nvlink error   : Undefined reference to '__cudaCDP2PeekAtLastError' in 'cdpAdvancedQuicksort.o' (target: sm_87)
nvlink error   : Undefined reference to '__cudaCDP2GetErrorString' in 'cdpAdvancedQuicksort.o' (target: sm_87)
nvlink error   : Undefined reference to '__cudaCDP2StreamCreateWithFlags' in 'cdpAdvancedQuicksort.o' (target: sm_87)
nvlink error   : Undefined reference to '__cudaCDP2MemcpyAsync' in 'cdpAdvancedQuicksort.o' (target: sm_87)
nvlink error   : Undefined reference to '__cudaCDP2GetParameterBufferV2' in 'cdpAdvancedQuicksort.o' (target: sm_87)
nvlink error   : Undefined reference to '__cudaCDP2LaunchDeviceV2' in 'cdpAdvancedQuicksort.o' (target: sm_87)
make: *** [Makefile:383: cdpAdvancedQuicksort] Error 25