nixpkgs/pkgs/games/katago/default.nix
Serge K d924de58be
cudaPackages.cudnn: migrate to redist cuda, fix missing zlib (#168748)
* cudaPackages.cudnn: migrate to redist cudaPackages

* cudaPackages.cudnn: fix missing zlib in rpath

* cudaPackages.cudnn: remove the propagated cudatoolkit

* cudaPackages.cudnn: use autoPatchelfHook

instead of custom find ... -exec ldd | grep routine
mark libcudnn_cnn_infer.so as needed for libcudnn.so on cudnn>=8.0.5
- a hint for autoPatchelf, as an alternative to manually adding $ORIGIN

* cudaPackages.cudnn: use automatic hooks for rpath

as a more common way to use addOpenGLRunpath and autoPatchelf with cudaPackages

* cudaPackages.cudnn: consume individual cuda packages

...since cudnn is part of the cuda package set

- introduces the scary useCudatoolkitRunfile function argument
  to discourage usage of the runfile-based cudatoolkit
- instead of the rather hidden useRedist term in let ... in
- repeats cudatoolkit_root pattern after cuda_joined in pytorch &c
  (the "toolchain view")
- redist packages are marked optional to support cuda<11.4 where the
  attributes for redist packages do not exist

* cudaPackages.cudnn: update to pname+version

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>

Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
2022-04-19 20:52:52 +02:00

111 lines
2.6 KiB
Nix

{ stdenv
, boost
, cmake
, cudaPackages
, eigen
, fetchFromGitHub
, gperftools
, lib
, libzip
, makeWrapper
, mesa
, ocl-icd
, opencl-headers
, openssl
, writeShellScriptBin
, enableAVX2 ? stdenv.hostPlatform.avx2Support
, enableBigBoards ? false
, enableCuda ? false
, enableContrib ? false
, enableGPU ? true
, enableTcmalloc ? true
}:
assert !enableGPU -> (
!enableCuda);
# N.b. older versions of cuda toolkit (e.g. 10) do not support newer versions
# of gcc. If you need to use cuda10, please override stdenv with gcc8Stdenv
stdenv.mkDerivation rec {
pname = "katago";
version = "1.11.0";
githash = "d8d0cd76cf73df08af3d7061a639488ae9494419";
src = fetchFromGitHub {
owner = "lightvector";
repo = "katago";
rev = "v${version}";
sha256 = "sha256-TZKkkYe2PPzgPhItBZBSJDwU3anhsujuCGIYru55OtU=";
};
fakegit = writeShellScriptBin "git" "echo ${githash}";
nativeBuildInputs = [
cmake
makeWrapper
];
buildInputs = [
libzip
boost
] ++ lib.optionals (!enableGPU) [
eigen
] ++ lib.optionals (enableGPU && enableCuda) [
cudaPackages.cudnn
cudaPackages.cudatoolkit
mesa.drivers
] ++ lib.optionals (enableGPU && !enableCuda) [
opencl-headers
ocl-icd
] ++ lib.optionals enableContrib [
openssl
] ++ lib.optionals enableTcmalloc [
gperftools
];
cmakeFlags = [
"-DNO_GIT_REVISION=ON"
] ++ lib.optionals (!enableGPU) [
"-DUSE_BACKEND=EIGEN"
] ++ lib.optionals enableAVX2 [
"-DUSE_AVX2=ON"
] ++ lib.optionals (enableGPU && enableCuda) [
"-DUSE_BACKEND=CUDA"
] ++ lib.optionals (enableGPU && !enableCuda) [
"-DUSE_BACKEND=OPENCL"
] ++ lib.optionals enableContrib [
"-DBUILD_DISTRIBUTED=1"
"-DNO_GIT_REVISION=OFF"
"-DGIT_EXECUTABLE=${fakegit}/bin/git"
] ++ lib.optionals enableTcmalloc [
"-DUSE_TCMALLOC=ON"
] ++ lib.optionals enableBigBoards [
"-DUSE_BIGGER_BOARDS_EXPENSIVE=ON"
];
preConfigure = ''
cd cpp/
'' + lib.optionalString enableCuda ''
export CUDA_PATH="${cudaPackages.cudatoolkit}"
export EXTRA_LDFLAGS="-L/run/opengl-driver/lib"
'';
installPhase = ''
runHook preInstall
mkdir -p $out/bin; cp katago $out/bin;
'' + lib.optionalString enableCuda ''
wrapProgram $out/bin/katago \
--prefix LD_LIBRARY_PATH : "/run/opengl-driver/lib"
'' + ''
runHook postInstall
'';
meta = with lib; {
description = "Go engine modeled after AlphaGo Zero";
homepage = "https://github.com/lightvector/katago";
license = licenses.mit;
maintainers = [ maintainers.omnipotententity ];
platforms = [ "x86_64-linux" ];
};
}