2020-03-09 02:36:58 +03:00
|
|
|
{ stdenv
|
|
|
|
, gcc8Stdenv
|
|
|
|
, boost
|
|
|
|
, cmake
|
2021-01-14 18:41:01 +03:00
|
|
|
, cudatoolkit
|
|
|
|
, cudnn
|
|
|
|
, eigen
|
2020-03-09 02:36:58 +03:00
|
|
|
, fetchFromGitHub
|
2020-05-12 19:03:33 +03:00
|
|
|
, fetchpatch
|
2021-01-14 18:41:01 +03:00
|
|
|
, gperftools
|
|
|
|
, lib
|
|
|
|
, libzip
|
|
|
|
, makeWrapper
|
|
|
|
, mesa
|
|
|
|
, ocl-icd
|
|
|
|
, opencl-headers
|
|
|
|
, openssl
|
|
|
|
, writeShellScriptBin
|
2021-01-04 12:59:14 +03:00
|
|
|
, enableAVX2 ? stdenv.hostPlatform.avx2Support
|
2020-08-26 18:34:30 +03:00
|
|
|
, enableBigBoards ? false
|
|
|
|
, enableCuda ? false
|
2021-01-14 18:41:01 +03:00
|
|
|
, enableContrib ? false
|
2020-08-26 18:34:30 +03:00
|
|
|
, enableGPU ? true
|
2021-01-04 12:59:14 +03:00
|
|
|
, enableTcmalloc ? true
|
|
|
|
}:
|
2020-03-09 02:36:58 +03:00
|
|
|
|
2020-08-26 18:34:30 +03:00
|
|
|
assert !enableGPU -> (
|
|
|
|
!enableCuda);
|
2020-08-24 00:00:52 +03:00
|
|
|
|
2020-03-09 02:36:58 +03:00
|
|
|
let
|
2020-08-26 18:34:30 +03:00
|
|
|
env = if enableCuda
|
2020-03-09 02:36:58 +03:00
|
|
|
then gcc8Stdenv
|
|
|
|
else stdenv;
|
|
|
|
|
|
|
|
in env.mkDerivation rec {
|
|
|
|
pname = "katago";
|
2021-01-14 18:41:01 +03:00
|
|
|
version = "1.8.0";
|
|
|
|
githash = "8ffda1fe05c69c67342365013b11225d443445e8";
|
2020-03-09 02:36:58 +03:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "lightvector";
|
|
|
|
repo = "katago";
|
2020-08-24 00:00:52 +03:00
|
|
|
rev = "v${version}";
|
2021-01-14 18:41:01 +03:00
|
|
|
sha256 = "18r75xjj6vv2gbl92k9aa5bd0cxf09zl1vxlji148y0xbvgv6p8c";
|
2020-03-09 02:36:58 +03:00
|
|
|
};
|
|
|
|
|
2021-01-14 18:41:01 +03:00
|
|
|
fakegit = writeShellScriptBin "git" "echo ${githash}";
|
|
|
|
|
2020-03-09 02:36:58 +03:00
|
|
|
nativeBuildInputs = [
|
|
|
|
cmake
|
|
|
|
makeWrapper
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
libzip
|
|
|
|
boost
|
2020-08-26 18:34:30 +03:00
|
|
|
] ++ lib.optionals (!enableGPU) [
|
2020-08-24 00:00:52 +03:00
|
|
|
eigen
|
2020-08-26 18:34:30 +03:00
|
|
|
] ++ lib.optionals (enableGPU && enableCuda) [
|
2020-03-09 02:36:58 +03:00
|
|
|
cudnn
|
2020-10-15 17:22:14 +03:00
|
|
|
mesa.drivers
|
2020-08-26 18:34:30 +03:00
|
|
|
] ++ lib.optionals (enableGPU && !enableCuda) [
|
2020-03-09 02:36:58 +03:00
|
|
|
opencl-headers
|
|
|
|
ocl-icd
|
2021-01-14 18:41:01 +03:00
|
|
|
] ++ lib.optionals enableContrib [
|
|
|
|
openssl
|
2020-08-26 18:34:30 +03:00
|
|
|
] ++ lib.optionals enableTcmalloc [
|
2020-03-09 02:36:58 +03:00
|
|
|
gperftools
|
|
|
|
];
|
|
|
|
|
|
|
|
cmakeFlags = [
|
|
|
|
"-DNO_GIT_REVISION=ON"
|
2020-08-26 18:34:30 +03:00
|
|
|
] ++ lib.optionals (!enableGPU) [
|
2020-08-24 00:00:52 +03:00
|
|
|
"-DUSE_BACKEND=EIGEN"
|
2020-08-26 18:34:30 +03:00
|
|
|
] ++ lib.optionals enableAVX2 [
|
2020-08-24 00:00:52 +03:00
|
|
|
"-DUSE_AVX2=ON"
|
2020-08-26 18:34:30 +03:00
|
|
|
] ++ lib.optionals (enableGPU && enableCuda) [
|
2020-03-09 02:36:58 +03:00
|
|
|
"-DUSE_BACKEND=CUDA"
|
2020-08-26 18:34:30 +03:00
|
|
|
] ++ lib.optionals (enableGPU && !enableCuda) [
|
2020-03-09 02:36:58 +03:00
|
|
|
"-DUSE_BACKEND=OPENCL"
|
2021-01-14 18:41:01 +03:00
|
|
|
] ++ lib.optionals enableContrib [
|
|
|
|
"-DBUILD_DISTRIBUTED=1"
|
|
|
|
"-DNO_GIT_REVISION=OFF"
|
|
|
|
"-DGIT_EXECUTABLE=${fakegit}/bin/git"
|
2020-08-26 18:34:30 +03:00
|
|
|
] ++ lib.optionals enableTcmalloc [
|
2020-03-09 02:36:58 +03:00
|
|
|
"-DUSE_TCMALLOC=ON"
|
2020-08-26 18:34:30 +03:00
|
|
|
] ++ lib.optionals enableBigBoards [
|
|
|
|
"-DUSE_BIGGER_BOARDS_EXPENSIVE=ON"
|
2020-03-09 02:36:58 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
preConfigure = ''
|
|
|
|
cd cpp/
|
2020-08-26 18:34:30 +03:00
|
|
|
'' + lib.optionalString enableCuda ''
|
2020-03-09 02:36:58 +03:00
|
|
|
export CUDA_PATH="${cudatoolkit}"
|
|
|
|
export EXTRA_LDFLAGS="-L/run/opengl-driver/lib"
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin; cp katago $out/bin;
|
2020-08-26 18:34:30 +03:00
|
|
|
'' + lib.optionalString enableCuda ''
|
2020-03-09 02:36:58 +03:00
|
|
|
wrapProgram $out/bin/katago \
|
|
|
|
--prefix LD_LIBRARY_PATH : "/run/opengl-driver/lib"
|
|
|
|
'';
|
|
|
|
|
2021-01-11 10:54:33 +03:00
|
|
|
meta = with lib; {
|
2020-03-09 02:36:58 +03:00
|
|
|
description = "Go engine modeled after AlphaGo Zero";
|
|
|
|
homepage = "https://github.com/lightvector/katago";
|
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = [ maintainers.omnipotententity ];
|
|
|
|
platforms = [ "x86_64-linux" ];
|
|
|
|
};
|
|
|
|
}
|