2020-03-08 23:36:58 +00:00
|
|
|
{ stdenv
|
|
|
|
, boost
|
|
|
|
, cmake
|
2023-03-31 12:56:07 +00:00
|
|
|
, config
|
2022-04-03 09:19:04 +00:00
|
|
|
, cudaPackages
|
2021-01-14 15:41:01 +00:00
|
|
|
, eigen
|
2020-03-08 23:36:58 +00:00
|
|
|
, fetchFromGitHub
|
2021-01-14 15:41:01 +00:00
|
|
|
, gperftools
|
|
|
|
, lib
|
|
|
|
, libzip
|
|
|
|
, makeWrapper
|
|
|
|
, mesa
|
|
|
|
, ocl-icd
|
|
|
|
, opencl-headers
|
|
|
|
, openssl
|
|
|
|
, writeShellScriptBin
|
2021-01-04 09:59:14 +00:00
|
|
|
, enableAVX2 ? stdenv.hostPlatform.avx2Support
|
2023-07-20 15:08:19 +00:00
|
|
|
, backend ? if config.cudaSupport then "cuda" else "opencl"
|
2020-08-26 15:34:30 +00:00
|
|
|
, enableBigBoards ? false
|
2021-01-14 15:41:01 +00:00
|
|
|
, enableContrib ? false
|
2021-01-04 09:59:14 +00:00
|
|
|
, enableTcmalloc ? true
|
2024-03-05 19:54:48 +00:00
|
|
|
, enableTrtPlanCache ? false
|
2021-01-04 09:59:14 +00:00
|
|
|
}:
|
2020-03-08 23:36:58 +00:00
|
|
|
|
2023-01-11 19:05:46 +00:00
|
|
|
assert lib.assertOneOf "backend" backend [ "opencl" "cuda" "tensorrt" "eigen" ];
|
2020-08-23 21:00:52 +00:00
|
|
|
|
2021-12-08 17:53:25 +00:00
|
|
|
# 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 {
|
2020-03-08 23:36:58 +00:00
|
|
|
pname = "katago";
|
2023-12-28 07:30:52 +00:00
|
|
|
version = "1.14.0";
|
|
|
|
githash = "c6de1bbda837a0717eaeca46102f7326ed0da0d4";
|
2020-03-08 23:36:58 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "lightvector";
|
|
|
|
repo = "katago";
|
2020-08-23 21:00:52 +00:00
|
|
|
rev = "v${version}";
|
2023-12-28 07:30:52 +00:00
|
|
|
sha256 = "sha256-0WB/weQIJkLXedcOJO7D/N85oXTufvbmyfIp8XdrACg=";
|
2020-03-08 23:36:58 +00:00
|
|
|
};
|
|
|
|
|
2021-01-14 15:41:01 +00:00
|
|
|
fakegit = writeShellScriptBin "git" "echo ${githash}";
|
|
|
|
|
2020-03-08 23:36:58 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libzip
|
|
|
|
boost
|
2023-01-11 19:05:46 +00:00
|
|
|
] ++ lib.optionals (backend == "eigen") [
|
2020-08-23 21:00:52 +00:00
|
|
|
eigen
|
2023-01-11 19:05:46 +00:00
|
|
|
] ++ lib.optionals (backend == "cuda") [
|
2022-04-03 09:19:04 +00:00
|
|
|
cudaPackages.cudnn
|
2022-04-19 18:52:52 +00:00
|
|
|
cudaPackages.cudatoolkit
|
2020-10-15 14:22:14 +00:00
|
|
|
mesa.drivers
|
2023-01-11 19:05:46 +00:00
|
|
|
] ++ lib.optionals (backend == "tensorrt") [
|
|
|
|
cudaPackages.cudatoolkit
|
|
|
|
cudaPackages.tensorrt
|
|
|
|
mesa.drivers
|
|
|
|
] ++ lib.optionals (backend == "opencl") [
|
2020-03-08 23:36:58 +00:00
|
|
|
opencl-headers
|
|
|
|
ocl-icd
|
2021-01-14 15:41:01 +00:00
|
|
|
] ++ lib.optionals enableContrib [
|
|
|
|
openssl
|
2020-08-26 15:34:30 +00:00
|
|
|
] ++ lib.optionals enableTcmalloc [
|
2020-03-08 23:36:58 +00:00
|
|
|
gperftools
|
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
2024-03-05 19:54:48 +00:00
|
|
|
(lib.cmakeFeature "USE_BACKEND" (lib.toUpper backend))
|
|
|
|
(lib.cmakeBool "USE_AVX2" enableAVX2)
|
|
|
|
(lib.cmakeBool "USE_TCMALLOC" enableTcmalloc)
|
|
|
|
(lib.cmakeBool "USE_BIGGER_BOARDS_EXPENSIVE" enableBigBoards)
|
|
|
|
(lib.cmakeBool "USE_CACHE_TENSORRT_PLAN" enableTrtPlanCache)
|
|
|
|
(lib.cmakeBool "NO_GIT_REVISION" (!enableContrib))
|
2021-01-14 15:41:01 +00:00
|
|
|
] ++ lib.optionals enableContrib [
|
2024-03-05 19:54:48 +00:00
|
|
|
(lib.cmakeBool "BUILD_DISTRIBUTED" true)
|
|
|
|
(lib.cmakeFeature "GIT_EXECUTABLE" "${fakegit}/bin/git")
|
2020-03-08 23:36:58 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
cd cpp/
|
2023-01-11 19:05:46 +00:00
|
|
|
'' + lib.optionalString (backend == "cuda" || backend == "tensorrt") ''
|
2022-04-03 09:19:04 +00:00
|
|
|
export CUDA_PATH="${cudaPackages.cudatoolkit}"
|
2020-03-08 23:36:58 +00:00
|
|
|
export EXTRA_LDFLAGS="-L/run/opengl-driver/lib"
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
2021-03-15 14:36:53 +00:00
|
|
|
runHook preInstall
|
2020-03-08 23:36:58 +00:00
|
|
|
mkdir -p $out/bin; cp katago $out/bin;
|
2023-01-11 19:05:46 +00:00
|
|
|
'' + lib.optionalString (backend == "cuda" || backend == "tensorrt") ''
|
2020-03-08 23:36:58 +00:00
|
|
|
wrapProgram $out/bin/katago \
|
|
|
|
--prefix LD_LIBRARY_PATH : "/run/opengl-driver/lib"
|
2021-03-15 14:36:53 +00:00
|
|
|
'' + ''
|
|
|
|
runHook postInstall
|
2020-03-08 23:36:58 +00:00
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2020-03-08 23:36:58 +00:00
|
|
|
description = "Go engine modeled after AlphaGo Zero";
|
2024-03-19 02:14:51 +00:00
|
|
|
mainProgram = "katago";
|
2020-03-08 23:36:58 +00:00
|
|
|
homepage = "https://github.com/lightvector/katago";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = [ maintainers.omnipotententity ];
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
};
|
|
|
|
}
|