The cudainfo program checks that we can initialize the CUDA RT library and communicate with the driver. It can be used as standalone program or built with cudainfo.gpuCheck so it is executed inside the build sandbox to see if it also works fine. It uses the autoAddDriverRunpath hook to inject in the runpath the location of the library directory for CUDA libraries. Reviewed-by: Aleix Boné <abonerib@bsc.es>
		
			
				
	
	
		
			44 lines
		
	
	
		
			953 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			44 lines
		
	
	
		
			953 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
| {
 | |
|   stdenv
 | |
| , cudatoolkit
 | |
| , cudaPackages
 | |
| , autoAddDriverRunpath
 | |
| , strace
 | |
| }:
 | |
| 
 | |
| stdenv.mkDerivation (finalAttrs: {
 | |
|   name = "cudainfo";
 | |
|   src = ./.;
 | |
|   buildInputs = [
 | |
|     cudatoolkit # Required for nvcc
 | |
|     cudaPackages.cuda_cudart.static # Required for -lcudart_static
 | |
|     autoAddDriverRunpath
 | |
|   ];
 | |
|   installPhase = ''
 | |
|     mkdir -p $out/bin
 | |
|     cp -a cudainfo $out/bin
 | |
|   '';
 | |
|   passthru.gpuCheck = stdenv.mkDerivation {
 | |
|     name = "cudainfo-test";
 | |
|     requiredSystemFeatures = [ "cuda" ];
 | |
|     dontBuild = true;
 | |
|     nativeCheckInputs = [
 | |
|       finalAttrs.finalPackage # The cudainfo package from above
 | |
|       strace # When it fails, it will show the trace
 | |
|     ];
 | |
|     dontUnpack = true;
 | |
|     doCheck = true;
 | |
|     checkPhase = ''
 | |
|       if ! cudainfo; then
 | |
|         set -x
 | |
|         cudainfo=$(command -v cudainfo)
 | |
|         ldd $cudainfo
 | |
|         readelf -d $cudainfo
 | |
|         strace -f $cudainfo
 | |
|         set +x
 | |
|       fi
 | |
|     '';
 | |
|     installPhase = "touch $out";
 | |
|   };
 | |
| })
 |