Guest User

Untitled

a guest
Mar 8th, 2020
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. { stdenv
  2. , gcc8Stdenv
  3. , lib
  4. , libzip
  5. , boost
  6. , cmake
  7. , makeWrapper
  8. , fetchFromGitHub
  9. , linuxPackages ? null
  10. , cudnn ? null
  11. , cudatoolkit ? null
  12. , libGL_driver ? null
  13. , opencl-headers ? null
  14. , ocl-icd ? null
  15. , cudaSupport ? false}:
  16.  
  17. assert !cudaSupport || (
  18. linuxPackages != null &&
  19. libGL_driver != null &&
  20. cudatoolkit != null &&
  21. cudnn != null);
  22.  
  23. assert cudaSupport || (
  24. opencl-headers != null &&
  25. ocl-icd != null);
  26.  
  27. let
  28. env = if cudaSupport
  29. then gcc8Stdenv
  30. else stdenv;
  31.  
  32. in env.mkDerivation rec {
  33. pname = "katago";
  34. version = "1.3.3";
  35.  
  36. src = fetchFromGitHub {
  37. owner = "lightvector";
  38. repo = "katago";
  39. rev = "v${version}";
  40. sha256 = "031pq0lhv2q46iip1d6nrhx5r669l3jc7gzdpw74j9xbhjvza9kz";
  41. };
  42.  
  43. nativeBuildInputs = [
  44. cmake
  45. makeWrapper
  46. ];
  47.  
  48. buildInputs = [
  49. libzip
  50. boost
  51. ] ++ lib.optionals cudaSupport [
  52. linuxPackages.nvidia_x11
  53. cudnn
  54. libGL_driver
  55. ] ++ lib.optionals (!cudaSupport) [
  56. opencl-headers
  57. ocl-icd
  58. ];
  59.  
  60. cmakeFlags = [
  61. "-DNO_GIT_REVISION=ON"
  62. ] ++ lib.optionals cudaSupport [
  63. "-DUSE_BACKEND=CUDA"
  64. ] ++ lib.optionals (!cudaSupport) [
  65. "-DUSE_BACKEND=OPENCL"
  66. ];
  67.  
  68. preConfigure = ''
  69. cd cpp/
  70. '' + lib.optionalString cudaSupport ''
  71. export CUDA_PATH="${cudatoolkit}"
  72. export EXTRA_LDFLAGS="-L${linuxPackages.nvidia_x11}/lib"
  73. '';
  74.  
  75. installPhase = ''
  76. mkdir -p $out/bin; cp katago $out/bin;
  77. '';
  78.  
  79. postInstall = lib.optionalString cudaSupport ''
  80. wrapProgram $out/bin/katago \
  81. --prefix LD_LIBRARY_PATH ":" "${linuxPackages.nvidia_x11}/lib"
  82. '';
  83.  
  84. enableParallelBuilding = true;
  85.  
  86. meta = with stdenv.lib; {
  87. description = "Go engine modeled after AlphaGo Zero";
  88. homepage = https://github.com/lightvector/katago;
  89. license = licenses.mit;
  90. maintainers = [ maintainers.omnipotententity ];
  91. platforms = platforms.linux;
  92. };
  93. }
Advertisement
Add Comment
Please, Sign In to add comment