1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
{ stdenv
, gcc8Stdenv
, boost
, cmake
, cudatoolkit
, cudnn
, eigen
, fetchFromGitHub
, fetchpatch
, 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);
let
env = if enableCuda
then gcc8Stdenv
else stdenv;
in env.mkDerivation rec {
pname = "katago";
version = "1.8.0";
githash = "8ffda1fe05c69c67342365013b11225d443445e8";
src = fetchFromGitHub {
owner = "lightvector";
repo = "katago";
rev = "v${version}";
sha256 = "18r75xjj6vv2gbl92k9aa5bd0cxf09zl1vxlji148y0xbvgv6p8c";
};
fakegit = writeShellScriptBin "git" "echo ${githash}";
nativeBuildInputs = [
cmake
makeWrapper
];
buildInputs = [
libzip
boost
] ++ lib.optionals (!enableGPU) [
eigen
] ++ lib.optionals (enableGPU && enableCuda) [
cudnn
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="${cudatoolkit}"
export EXTRA_LDFLAGS="-L/run/opengl-driver/lib"
'';
installPhase = ''
mkdir -p $out/bin; cp katago $out/bin;
'' + lib.optionalString enableCuda ''
wrapProgram $out/bin/katago \
--prefix LD_LIBRARY_PATH : "/run/opengl-driver/lib"
'';
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" ];
};
}
|