1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2015, 2016, 2017, 2018, 2019 Ricardo Wurmus <rekado@elephly.net>
3 ;;; Copyright © 2016 Efraim Flashner <efraim@flashner.co.il>
4 ;;; Copyright © 2016, 2017 Marius Bakke <mbakke@fastmail.com>
5 ;;; Copyright © 2016 Hartmut Goebel <h.goebel@crazy-compilers.com>
6 ;;; Copyright © 2018, 2019 Tobias Geerinckx-Rice <me@tobias.gr>
7 ;;; Copyright © 2018 Kei Kebreau <kkebreau@posteo.net>
8 ;;; Copyright © 2018 Mark Meyer <mark@ofosos.org>
9 ;;; Copyright © 2018 Ben Woodcroft <donttrustben@gmail.com>
10 ;;; Copyright © 2018 Fis Trivial <ybbs.daans@hotmail.com>
11 ;;; Copyright © 2018 Julien Lepiller <julien@lepiller.eu>
12 ;;; Copyright © 2018 Björn Höfling <bjoern.hoefling@bjoernhoefling.de>
13 ;;; Copyright © 2019 Nicolas Goaziou <mail@nicolasgoaziou.fr>
14 ;;; Copyright © 2019 Guillaume Le Vaillant <glv@posteo.net>
16 ;;; This file is part of GNU Guix.
18 ;;; GNU Guix is free software; you can redistribute it and/or modify it
19 ;;; under the terms of the GNU General Public License as published by
20 ;;; the Free Software Foundation; either version 3 of the License, or (at
21 ;;; your option) any later version.
23 ;;; GNU Guix is distributed in the hope that it will be useful, but
24 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
25 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 ;;; GNU General Public License for more details.
28 ;;; You should have received a copy of the GNU General Public License
29 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
31 (define-module (gnu packages machine-learning)
32 #:use-module ((guix licenses) #:prefix license:)
33 #:use-module (guix packages)
34 #:use-module (guix utils)
35 #:use-module (guix download)
36 #:use-module (guix svn-download)
37 #:use-module (guix build-system asdf)
38 #:use-module (guix build-system cmake)
39 #:use-module (guix build-system gnu)
40 #:use-module (guix build-system ocaml)
41 #:use-module (guix build-system python)
42 #:use-module (guix build-system r)
43 #:use-module (guix git-download)
44 #:use-module (gnu packages)
45 #:use-module (gnu packages adns)
46 #:use-module (gnu packages algebra)
47 #:use-module (gnu packages audio)
48 #:use-module (gnu packages autotools)
49 #:use-module (gnu packages base)
50 #:use-module (gnu packages bash)
51 #:use-module (gnu packages boost)
52 #:use-module (gnu packages check)
53 #:use-module (gnu packages compression)
54 #:use-module (gnu packages cran)
55 #:use-module (gnu packages databases)
56 #:use-module (gnu packages dejagnu)
57 #:use-module (gnu packages gcc)
58 #:use-module (gnu packages glib)
59 #:use-module (gnu packages graphviz)
60 #:use-module (gnu packages gstreamer)
61 #:use-module (gnu packages image)
62 #:use-module (gnu packages linux)
63 #:use-module (gnu packages lisp-xyz)
64 #:use-module (gnu packages maths)
65 #:use-module (gnu packages mpi)
66 #:use-module (gnu packages ocaml)
67 #:use-module (gnu packages onc-rpc)
68 #:use-module (gnu packages perl)
69 #:use-module (gnu packages pkg-config)
70 #:use-module (gnu packages protobuf)
71 #:use-module (gnu packages python)
72 #:use-module (gnu packages python-science)
73 #:use-module (gnu packages python-web)
74 #:use-module (gnu packages python-xyz)
75 #:use-module (gnu packages serialization)
76 #:use-module (gnu packages sphinx)
77 #:use-module (gnu packages statistics)
78 #:use-module (gnu packages sqlite)
79 #:use-module (gnu packages swig)
80 #:use-module (gnu packages tls)
81 #:use-module (gnu packages web)
82 #:use-module (gnu packages xml)
83 #:use-module (gnu packages xorg)
84 #:use-module (ice-9 match))
87 ;; The last release is >100 commits behind, so we package from git.
88 (let ((commit "d71d54788bee56ba4cf7522801270152da5209d7"))
91 (version (string-append "2.2.0-1." (string-take commit 8)))
95 (url "https://github.com/libfann/fann.git")
97 (file-name (string-append name "-" version "-checkout"))
100 "0ibwpfrjs6q2lijs8slxjgzb2llcl6rk3v2ski4r6215g5jjhg3x"))))
101 (build-system cmake-build-system)
104 (modify-phases %standard-phases
106 (lambda* (#:key outputs #:allow-other-keys)
107 (let* ((out (assoc-ref outputs "out")))
108 (with-directory-excursion (string-append (getcwd) "/tests")
109 (invoke "./fann_tests"))))))))
110 (home-page "http://leenissen.dk/fann/wp/")
111 (synopsis "Fast Artificial Neural Network")
113 "FANN is a neural network library, which implements multilayer
114 artificial neural networks in C with support for both fully connected and
115 sparsely connected networks.")
116 (license license:lgpl2.1))))
118 (define-public libsvm
125 (uri (string-append "https://www.csie.ntu.edu.tw/~cjlin/libsvm/"
126 name "-" version ".tar.gz"))
128 (base32 "0jpaq0rr92x38p4nk3gjan79ip67m6p80anb28z1d8601miysyi5"))))
129 (build-system gnu-build-system)
131 `(#:tests? #f ; no "check" target
132 #:phases (modify-phases %standard-phases
135 'install ; no ‘install’ target
136 (lambda* (#:key outputs #:allow-other-keys)
137 (let* ((out (assoc-ref outputs "out"))
138 (bin (string-append out "/bin/")))
140 (for-each (lambda (file)
141 (copy-file file (string-append bin file)))
146 (home-page "http://www.csie.ntu.edu.tw/~cjlin/libsvm/")
147 (synopsis "Library for Support Vector Machines")
149 "LIBSVM is a machine learning library for support vector
150 classification, (C-SVC, nu-SVC), regression (epsilon-SVR, nu-SVR) and
151 distribution estimation (one-class SVM). It supports multi-class
153 (license license:bsd-3)))
155 (define-public python-libsvm
156 (package (inherit libsvm)
157 (name "python-libsvm")
158 (build-system gnu-build-system)
160 `(#:tests? #f ; no "check" target
161 #:make-flags '("-C" "python")
163 (modify-phases %standard-phases
166 'install ; no ‘install’ target
167 (lambda* (#:key inputs outputs #:allow-other-keys)
168 (let ((site (string-append (assoc-ref outputs "out")
172 (assoc-ref inputs "python") 5) 3)
174 (substitute* "python/svm.py"
175 (("../libsvm.so.2") "libsvm.so.2"))
177 (for-each (lambda (file)
178 (copy-file file (string-append site (basename file))))
179 (find-files "python" "\\.py"))
180 (copy-file "libsvm.so.2"
181 (string-append site "libsvm.so.2")))
184 `(("python" ,python)))
185 (synopsis "Python bindings of libSVM")))
188 ;; The latest release candidate is several years and a couple of fixes have
189 ;; been published since. This is why we download the sources from the SVN
191 (let ((svn-revision 2341))
194 (version (string-append "0.9-rc3-0." (number->string svn-revision)))
198 (url "http://svn.code.sf.net/p/ghmm/code/trunk")
199 (revision svn-revision)))
200 (file-name (string-append name "-" version "-checkout"))
203 "0qbq1rqp94l530f043qzp8aw5lj7dng9wq0miffd7spd1ff638wq"))))
204 (build-system gnu-build-system)
206 `(#:imported-modules (,@%gnu-build-system-modules
207 (guix build python-build-system))
209 (modify-phases %standard-phases
210 (add-after 'unpack 'enter-dir
211 (lambda _ (chdir "ghmm") #t))
213 (add-after 'install 'check
214 (assoc-ref %standard-phases 'check))
215 (add-before 'check 'fix-PYTHONPATH
216 (lambda* (#:key inputs outputs #:allow-other-keys)
217 (let ((python-version (python-version
218 (assoc-ref inputs "python"))))
220 (string-append (getenv "PYTHONPATH")
221 ":" (assoc-ref outputs "out")
222 "/lib/python" python-version
225 (add-after 'enter-dir 'fix-runpath
226 (lambda* (#:key outputs #:allow-other-keys)
227 (substitute* "ghmmwrapper/setup.py"
228 (("^(.*)extra_compile_args = \\[" line indent)
229 (string-append indent
230 "extra_link_args = [\"-Wl,-rpath="
231 (assoc-ref outputs "out") "/lib\"],\n"
234 (assoc-ref outputs "out")
237 (add-after 'enter-dir 'disable-broken-tests
239 (substitute* "tests/Makefile.am"
240 ;; GHMM_SILENT_TESTS is assumed to be a command.
241 (("TESTS_ENVIRONMENT.*") "")
242 ;; Do not build broken tests.
246 (("label_higher_order_test.*$")
247 "label_higher_order_test\n"))
249 ;; These Python unittests are broken as there is no gato.
250 ;; See https://sourceforge.net/p/ghmm/support-requests/3/
251 (substitute* "ghmmwrapper/ghmmunittests.py"
252 (("^(.*)def (testNewXML|testMultipleTransitionClasses|testNewXML)"
254 (string-append indent
255 "@unittest.skip(\"Disabled by Guix\")\n"
259 `(("python" ,python-2) ; only Python 2 is supported
260 ("libxml2" ,libxml2)))
262 `(("pkg-config" ,pkg-config)
265 ("autoconf" ,autoconf)
266 ("automake" ,automake)
267 ("libtool" ,libtool)))
268 (home-page "http://ghmm.org")
269 (synopsis "Hidden Markov Model library")
271 "The General Hidden Markov Model library (GHMM) is a C library with
272 additional Python bindings implementing a wide range of types of @dfn{Hidden
273 Markov Models} (HMM) and algorithms: discrete, continuous emissions, basic
274 training, HMM clustering, HMM mixtures.")
275 (license license:lgpl2.0+))))
284 "http://micans.org/mcl/src/mcl-"
285 (string-replace-substring version "." "-")
289 "15xlax3z31lsn62vlg94hkm75nm40q4679amnfg13jm8m2bnhy5m"))))
290 (build-system gnu-build-system)
292 `(#:configure-flags (list "--enable-blast")))
295 (home-page "http://micans.org/mcl/")
296 (synopsis "Clustering algorithm for graphs")
298 "The MCL algorithm is short for the @dfn{Markov Cluster Algorithm}, a
299 fast and scalable unsupervised cluster algorithm for graphs (also known as
300 networks) based on simulation of (stochastic) flow in graphs.")
301 ;; In the LICENCE file and web page it says "The software is licensed
302 ;; under the GNU General Public License, version 3.", but in several of
303 ;; the source code files it suggests GPL3 or later.
304 ;; http://listserver.ebi.ac.uk/pipermail/mcl-users/2016/000376.html
305 (license license:gpl3)))
307 (define-public ocaml-mcl
310 (version "12-068oasis4")
315 (url "https://github.com/fhcrc/mcl.git")
317 (file-name (git-file-name name version))
320 "0009dc3h2jp3qg5val452wngpqnbfyhbcxylghq0mrjqxx0jdq5p"))))
321 (build-system ocaml-build-system)
324 (modify-phases %standard-phases
325 (add-before 'configure 'patch-paths
327 (substitute* "configure"
328 (("/bin/sh") (which "sh")))
329 (substitute* "setup.ml"
331 (string-append "LDFLAGS=-fPIC\"; \"SHELL=" (which "sh")))
332 (("-std=c89") "-std=gnu99")
334 ;; This is a mutable string, which is no longer supported. Use
335 ;; a byte buffer instead.
336 (("String.make \\(String.length s\\)")
337 "Bytes.make (String.length s)")
339 ;; These two belong together.
340 (("OASISString.replace_chars")
341 "Bytes.to_string (OASISString.replace_chars")
344 (substitute* "myocamlbuild.ml"
345 (("std=c89") "std=gnu99"))
346 ;; Since we build with a more recent OCaml, we have to use C99 or
347 ;; later. This causes problems with the old C code.
348 (substitute* "src/impala/matrix.c"
349 (("restrict") "restrict_"))
352 `(("ocamlbuild" ,ocamlbuild)))
353 (home-page "https://github.com/fhcrc/mcl")
354 (synopsis "OCaml wrappers around MCL")
356 "This package provides OCaml bindings for the MCL graph clustering
358 (license license:gpl3)))
360 (define-public randomjungle
362 (name "randomjungle")
368 "https://www.imbs.uni-luebeck.de/fileadmin/files/Software"
369 "/randomjungle/randomjungle-" version ".tar_.gz"))
370 (patches (search-patches "randomjungle-disable-static-build.patch"))
373 "12c8rf30cla71swx2mf4ww9mfd8jbdw5lnxd7dxhyw1ygrvg6y4w"))))
374 (build-system gnu-build-system)
377 (list "--disable-static"
378 (string-append "--with-boost="
379 (assoc-ref %build-inputs "boost")))
381 (modify-phases %standard-phases
383 'configure 'set-CXXFLAGS
385 (setenv "CXXFLAGS" "-fpermissive ")
393 `(("gfortran" ,gfortran)
394 ("gfortran:lib" ,gfortran "lib")))
395 ;; Non-portable assembly instructions are used so building fails on
396 ;; platforms other than x86_64 or i686.
397 (supported-systems '("x86_64-linux" "i686-linux"))
398 (home-page "https://www.imbs.uni-luebeck.de/forschung/software/details.html#c224")
399 (synopsis "Implementation of the Random Forests machine learning method")
401 "Random Jungle is an implementation of Random Forests. It is supposed to
402 analyse high dimensional data. In genetics, it can be used for analysing big
403 Genome Wide Association (GWA) data. Random Forests is a powerful machine
404 learning method. Most interesting features are variable selection, missing
405 value imputation, classifier creation, generalization error estimation and
406 sample proximities between pairs of cases.")
407 (license license:gpl3+)))
409 (define-public openfst
415 (uri (string-append "http://www.openfst.org/twiki/pub/FST/"
416 "FstDownload/openfst-" version ".tar.gz"))
419 "0fqgk8195kz21is09gwzwnrg7fr9526bi9mh4apyskapz27pbhr1"))))
420 (build-system gnu-build-system)
421 (home-page "http://www.openfst.org")
422 (synopsis "Library for weighted finite-state transducers")
423 (description "OpenFst is a library for constructing, combining,
424 optimizing, and searching weighted finite-state transducers (FSTs).")
425 (license license:asl2.0)))
427 (define-public shogun
435 "ftp://shogun-toolbox.org/shogun/releases/"
436 (version-major+minor version)
437 "/sources/shogun-" version ".tar.bz2"))
440 "1rn9skm3nw6hr7mr3lgp2gfqhi7ii0lyxck7qmqnf8avq349s5jp"))
441 (modules '((guix build utils)
445 ;; Remove non-free sources and files referencing them
446 (for-each delete-file
447 (find-files "src/shogun/classifier/svm/"
448 "SVMLight\\.(cpp|h)"))
449 (for-each delete-file
450 (find-files "examples/undocumented/libshogun/"
452 "(classifier_.*svmlight.*|"
453 "evaluation_cross_validation_locked_comparison).cpp")))
454 ;; Remove non-free functions.
455 (define (delete-ifdefs file)
456 (with-atomic-file-replacement file
458 (let loop ((line (read-line in 'concat))
460 (if (eof-object? line)
465 "#endif //USE_SVMLIGHT" line)))
467 "#ifdef USE_SVMLIGHT" line))))
468 (when (or (not skipping?)
469 (and skipping? (not skip-next?)))
471 (loop (read-line in 'concat) skip-next?)))))))
472 (for-each delete-ifdefs
474 (find-files "src/shogun/classifier/mkl"
475 "^MKLClassification\\.cpp")
476 (find-files "src/shogun/classifier/svm"
477 "^SVMLightOneClass\\.(cpp|h)")
478 (find-files "src/shogun/multiclass"
479 "^ScatterSVM\\.(cpp|h)")
480 (find-files "src/shogun/kernel/"
481 "^(Kernel|CombinedKernel|ProductKernel)\\.(cpp|h)")
482 (find-files "src/shogun/regression/svr"
483 "^(MKLRegression|SVRLight)\\.(cpp|h)")
484 (find-files "src/shogun/transfer/domain_adaptation"
485 "^DomainAdaptationSVM\\.(cpp|h)")))
487 (build-system cmake-build-system)
489 '(#:tests? #f ;no check target
491 (modify-phases %standard-phases
492 (add-after 'unpack 'delete-broken-symlinks
494 (for-each delete-file '("applications/arts/data"
495 "applications/asp/data"
496 "applications/easysvm/data"
497 "applications/msplicer/data"
498 "applications/ocr/data"
500 "examples/undocumented/data"))
502 (add-after 'unpack 'change-R-target-path
503 (lambda* (#:key outputs #:allow-other-keys)
504 (substitute* '("src/interfaces/r/CMakeLists.txt"
505 "examples/meta/r/CMakeLists.txt")
506 (("\\$\\{R_COMPONENT_LIB_PATH\\}")
507 (string-append (assoc-ref outputs "out")
510 (add-after 'unpack 'fix-octave-modules
511 (lambda* (#:key outputs #:allow-other-keys)
512 (substitute* "src/interfaces/octave/CMakeLists.txt"
513 (("^include_directories\\(\\$\\{OCTAVE_INCLUDE_DIRS\\}")
514 "include_directories(${OCTAVE_INCLUDE_DIRS} ${OCTAVE_INCLUDE_DIRS}/octave")
515 ;; change target directory
516 (("\\$\\{OCTAVE_OCT_LOCAL_API_FILE_DIR\\}")
517 (string-append (assoc-ref outputs "out")
518 "/share/octave/packages")))
519 (substitute* '("src/interfaces/octave/swig_typemaps.i"
520 "src/interfaces/octave/sg_print_functions.cpp")
521 ;; "octave/config.h" and "octave/oct-obj.h" deprecated in Octave.
522 (("octave/config\\.h") "octave/octave-config.h")
523 (("octave/oct-obj.h") "octave/ovl.h"))
525 (add-after 'unpack 'move-rxcpp
526 (lambda* (#:key inputs #:allow-other-keys)
527 (let ((rxcpp-dir "shogun/third-party/rxcpp"))
529 (install-file (assoc-ref inputs "rxcpp") rxcpp-dir)
531 (add-before 'build 'set-HOME
532 ;; $HOME needs to be set at some point during the build phase
533 (lambda _ (setenv "HOME" "/tmp") #t)))
535 (list "-DCMAKE_BUILD_WITH_INSTALL_RPATH=TRUE"
536 "-DUSE_SVMLIGHT=OFF" ;disable proprietary SVMLIGHT
537 "-DBUILD_META_EXAMPLES=OFF" ;requires unpackaged ctags
538 ;;"-DINTERFACE_JAVA=ON" ;requires unpackaged jblas
539 ;;"-DINTERFACE_RUBY=ON" ;requires unpackaged ruby-narray
540 ;;"-DINTERFACE_PERL=ON" ;"FindPerlLibs" does not exist
541 ;;"-DINTERFACE_LUA=ON" ;fails because lua doesn't build pkgconfig file
542 "-DINTERFACE_OCTAVE=ON"
543 "-DINTERFACE_PYTHON=ON"
544 "-DINTERFACE_R=ON")))
547 ("numpy" ,python-numpy)
548 ("r-minimal" ,r-minimal)
549 ("octave" ,octave-cli)
554 ("arpack" ,arpack-ng)
561 `(("pkg-config" ,pkg-config)
563 ;; Non-portable SSE instructions are used so building fails on platforms
564 ;; other than x86_64.
565 (supported-systems '("x86_64-linux"))
566 (home-page "http://shogun-toolbox.org/")
567 (synopsis "Machine learning toolbox")
569 "The Shogun Machine learning toolbox provides a wide range of unified and
570 efficient Machine Learning (ML) methods. The toolbox seamlessly allows to
571 combine multiple data representations, algorithm classes, and general purpose
572 tools. This enables both rapid prototyping of data pipelines and extensibility
573 in terms of new algorithms.")
574 (license license:gpl3+)))
584 (url "https://github.com/ReactiveX/RxCpp.git")
585 (commit (string-append "v" version))))
587 (base32 "1rdpa3jlc181jd08nk437aar085h28i45s6nzrv65apb3xyyz0ij"))
588 (file-name (git-file-name name version))))
589 (build-system cmake-build-system)
592 (modify-phases %standard-phases
593 (add-after 'unpack 'remove-werror
595 (substitute* (find-files ".")
600 (invoke "ctest"))))))
602 `(("catch" ,catch-framework)))
603 (home-page "http://reactivex.io/")
604 (synopsis "Reactive Extensions for C++")
606 "The Reactive Extensions for C++ (RxCpp) is a library of algorithms for
607 values-distributed-in-time. ReactiveX is a library for composing asynchronous
608 and event-based programs by using observable sequences.
610 It extends the observer pattern to support sequences of data and/or events and
611 adds operators that allow you to compose sequences together declaratively while
612 abstracting away concerns about things like low-level threading,
613 synchronization, thread-safety, concurrent data structures, and non-blocking
615 (license license:asl2.0)))
617 (define-public r-adaptivesparsity
619 (name "r-adaptivesparsity")
623 (uri (cran-uri "AdaptiveSparsity" version))
626 "0imr5m8mll9j6n4icsv6z9rl5kbnwsp9wvzrg7n90nnmcxq2cz91"))))
628 `((upstream-name . "AdaptiveSparsity")))
629 (build-system r-build-system)
632 (modify-phases %standard-phases
633 (add-after 'unpack 'link-against-armadillo
635 (substitute* "src/Makevars"
636 (("PKG_LIBS=" prefix)
637 (string-append prefix "-larmadillo"))))))))
640 ("r-matrix" ,r-matrix)
642 ("r-rcpparmadillo" ,r-rcpparmadillo)))
644 `(("armadillo" ,armadillo)))
645 (home-page "https://cran.r-project.org/web/packages/AdaptiveSparsity")
646 (synopsis "Adaptive sparsity models")
648 "This package implements the Figueiredo machine learning algorithm for
649 adaptive sparsity and the Wong algorithm for adaptively sparse gaussian
651 (license license:lgpl3+)))
653 (define-public gemmlowp-for-tensorflow
654 ;; The commit hash is taken from "tensorflow/workspace.bzl".
655 (let ((commit "38ebac7b059e84692f53e5938f97a9943c120d98")
659 (version (git-version "0" revision commit))
662 (uri (string-append "https://mirror.bazel.build/"
663 "github.com/google/gemmlowp/archive/"
665 (file-name (string-append "gemmlowp-" version ".zip"))
668 "0n56s2g8hrssm4w8qj1v58gfm56a04n9v992ixkmvk6zjiralzxq"))))
669 (build-system cmake-build-system)
672 (list ,@(match (%current-system)
673 ((or "x86_64-linux" "i686-linux")
674 '("-DCMAKE_CXX_FLAGS=-msse2"))
677 (modify-phases %standard-phases
678 ;; This directory contains the CMakeLists.txt.
679 (add-after 'unpack 'chdir
680 (lambda _ (chdir "contrib") #t))
681 ;; There is no install target
683 (lambda* (#:key outputs #:allow-other-keys)
684 (let* ((out (assoc-ref outputs "out"))
685 (lib (string-append out "/lib/"))
686 (inc (string-append out "/include/")))
687 (install-file "../build/libeight_bit_int_gemm.so" lib)
688 (for-each (lambda (dir)
689 (let ((target (string-append inc "/" dir)))
691 (for-each (lambda (h)
692 (install-file h target))
693 (find-files (string-append "../" dir)
695 '("meta" "profiling" "public" "fixedpoint"
696 "eight_bit_int_gemm" "internal"))
700 (home-page "https://github.com/google/gemmlowp")
701 (synopsis "Small self-contained low-precision GEMM library")
703 "This is a small self-contained low-precision @dfn{general matrix
704 multiplication} (GEMM) library. It is not a full linear algebra library.
705 Low-precision means that the input and output matrix entries are integers on
706 at most 8 bits. To avoid overflow, results are internally accumulated on more
707 than 8 bits, and at the end only some significant 8 bits are kept.")
708 (license license:asl2.0))))
717 "http://dlib.net/files/dlib-" version ".tar.bz2"))
720 "1mljz02kwkrbggyncxv5fpnyjdybw2qihaacb3js8yfkw12vwpc2"))
721 (modules '((guix build utils)))
724 ;; Delete ~13MB of bundled dependencies.
725 (delete-file-recursively "dlib/external")
726 (delete-file-recursively "docs/dlib/external")
728 (build-system cmake-build-system)
731 (modify-phases %standard-phases
732 (add-after 'unpack 'disable-asserts
734 ;; config.h recommends explicitly enabling or disabling asserts
735 ;; when building as a shared library. By default neither is set.
736 (substitute* "dlib/config.h"
737 (("^//#define DLIB_DISABLE_ASSERTS") "#define DLIB_DISABLE_ASSERTS"))
739 (add-after 'disable-asserts 'disable-failing-tests
741 ;; One test times out on MIPS, so we need to disable it.
742 ;; Others are flaky on some platforms.
743 (let* ((system ,(or (%current-target-system)
745 (disabled-tests (cond
746 ((string-prefix? "mips64" system)
747 '("object_detector" ; timeout
749 ((string-prefix? "armhf" system)
750 '("learning_to_track"))
751 ((string-prefix? "i686" system)
756 (substitute* "dlib/test/makefile"
757 (((string-append "SRC \\+= " test "\\.cpp")) "")))
762 ;; No test target, so we build and run the unit tests here.
763 (let ((test-dir (string-append "../dlib-" ,version "/dlib/test")))
764 (with-directory-excursion test-dir
765 (invoke "make" "-j" (number->string (parallel-job-count)))
766 (invoke "./dtest" "--runall"))
768 (add-after 'install 'delete-static-library
769 (lambda* (#:key outputs #:allow-other-keys)
770 (delete-file (string-append (assoc-ref outputs "out")
774 `(("pkg-config" ,pkg-config)
783 ("openblas" ,openblas)
786 "Toolkit for making machine learning and data analysis applications in C++")
788 "Dlib is a modern C++ toolkit containing machine learning algorithms and
789 tools. It is used in both industry and academia in a wide range of domains
790 including robotics, embedded devices, mobile phones, and large high performance
791 computing environments.")
792 (home-page "http://dlib.net")
793 (license license:boost1.0)))
795 (define-public python-scikit-learn
797 (name "python-scikit-learn")
803 (url "https://github.com/scikit-learn/scikit-learn.git")
805 (file-name (git-file-name name version))
808 "08zbzi8yx5wdlxfx9jap61vg1malc9ajf576w7a0liv6jvvrxlpj"))))
809 (build-system python-build-system)
812 (modify-phases %standard-phases
813 (add-after 'build 'build-ext
814 (lambda _ (invoke "python" "setup.py" "build_ext" "--inplace") #t))
817 ;; Restrict OpenBLAS threads to prevent segfaults while testing!
818 (setenv "OPENBLAS_NUM_THREADS" "1")
820 ;; Some tests require write access to $HOME.
821 (setenv "HOME" "/tmp")
823 (invoke "pytest" "sklearn" "-m" "not network")))
824 (add-before 'reset-gzip-timestamps 'make-files-writable
825 (lambda* (#:key outputs #:allow-other-keys)
826 ;; Make sure .gz files are writable so that the
827 ;; 'reset-gzip-timestamps' phase can do its work.
828 (let ((out (assoc-ref outputs "out")))
829 (for-each make-file-writable
830 (find-files out "\\.gz$"))
833 `(("openblas" ,openblas)))
835 `(("python-pytest" ,python-pytest)
836 ("python-pandas" ,python-pandas) ;for tests
837 ("python-cython" ,python-cython)))
839 `(("python-numpy" ,python-numpy)
840 ("python-scipy" ,python-scipy)))
841 (home-page "http://scikit-learn.org/")
842 (synopsis "Machine Learning in Python")
844 "Scikit-learn provides simple and efficient tools for data mining and
846 (license license:bsd-3)))
848 (define-public python2-scikit-learn
849 (package-with-python2 python-scikit-learn))
851 (define-public python-autograd
852 (let* ((commit "442205dfefe407beffb33550846434baa90c4de7")
854 (version (git-version "0.0.0" revision commit)))
856 (name "python-autograd")
857 (home-page "https://github.com/HIPS/autograd")
865 "189sv2xb0mwnjawa9z7mrgdglc1miaq93pnck26r28fi1jdwg0z4"))
866 (file-name (git-file-name name version))))
868 (build-system python-build-system)
870 `(("python-nose" ,python-nose)
871 ("python-pytest" ,python-pytest)))
873 `(("python-future" ,python-future)
874 ("python-numpy" ,python-numpy)))
876 `(#:phases (modify-phases %standard-phases
879 (invoke "py.test" "-v"))))))
880 (synopsis "Efficiently computes derivatives of NumPy code")
881 (description "Autograd can automatically differentiate native Python and
882 NumPy code. It can handle a large subset of Python's features, including loops,
883 ifs, recursion and closures, and it can even take derivatives of derivatives
884 of derivatives. It supports reverse-mode differentiation
885 (a.k.a. backpropagation), which means it can efficiently take gradients of
886 scalar-valued functions with respect to array-valued arguments, as well as
887 forward-mode differentiation, and the two can be composed arbitrarily. The
888 main intended application of Autograd is gradient-based optimization.")
889 (license license:expat))))
891 (define-public python2-autograd
892 (package-with-python2 python-autograd))
894 (define-public lightgbm
901 "https://github.com/Microsoft/LightGBM/archive/v"
905 "132zf0yk0545mg72hyzxm102g3hpb6ixx9hnf8zd2k55gas6cjj1"))
906 (file-name (string-append name "-" version ".tar.gz"))))
908 `(("python-pytest" ,python-pytest)
909 ("python-nose" ,python-nose)))
911 `(("openmpi" ,openmpi)))
913 `(("python-numpy" ,python-numpy)
914 ("python-scipy" ,python-scipy)))
919 (modify-phases %standard-phases
921 (lambda* (#:key outputs #:allow-other-keys)
922 (with-directory-excursion ,(string-append "../LightGBM-" version)
923 (invoke "pytest" "tests/c_api_test/test_.py")))))))
924 (build-system cmake-build-system)
925 (home-page "https://github.com/Microsoft/LightGBM")
926 (synopsis "Gradient boosting framework based on decision tree algorithms")
927 (description "LightGBM is a gradient boosting framework that uses tree
928 based learning algorithms. It is designed to be distributed and efficient with
929 the following advantages:
932 @item Faster training speed and higher efficiency
933 @item Lower memory usage
934 @item Better accuracy
935 @item Parallel and GPU learning supported (not enabled in this package)
936 @item Capable of handling large-scale data
938 (license license:expat)))
940 (define-public vowpal-wabbit
941 ;; Language bindings not included.
943 (name "vowpal-wabbit")
948 "https://github.com/JohnLangford/vowpal_wabbit/archive/"
952 "0clp2kb7rk5sckhllxjr5a651awf4s8dgzg4659yh4hf5cqnf0gr"))
953 (file-name (string-append name "-" version ".tar.gz"))))
959 (list (string-append "--with-boost="
960 (assoc-ref %build-inputs "boost")))))
961 (build-system gnu-build-system)
962 (home-page "https://github.com/JohnLangford/vowpal_wabbit")
963 (synopsis "Fast machine learning library for online learning")
964 (description "Vowpal Wabbit is a machine learning system with techniques
965 such as online, hashing, allreduce, reductions, learning2search, active, and
966 interactive learning.")
967 (license license:bsd-3)))
969 (define-public python2-fastlmm
971 (name "python2-fastlmm")
976 (uri (pypi-uri "fastlmm" version ".zip"))
979 "1q8c34rpmwkfy3r4d5172pzdkpfryj561897z9r3x22gq7813x1m"))))
980 (build-system python-build-system)
982 `(#:tests? #f ; some test files are missing
983 #:python ,python-2)) ; only Python 2.7 is supported
985 `(("python2-numpy" ,python2-numpy)
986 ("python2-scipy" ,python2-scipy)
987 ("python2-matplotlib" ,python2-matplotlib)
988 ("python2-pandas" ,python2-pandas)
989 ("python2-scikit-learn" ,python2-scikit-learn)
990 ("python2-pysnptools" ,python2-pysnptools)))
993 ("python2-cython" ,python2-cython)
994 ("python2-mock" ,python2-mock)
995 ("python2-nose" ,python2-nose)))
996 (home-page "http://research.microsoft.com/en-us/um/redmond/projects/mscompbio/fastlmm/")
997 (synopsis "Perform genome-wide association studies on large data sets")
999 "FaST-LMM, which stands for Factored Spectrally Transformed Linear Mixed
1000 Models, is a program for performing both single-SNP and SNP-set genome-wide
1001 association studies (GWAS) on extremely large data sets.")
1002 (license license:asl2.0)))
1004 ;; There have been no proper releases yet.
1005 (define-public kaldi
1006 (let ((commit "2f95609f0bb085bd3a1dc5eb0a39f3edea59e606")
1010 (version (git-version "0" revision commit))
1014 (url "https://github.com/kaldi-asr/kaldi.git")
1016 (file-name (git-file-name name version))
1019 "082qh3pfi7hvncylp4xsmkfahbd7gb0whdfa4rwrx7fxk9rdh3kz"))))
1020 (build-system gnu-build-system)
1022 `(#:test-target "test"
1024 (modify-phases %standard-phases
1025 (add-after 'unpack 'chdir
1026 (lambda _ (chdir "src") #t))
1028 (lambda* (#:key build system inputs outputs #:allow-other-keys)
1029 (when (not (or (string-prefix? "x86_64" system)
1030 (string-prefix? "i686" system)))
1031 (substitute* "makefiles/linux_openblas.mk"
1032 (("-msse -msse2") "")))
1033 (substitute* "makefiles/default_rules.mk"
1034 (("/bin/bash") (which "bash")))
1035 (substitute* "Makefile"
1036 (("ext_depend: check_portaudio")
1038 (substitute* '("online/Makefile"
1039 "onlinebin/Makefile"
1040 "gst-plugin/Makefile")
1041 (("../../tools/portaudio/install")
1042 (assoc-ref inputs "portaudio")))
1044 ;; This `configure' script doesn't support variables passed as
1045 ;; arguments, nor does it support "prefix".
1046 (let ((out (assoc-ref outputs "out"))
1047 (openblas (assoc-ref inputs "openblas"))
1048 (openfst (assoc-ref inputs "openfst")))
1049 (substitute* "configure"
1050 (("check_for_slow_expf;") "")
1051 ;; This affects the RPATH and also serves as the installation
1053 (("KALDILIBDIR=`pwd`/lib")
1054 (string-append "KALDILIBDIR=" out "/lib")))
1055 (mkdir-p out) ; must exist
1056 (setenv "CONFIG_SHELL" (which "bash"))
1057 (setenv "OPENFST_VER" ,(package-version openfst))
1058 (invoke "./configure"
1061 (string-append "--openblas-root=" openblas)
1062 (string-append "--fst-root=" openfst)))))
1063 (add-after 'build 'build-ext-and-gstreamer-plugin
1065 (invoke "make" "-C" "online" "depend")
1066 (invoke "make" "-C" "online")
1067 (invoke "make" "-C" "onlinebin" "depend")
1068 (invoke "make" "-C" "onlinebin")
1069 (invoke "make" "-C" "gst-plugin" "depend")
1070 (invoke "make" "-C" "gst-plugin")
1072 ;; TODO: also install the executables.
1074 (lambda* (#:key outputs #:allow-other-keys)
1075 (let* ((out (assoc-ref outputs "out"))
1076 (inc (string-append out "/include"))
1077 (lib (string-append out "/lib")))
1079 ;; The build phase installed symlinks to the actual
1080 ;; libraries. Install the actual targets.
1081 (for-each (lambda (file)
1082 (let ((target (readlink file)))
1084 (install-file target lib)))
1085 (find-files lib "\\.so"))
1087 (for-each (lambda (file)
1088 (let ((target-dir (string-append inc "/" (dirname file))))
1089 (install-file file target-dir)))
1090 (find-files "." "\\.h"))
1091 (install-file "gst-plugin/libgstonlinegmmdecodefaster.so"
1092 (string-append lib "/gstreamer-1.0"))
1095 `(("alsa-lib" ,alsa-lib)
1096 ("gfortran" ,gfortran "lib")
1098 ("gstreamer" ,gstreamer)
1100 ("openblas" ,openblas)
1101 ("openfst" ,openfst)
1102 ("portaudio" ,portaudio)
1103 ("python" ,python)))
1105 `(("glib" ,glib "bin") ; glib-genmarshal
1108 ("pkg-config" ,pkg-config)
1110 (home-page "https://kaldi-asr.org/")
1111 (synopsis "Speech recognition toolkit")
1112 (description "Kaldi is an extensible toolkit for speech recognition
1114 (license license:asl2.0))))
1116 (define-public gst-kaldi-nnet2-online
1117 (let ((commit "617e43e73c7cc45eb9119028c02bd4178f738c4a")
1120 (name "gst-kaldi-nnet2-online")
1121 (version (git-version "0" revision commit))
1125 (url "https://github.com/alumae/gst-kaldi-nnet2-online.git")
1127 (file-name (git-file-name name version))
1130 "0xh3w67b69818s6ib02ara4lw7wamjdmh4jznvkpzrs4skbs9jx9"))))
1131 (build-system gnu-build-system)
1133 `(#:tests? #f ; there are none
1135 (list (string-append "SHELL="
1136 (assoc-ref %build-inputs "bash") "/bin/bash")
1137 (string-append "KALDI_ROOT="
1138 (assoc-ref %build-inputs "kaldi-src"))
1139 (string-append "KALDILIBDIR="
1140 (assoc-ref %build-inputs "kaldi") "/lib")
1141 "KALDI_FLAVOR=dynamic")
1143 (modify-phases %standard-phases
1144 (add-after 'unpack 'chdir
1145 (lambda _ (chdir "src") #t))
1147 (lambda* (#:key inputs #:allow-other-keys)
1148 (let ((glib (assoc-ref inputs "glib")))
1149 (setenv "CXXFLAGS" "-fPIC")
1150 (setenv "CPLUS_INCLUDE_PATH"
1151 (string-append glib "/include/glib-2.0:"
1152 glib "/lib/glib-2.0/include:"
1153 (assoc-ref inputs "gstreamer")
1154 "/include/gstreamer-1.0")))
1155 (substitute* "Makefile"
1156 (("include \\$\\(KALDI_ROOT\\)/src/kaldi.mk") "")
1157 (("\\$\\(error Cannot find") "#"))
1159 (add-before 'build 'build-depend
1160 (lambda* (#:key make-flags #:allow-other-keys)
1161 (apply invoke "make" "depend" make-flags)))
1163 (lambda* (#:key outputs #:allow-other-keys)
1164 (let* ((out (assoc-ref outputs "out"))
1165 (lib (string-append out "/lib/gstreamer-1.0")))
1166 (install-file "libgstkaldinnet2onlinedecoder.so" lib)
1170 ("gstreamer" ,gstreamer)
1171 ("jansson" ,jansson)
1172 ("openfst" ,openfst)
1176 ("glib:bin" ,glib "bin") ; glib-genmarshal
1177 ("kaldi-src" ,(package-source kaldi))
1178 ("pkg-config" ,pkg-config)))
1179 (home-page "https://kaldi-asr.org/")
1180 (synopsis "Gstreamer plugin for decoding speech")
1181 (description "This package provides a GStreamer plugin that wraps
1182 Kaldi's @code{SingleUtteranceNnet2Decoder}. It requires iVector-adapted DNN
1183 acoustic models. The iVectors are adapted to the current audio stream
1185 (license license:asl2.0))))
1187 (define-public kaldi-gstreamer-server
1188 (let ((commit "1735ba49c5dc0ebfc184e45105fc600cd9f1f508")
1191 (name "kaldi-gstreamer-server")
1192 (version (git-version "0" revision commit))
1196 (url "https://github.com/alumae/kaldi-gstreamer-server.git")
1198 (file-name (git-file-name name version))
1201 "0j701m7lbwmzqxsfanj882v7881hrbmpqybbczbxqpcbg8q34w0k"))))
1202 (build-system gnu-build-system)
1204 `(#:tests? #f ; there are no tests that can be run automatically
1205 #:modules ((guix build utils)
1206 (guix build gnu-build-system)
1209 (modify-phases %standard-phases
1212 (lambda* (#:key outputs #:allow-other-keys)
1213 ;; Disable hash randomization to ensure the generated .pycs
1214 ;; are reproducible.
1215 (setenv "PYTHONHASHSEED" "0")
1216 (with-directory-excursion "kaldigstserver"
1217 (for-each (lambda (file)
1221 "-f" ; force rebuild
1223 (find-files "." "\\.py$")))
1226 (lambda* (#:key inputs outputs #:allow-other-keys)
1227 (let* ((out (assoc-ref outputs "out"))
1228 (bin (string-append out "/bin"))
1229 (share (string-append out "/share/kaldi-gstreamer-server/")))
1230 ;; Install Python files
1231 (with-directory-excursion "kaldigstserver"
1232 (for-each (cut install-file <> share)
1233 (find-files "." ".*")))
1235 ;; Install sample configuration files
1236 (for-each (cut install-file <> share)
1237 (find-files "." "\\.yaml"))
1239 ;; Install executables
1241 (let* ((server (string-append bin "/kaldi-gst-server"))
1242 (client (string-append bin "/kaldi-gst-client"))
1243 (worker (string-append bin "/kaldi-gst-worker"))
1244 (PYTHONPATH (getenv "PYTHONPATH"))
1245 (GST_PLUGIN_PATH (string-append
1246 (assoc-ref inputs "gst-kaldi-nnet2-online")
1247 "/lib/gstreamer-1.0:${GST_PLUGIN_PATH}"))
1248 (wrap (lambda (wrapper what)
1249 (with-output-to-file wrapper
1253 export PYTHONPATH=~a
1254 export GST_PLUGIN_PATH=~a
1255 exec ~a ~a/~a \"$@\"~%"
1256 (which "bash") PYTHONPATH GST_PLUGIN_PATH
1257 (which "python") share what)))
1258 (chmod wrapper #o555))))
1260 (list server client worker)
1261 (list "master_server.py"
1266 `(("gst-kaldi-nnet2-online" ,gst-kaldi-nnet2-online)
1267 ("python2" ,python-2)
1268 ("python2-futures" ,python2-futures)
1269 ("python2-pygobject" ,python2-pygobject)
1270 ("python2-pyyaml" ,python2-pyyaml)
1271 ("python2-tornado" ,python2-tornado)
1272 ("python2-ws4py" ,python2-ws4py-for-kaldi-gstreamer-server)))
1273 (home-page "https://github.com/alumae/kaldi-gstreamer-server")
1274 (synopsis "Real-time full-duplex speech recognition server")
1275 (description "This is a real-time full-duplex speech recognition server,
1276 based on the Kaldi toolkit and the GStreamer framework and implemented in
1278 (license license:bsd-2))))
1287 (url "https://github.com/grpc/grpc.git")
1288 (commit (string-append "v" version))))
1289 (file-name (git-file-name name version))
1292 "1jimqz3115f9pli5w6ik9wi7mjc7ix6y7yrq4a1ab9fc3dalj7p2"))))
1293 (build-system cmake-build-system)
1295 `(#:tests? #f ; no test target
1297 (list "-DgRPC_ZLIB_PROVIDER=package"
1298 "-DgRPC_CARES_PROVIDER=package"
1299 "-DgRPC_SSL_PROVIDER=package"
1300 "-DgRPC_PROTOBUF_PROVIDER=package")))
1302 `(("c-ares" ,c-ares/cmake)
1303 ("openssl" ,openssl)
1306 `(("protobuf" ,protobuf)
1307 ("python" ,python-wrapper)))
1308 (home-page "https://grpc.io")
1309 (synopsis "High performance universal RPC framework")
1310 (description "gRPC is a modern high performance @dfn{Remote Procedure Call}
1311 (RPC) framework that can run in any environment. It can efficiently connect
1312 services in and across data centers with pluggable support for load balancing,
1313 tracing, health checking and authentication. It is also applicable in last
1314 mile of distributed computing to connect devices, mobile applications and
1315 browsers to backend services.")
1316 (license license:asl2.0)))
1318 ;; Note that Tensorflow includes a "third_party" directory, which seems to not
1319 ;; only contain modified subsets of upstream library source code, but also
1320 ;; adapter headers provided by Google (such as the fft.h header, which is not
1321 ;; part of the upstream project code). The Tensorflow code includes headers
1322 ;; from the "third_party" directory. It does not look like we can replace
1323 ;; these headers with unmodified upstream files, so we keep them.
1324 (define-public tensorflow
1332 (url "https://github.com/tensorflow/tensorflow.git")
1333 (commit (string-append "v" version))))
1334 (file-name (string-append "tensorflow-" version "-checkout"))
1337 "0a9kwha395g3wgxfwln5j8vn9nkspmd75xldrlqdq540w996g8xa"))))
1338 (build-system cmake-build-system)
1340 `(#:tests? #f ; no "check" target
1341 #:build-type "Release"
1343 (let ((protobuf (assoc-ref %build-inputs "protobuf"))
1344 (protobuf:native (assoc-ref %build-inputs "protobuf:native"))
1345 (jsoncpp (assoc-ref %build-inputs "jsoncpp"))
1346 (snappy (assoc-ref %build-inputs "snappy"))
1347 (sqlite (assoc-ref %build-inputs "sqlite")))
1349 ;; Use protobuf from Guix
1350 (string-append "-Dprotobuf_STATIC_LIBRARIES="
1351 protobuf "/lib/libprotobuf.so")
1352 (string-append "-DPROTOBUF_PROTOC_EXECUTABLE="
1353 protobuf:native "/bin/protoc")
1355 ;; Use snappy from Guix
1356 (string-append "-Dsnappy_STATIC_LIBRARIES="
1357 snappy "/lib/libsnappy.so")
1358 ;; Yes, this is not actually the include directory but a prefix...
1359 (string-append "-Dsnappy_INCLUDE_DIR=" snappy)
1361 ;; Use jsoncpp from Guix
1362 (string-append "-Djsoncpp_STATIC_LIBRARIES="
1363 jsoncpp "/lib/libjsoncpp.so")
1364 ;; Yes, this is not actually the include directory but a prefix...
1365 (string-append "-Djsoncpp_INCLUDE_DIR=" jsoncpp)
1367 ;; Use sqlite from Guix
1368 (string-append "-Dsqlite_STATIC_LIBRARIES="
1369 sqlite "/lib/libsqlite.a")
1371 ;; Use system libraries wherever possible. Currently, this
1372 ;; only affects zlib.
1373 "-Dsystemlib_ALL=ON"
1374 "-Dtensorflow_ENABLE_POSITION_INDEPENDENT_CODE=ON"
1375 "-Dtensorflow_BUILD_SHARED_LIB=ON"
1376 "-Dtensorflow_OPTIMIZE_FOR_NATIVE_ARCH=OFF"
1377 "-Dtensorflow_ENABLE_SSL_SUPPORT=OFF"
1378 "-Dtensorflow_BUILD_CONTRIB_KERNELS=OFF"))
1381 #:modules ((ice-9 ftw)
1383 (guix build cmake-build-system))
1385 (modify-phases %standard-phases
1386 (add-after 'unpack 'set-source-file-times-to-1980
1387 ;; At the end of the tf_python_build_pip_package target, a ZIP
1388 ;; archive should be generated via bdist_wheel, but it fails with
1389 ;; "ZIP does not support timestamps before 1980". Luckily,
1390 ;; SOURCE_DATE_EPOCH is respected, which we set to some time in
1392 (lambda _ (setenv "SOURCE_DATE_EPOCH" "315532800") #t))
1393 ;; See https://github.com/tensorflow/tensorflow/issues/20517#issuecomment-406373913
1394 (add-after 'unpack 'python3.7-compatibility
1396 (substitute* '("tensorflow/python/eager/pywrap_tfe_src.cc"
1397 "tensorflow/python/lib/core/ndarray_tensor.cc"
1398 "tensorflow/python/lib/core/py_func.cc")
1399 (("PyUnicode_AsUTF8") "(char *)PyUnicode_AsUTF8"))
1400 (substitute* "tensorflow/c/eager/c_api.h"
1401 (("unsigned char async")
1402 "unsigned char is_async"))
1404 ;; Remove dependency on tensorboard, a complicated but probably
1405 ;; optional package.
1406 (substitute* "tensorflow/tools/pip_package/setup.py"
1407 ((".*'tensorboard >.*") ""))
1409 (add-after 'python3.7-compatibility 'chdir
1410 (lambda _ (chdir "tensorflow/contrib/cmake") #t))
1411 (add-after 'chdir 'disable-downloads
1412 (lambda* (#:key inputs #:allow-other-keys)
1413 (substitute* (find-files "external" "\\.cmake$")
1414 (("GIT_REPOSITORY.*") "")
1417 "DOWNLOAD_COMMAND \"\"\nPREFIX "))
1419 ;; Use packages from Guix
1420 (let ((grpc (assoc-ref inputs "grpc")))
1421 (substitute* "CMakeLists.txt"
1423 (("include\\(sqlite\\)") "")
1424 (("\\$\\{sqlite_STATIC_LIBRARIES\\}")
1425 (string-append (assoc-ref inputs "sqlite")
1426 "/lib/libsqlite3.so"))
1427 (("sqlite_copy_headers_to_destination") "")
1430 (("include\\(png\\)") "")
1431 (("\\$\\{png_STATIC_LIBRARIES\\}")
1432 (string-append (assoc-ref inputs "libpng")
1433 "/lib/libpng16.so"))
1434 (("png_copy_headers_to_destination") "")
1437 (("include\\(jpeg\\)") "")
1438 (("\\$\\{jpeg_STATIC_LIBRARIES\\}")
1439 (string-append (assoc-ref inputs "libjpeg")
1441 (("jpeg_copy_headers_to_destination") "")
1444 (("include\\(gif\\)") "")
1445 (("\\$\\{gif_STATIC_LIBRARIES\\}")
1446 (string-append (assoc-ref inputs "giflib")
1448 (("gif_copy_headers_to_destination") "")
1451 (("include\\(lmdb\\)") "")
1452 (("\\$\\{lmdb_STATIC_LIBRARIES\\}")
1453 (string-append (assoc-ref inputs "lmdb")
1455 (("lmdb_copy_headers_to_destination") "")
1458 (("include\\(protobuf\\)") "")
1459 (("protobuf_copy_headers_to_destination") "")
1460 (("^ +protobuf") "")
1463 (("include\\(grpc\\)")
1464 "find_package(grpc REQUIRED NAMES gRPC)")
1465 (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES grpc\\)") "")
1468 (("include\\(eigen\\)")
1469 (string-append "find_package(eigen REQUIRED NAMES Eigen3)
1470 set(eigen_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/external/eigen_archive "
1471 (assoc-ref inputs "eigen") "/include/eigen3)"))
1475 (("include\\(snappy\\)")
1476 "add_definitions(-DTF_USE_SNAPPY)")
1477 (("list\\(APPEND tensorflow_EXTERNAL_DEPENDENCIES snappy\\)") "")
1480 (("include\\(jsoncpp\\)") "")
1481 (("^ +jsoncpp") ""))
1483 (substitute* "tf_core_framework.cmake"
1485 (("\\$\\{GRPC_BUILD\\}/grpc_cpp_plugin")
1486 (which "grpc_cpp_plugin"))
1487 ;; Link with gRPC libraries
1488 (("add_library\\(tf_protos_cc.*" m)
1490 (format #f "\ntarget_link_libraries(tf_protos_cc PRIVATE \
1491 ~a/lib/libgrpc++_unsecure.a \
1492 ~a/lib/libgrpc_unsecure.a \
1493 ~a/lib/libaddress_sorting.a \
1498 (assoc-ref inputs "c-ares"))))))
1499 (substitute* "tf_tools.cmake"
1500 (("add_dependencies\\(\\$\\{proto_text.*") ""))
1501 ;; Remove dependency on bundled grpc
1502 (substitute* "tf_core_distributed_runtime.cmake"
1503 (("tf_core_cpu grpc") "tf_core_cpu"))
1505 ;; This directory is a dependency of many targets.
1506 (mkdir-p "protobuf")
1508 (add-after 'configure 'unpack-third-party-sources
1509 (lambda* (#:key inputs #:allow-other-keys)
1510 ;; This is needed to configure bundled packages properly.
1511 (setenv "CONFIG_SHELL" (which "bash"))
1514 (let* ((what (assoc-ref inputs (string-append name "-src")))
1515 (name* (string-map (lambda (c)
1518 (where (string-append "../build/" name* "/src/" name*)))
1520 ((string-suffix? ".zip" what)
1522 (with-directory-excursion where
1523 (invoke "unzip" what)))
1524 ((string-suffix? ".tar.gz" what)
1526 (invoke "tar" "xf" what
1527 "-C" where "--strip-components=1"))
1529 (let ((parent (dirname where)))
1531 (with-directory-excursion parent
1532 (when (file-exists? name*)
1533 (delete-file-recursively name*))
1534 (copy-recursively what name*)
1535 (map make-file-writable
1536 (find-files name* ".*"))))))))
1546 (rename-file "../build/cub/src/cub/cub-1.8.0/"
1547 "../build/cub/src/cub/cub/")
1549 (add-after 'unpack 'fix-python-build
1550 (lambda* (#:key inputs outputs #:allow-other-keys)
1551 (mkdir-p "protobuf-src")
1552 (invoke "tar" "xf" (assoc-ref inputs "protobuf:src")
1553 "-C" "protobuf-src" "--strip-components=1")
1554 (mkdir-p "eigen-src")
1555 (invoke "tar" "xf" (assoc-ref inputs "eigen:src")
1556 "-C" "eigen-src" "--strip-components=1")
1558 (substitute* "tensorflow/contrib/cmake/tf_python.cmake"
1559 ;; Ensure that all Python dependencies can be found at build time.
1560 (("PYTHONPATH=\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/tf_python" m)
1561 (string-append m ":" (getenv "PYTHONPATH")))
1562 ;; Take protobuf source files from our source package.
1563 (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/protobuf/src/protobuf/src/google")
1564 (string-append (getcwd) "/protobuf-src/src/google")))
1566 (substitute* '("tensorflow/contrib/cmake/tf_shared_lib.cmake"
1567 "tensorflow/contrib/cmake/tf_python.cmake")
1568 ;; Take Eigen source files from our source package.
1569 (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/eigen/src/eigen/")
1570 (string-append (getcwd) "/eigen-src/"))
1571 ;; Take Eigen headers from our own package.
1572 (("\\$\\{CMAKE_CURRENT_BINARY_DIR\\}/external/eigen_archive")
1573 (string-append (assoc-ref inputs "eigen") "/include/eigen3")))
1575 ;; Correct the RUNPATH of ops libraries generated for Python.
1576 ;; TODO: this doesn't work :(
1577 ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so:
1578 ;; warning: RUNPATH contains bogus entries: ("/tmp/guix-build-tensorflow-1.9.0.drv-0/source/tensorflow/contrib/build")
1579 ;; /gnu/store/...-tensorflow-1.9.0/lib/python3.7/site-packages/tensorflow/contrib/seq2seq/python/ops/lib_beam_search_ops.so:
1580 ;; error: depends on 'libpywrap_tensorflow_internal.so', which
1581 ;; cannot be found in RUNPATH ...
1582 (substitute* "tensorflow/contrib/cmake/tf_cc_ops.cmake"
1583 (("set_target_properties.*")
1584 (string-append "set_target_properties(${_AT_TARGET} PROPERTIES \
1585 COMPILE_FLAGS ${target_compile_flags} \
1586 INSTALL_RPATH_USE_LINK_PATH TRUE \
1587 INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n")))
1589 (add-after 'build 'build-pip-package
1590 (lambda* (#:key outputs #:allow-other-keys)
1592 (string-append "-Wl,-rpath="
1593 (assoc-ref outputs "out") "/lib"))
1594 (invoke "make" "tf_python_build_pip_package")
1596 (add-after 'build-pip-package 'install-python
1597 (lambda* (#:key outputs #:allow-other-keys)
1598 (let ((out (assoc-ref outputs "out"))
1599 (wheel (car (find-files "../build/tf_python/dist/" "\\.whl$"))))
1600 (invoke "python" "-m" "pip" "install" wheel
1601 (string-append "--prefix=" out))
1603 ;; XXX: broken RUNPATH, see fix-python-build phase.
1606 out "/lib/python3.7/site-packages/tensorflow/contrib/"
1607 "seq2seq/python/ops/lib_beam_search_ops.so"))
1610 `(("pkg-config" ,pkg-config)
1611 ("protobuf:native" ,protobuf-3.6) ; protoc
1612 ("protobuf:src" ,(package-source protobuf-3.6))
1613 ("eigen:src" ,(package-source eigen-for-tensorflow))
1614 ;; install_pip_packages.sh wants setuptools 39.1.0 specifically.
1615 ("python-setuptools" ,python-setuptools-for-tensorflow)
1617 ;; The commit hashes and URLs for third-party source code are taken
1618 ;; from "tensorflow/workspace.bzl".
1620 ,(let ((commit "ee7aa02")
1625 (url "https://boringssl.googlesource.com/boringssl")
1627 (file-name (string-append "boringssl-0-" revision
1628 (string-take commit 7)
1632 "1jf693q0nw0adsic6cgmbdx6g7wr4rj4vxa8j1hpn792fqhd8wgw")))))
1634 ,(let ((version "1.8.0"))
1637 (uri (string-append "https://mirror.bazel.build/github.com/NVlabs/"
1638 "cub/archive/" version ".zip"))
1639 (file-name (string-append "cub-" version ".zip"))
1642 "1hsqikqridb90dkxkjr2918dcry6pfh46ccnwrzawl56aamhdykb")))))
1643 ("double-conversion-src"
1644 ,(let ((commit "5664746")
1649 (url "https://github.com/google/double-conversion.git")
1652 (git-file-name "double-conversion"
1653 (string-append "0-" revision "."
1654 (string-take commit 7))))
1657 "1h5lppqqxcvdg5jq42i5msgwx20ryij3apvmndflngrgdpc04gn1")))))
1659 ,(let ((commit "816a4ae622e964763ca0862d9dbd19324a1eaf45"))
1663 "https://mirror.bazel.build/github.com/google/farmhash/archive/"
1665 (file-name (string-append "farmhash-0-" (string-take commit 7)
1669 "185b2xdxl4d4cnsnv6abg8s22gxvx8673jq2yaq85bz4cdy58q35")))))
1670 ;; The license notice on the home page at
1671 ;; http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html says:
1672 ;; Copyright Takuya OOURA, 1996-2001
1674 ;; You may use, copy, modify and distribute this code for any purpose
1675 ;; (include commercial use) and without fee. Please refer to this
1676 ;; package when you modify this code.
1678 ;; We take the identical tarball from the Bazel mirror, because the URL
1679 ;; at the home page is not versioned and might change.
1683 (uri "https://mirror.bazel.build/www.kurims.kyoto-u.ac.jp/~ooura/fft.tgz")
1684 (file-name "fft2d.tar.gz")
1687 "15jjkfvhqvl2c0753d2di8hz0pyzn598g74wqy79awdrf1y67fsj"))))
1689 ,(let ((commit "be5edafc2e1a455768e260ccd68ae7317b6690ee")
1694 (url "https://github.com/google/highwayhash.git")
1696 (file-name (string-append "highwayhash-0-" revision
1697 (string-take commit 7)
1701 "154jwf98cyy54hldr94pgjn85zynly3abpnc1avmb8a18lzwjyb6")))))
1703 ,(let ((version "0559ce013feac8db639ee1bf776aca0325d28777")
1707 (uri (string-append "https://mirror.bazel.build/"
1708 "github.com/google/nsync/archive/"
1710 (file-name (string-append "nsync-0." revision
1711 "-" (string-take version 7)
1715 "0qdkyqym34x739mmzv97ah5r7ph462v5xkxqxvidmcfqbi64b132")))))
1717 ,(let ((commit "e7efc48")
1722 (url "https://github.com/google/re2")
1724 (file-name (string-append "re2-0-" revision
1725 (string-take commit 7)
1729 "161g9841rjfsy5pn52fcis0s9hdr7rxvb06pad38j5rppfihvign")))))
1730 ("googletest" ,googletest)
1734 `(("python-absl-py" ,python-absl-py)
1735 ("python-astor" ,python-astor)
1736 ("python-gast" ,python-gast)
1737 ("python-grpcio" ,python-grpcio)
1738 ("python-numpy" ,python-numpy)
1739 ("python-protobuf" ,python-protobuf-3.6)
1740 ("python-six" ,python-six)
1741 ("python-termcolo" ,python-termcolor)
1742 ("python-wheel" ,python-wheel)))
1744 `(("c-ares" ,c-ares)
1745 ("eigen" ,eigen-for-tensorflow)
1746 ("gemmlowp" ,gemmlowp-for-tensorflow)
1748 ("libjpeg" ,libjpeg)
1752 ("jsoncpp" ,jsoncpp-for-tensorflow)
1755 ("protobuf" ,protobuf-3.6)
1756 ("python" ,python-wrapper)
1758 (home-page "https://tensorflow.org")
1759 (synopsis "Machine learning framework")
1761 "TensorFlow is a flexible platform for building and training machine
1762 learning models. It provides a library for high performance numerical
1763 computation and includes high level Python APIs, including both a sequential
1764 API for beginners that allows users to build models quickly by plugging
1765 together building blocks and a subclassing API with an imperative style for
1766 advanced research.")
1767 (license license:asl2.0)))
1769 (define-public python-iml
1776 (uri (pypi-uri "iml" version))
1779 "1k8szlpm19rcwcxdny9qdm3gmaqq8akb4xlvrzyz8c2d679aak6l"))))
1780 (build-system python-build-system)
1782 `(("ipython" ,python-ipython)
1783 ("nose" ,python-nose)
1784 ("numpy" ,python-numpy)
1785 ("pandas" ,python-pandas)
1786 ("scipy" ,python-scipy)))
1787 (home-page "http://github.com/interpretable-ml/iml")
1788 (synopsis "Interpretable Machine Learning (iML) package")
1789 (description "Interpretable ML (iML) is a set of data type objects,
1790 visualizations, and interfaces that can be used by any method designed to
1791 explain the predictions of machine learning models (or really the output of
1792 any function). It currently contains the interface and IO code from the Shap
1793 project, and it will potentially also do the same for the Lime project.")
1794 (license license:expat)))
1796 (define-public python-keras-applications
1798 (name "python-keras-applications")
1803 (uri (pypi-uri "Keras_Applications" version))
1806 "1rcz31ca4axa6kzhjx4lwqxbg4wvlljkj8qj9a7p9sfd5fhzjyam"))))
1807 (build-system python-build-system)
1808 ;; The tests require Keras, but this package is needed to build Keras.
1809 (arguments '(#:tests? #f))
1811 `(("python-h5py" ,python-h5py)
1812 ("python-numpy" ,python-numpy)))
1814 `(("python-pytest" ,python-pytest)
1815 ("python-pytest-cov" ,python-pytest-cov)
1816 ("python-pytest-pep8" ,python-pytest-pep8)
1817 ("python-pytest-xdist" ,python-pytest-xdist)))
1818 (home-page "https://github.com/keras-team/keras-applications")
1819 (synopsis "Reference implementations of popular deep learning models")
1821 "This package provides reference implementations of popular deep learning
1822 models for use with the Keras deep learning framework.")
1823 (license license:expat)))
1825 (define-public python-keras-preprocessing
1827 (name "python-keras-preprocessing")
1832 (uri (pypi-uri "Keras_Preprocessing" version))
1835 "1r98nm4k1svsqjyaqkfk23i31bl1kcfcyp7094yyj3c43phfp3as"))))
1836 (build-system python-build-system)
1838 `(("python-numpy" ,python-numpy)
1839 ("python-six" ,python-six)))
1841 `(("python-pandas" ,python-pandas)
1842 ("python-pillow" ,python-pillow)
1843 ("python-pytest" ,python-pytest)
1844 ("python-pytest-cov" ,python-pytest-cov)
1845 ("python-pytest-xdist" ,python-pytest-xdist)
1846 ("tensorflow" ,tensorflow)))
1847 (home-page "https://github.com/keras-team/keras-preprocessing/")
1848 (synopsis "Data preprocessing and augmentation for deep learning models")
1850 "Keras Preprocessing is the data preprocessing and data augmentation
1851 module of the Keras deep learning library. It provides utilities for working
1852 with image data, text data, and sequence data.")
1853 (license license:expat)))
1855 (define-public python-keras
1857 (name "python-keras")
1862 (uri (pypi-uri "Keras" version))
1863 (patches (search-patches "python-keras-integration-test.patch"))
1866 "1j8bsqzh49vjdxy6l1k4iwax5vpjzniynyd041xjavdzvfii1dlh"))))
1867 (build-system python-build-system)
1870 (modify-phases %standard-phases
1871 (add-after 'unpack 'remove-tests-for-unavailable-features
1873 (delete-file "keras/backend/theano_backend.py")
1874 (delete-file "keras/backend/cntk_backend.py")
1875 (delete-file "tests/keras/backend/backend_test.py")
1877 ;; FIXME: This doesn't work because Tensorflow is missing the
1878 ;; coder ops library.
1879 (delete-file "tests/keras/test_callbacks.py")
1883 ;; These tests attempt to download data files from the internet.
1884 (delete-file "tests/integration_tests/test_datasets.py")
1885 (delete-file "tests/integration_tests/imagenet_utils_test.py")
1887 (setenv "PYTHONPATH"
1888 (string-append (getcwd) "/build/lib:"
1889 (getenv "PYTHONPATH")))
1890 (invoke "py.test" "-v"
1891 "-p" "no:cacheprovider"
1892 "--ignore" "keras/utils"))))))
1894 `(("python-h5py" ,python-h5py)
1895 ("python-keras-applications" ,python-keras-applications)
1896 ("python-keras-preprocessing" ,python-keras-preprocessing)
1897 ("python-numpy" ,python-numpy)
1898 ("python-pydot" ,python-pydot)
1899 ("python-pyyaml" ,python-pyyaml)
1900 ("python-scipy" ,python-scipy)
1901 ("python-six" ,python-six)
1902 ("tensorflow" ,tensorflow)
1903 ("graphviz" ,graphviz)))
1905 `(("python-pandas" ,python-pandas)
1906 ("python-pytest" ,python-pytest)
1907 ("python-pytest-cov" ,python-pytest-cov)
1908 ("python-pytest-pep8" ,python-pytest-pep8)
1909 ("python-pytest-timeout" ,python-pytest-timeout)
1910 ("python-pytest-xdist" ,python-pytest-xdist)
1911 ("python-sphinx" ,python-sphinx)
1912 ("python-requests" ,python-requests)))
1913 (home-page "https://github.com/keras-team/keras")
1914 (synopsis "High-level deep learning framework")
1915 (description "Keras is a high-level neural networks API, written in Python
1916 and capable of running on top of TensorFlow. It was developed with a focus on
1917 enabling fast experimentation. Use Keras if you need a deep learning library
1921 @item Allows for easy and fast prototyping (through user friendliness,
1922 modularity, and extensibility).
1923 @item Supports both convolutional networks and recurrent networks, as well as
1924 combinations of the two.
1925 @item Runs seamlessly on CPU and GPU.
1927 (license license:expat)))
1929 (define-public sbcl-cl-libsvm-format
1930 (let ((commit "3300f84fd8d9f5beafc114f543f9d83417c742fb")
1933 (name "sbcl-cl-libsvm-format")
1934 (version (git-version "0.1.0" revision commit))
1939 (url "https://github.com/masatoi/cl-libsvm-format.git")
1941 (file-name (git-file-name name version))
1944 "0284aj84xszhkhlivaigf9qj855fxad3mzmv3zfr0qzb5k0nzwrg"))))
1945 (build-system asdf-build-system/sbcl)
1947 `(("prove" ,sbcl-prove)
1948 ("prove-asdf" ,sbcl-prove-asdf)))
1950 `(("alexandria" ,sbcl-alexandria)))
1951 (synopsis "LibSVM data format reader for Common Lisp")
1953 "This Common Lisp library provides a fast reader for data in LibSVM
1955 (home-page "https://github.com/masatoi/cl-libsvm-format")
1956 (license license:expat))))
1958 (define-public cl-libsvm-format
1959 (sbcl-package->cl-source-package sbcl-cl-libsvm-format))
1961 (define-public ecl-cl-libsvm-format
1962 (sbcl-package->ecl-package sbcl-cl-libsvm-format))
1964 (define-public sbcl-cl-online-learning
1965 (let ((commit "fc7a34f4f161cd1c7dd747d2ed8f698947781423")
1968 (name "sbcl-cl-online-learning")
1969 (version (git-version "0.5" revision commit))
1974 (url "https://github.com/masatoi/cl-online-learning.git")
1976 (file-name (git-file-name name version))
1979 "14x95rlg80ay5hv645ki57pqvy12v28hz4k1w0f6bsfi2rmpxchq"))))
1980 (build-system asdf-build-system/sbcl)
1982 `(("prove" ,sbcl-prove)
1983 ("prove-asdf" ,sbcl-prove-asdf)))
1985 `(("cl-libsvm-format" ,sbcl-cl-libsvm-format)
1986 ("cl-store" ,sbcl-cl-store)))
1988 `(;; FIXME: Tests pass but then the check phase crashes
1990 (synopsis "Online Machine Learning for Common Lisp")
1992 "This library contains a collection of machine learning algorithms for
1993 online linear classification written in Common Lisp.")
1994 (home-page "https://github.com/masatoi/cl-online-learning")
1995 (license license:expat))))
1997 (define-public cl-online-learning
1998 (sbcl-package->cl-source-package sbcl-cl-online-learning))
2000 (define-public ecl-cl-online-learning
2001 (sbcl-package->ecl-package sbcl-cl-online-learning))
2003 (define-public sbcl-cl-random-forest
2004 (let ((commit "85fbdd4596d40e824f70f1b7cf239cf544e49d51")
2007 (name "sbcl-cl-random-forest")
2008 (version (git-version "0.1" revision commit))
2013 (url "https://github.com/masatoi/cl-random-forest.git")
2015 (file-name (git-file-name name version))
2018 "097xv60i1ndz68sg9p4pc7c5gvyp9i1xgw966b4wwfq3x6hbz421"))))
2019 (build-system asdf-build-system/sbcl)
2021 `(("prove" ,sbcl-prove)
2022 ("prove-asdf" ,sbcl-prove-asdf)
2023 ("trivial-garbage" ,sbcl-trivial-garbage)))
2025 `(("alexandria" ,sbcl-alexandria)
2026 ("cl-libsvm-format" ,sbcl-cl-libsvm-format)
2027 ("cl-online-learning" ,sbcl-cl-online-learning)
2028 ("lparallel" ,sbcl-lparallel)))
2030 `(;; The tests download data from the Internet
2033 (modify-phases %standard-phases
2034 (add-after 'unpack 'add-sb-cltl2-dependency
2036 ;; sb-cltl2 is required by lparallel when using sbcl, but it is
2037 ;; not loaded automatically.
2038 (substitute* "cl-random-forest.asd"
2039 (("\\(in-package :cl-user\\)")
2040 "(in-package :cl-user) #+sbcl (require :sb-cltl2)"))
2042 (synopsis "Random Forest and Global Refinement for Common Lisp")
2044 "CL-random-forest is an implementation of Random Forest for multiclass
2045 classification and univariate regression written in Common Lisp. It also
2046 includes an implementation of Global Refinement of Random Forest.")
2047 (home-page "https://github.com/masatoi/cl-random-forest")
2048 (license license:expat))))
2050 (define-public cl-random-forest
2051 (sbcl-package->cl-source-package sbcl-cl-random-forest))
2053 (define-public ecl-cl-random-forest
2054 (sbcl-package->ecl-package sbcl-cl-random-forest))
2057 (let ((version "0.0.0") ; no proper version tag
2058 (commit "ca528e32fea9ca8f2b16053cff17160290fc84ce")
2062 (version (git-version version revision commit))
2067 (url "https://github.com/facebookincubator/gloo.git")
2069 (file-name (git-file-name name version))
2072 "1q9f80zy75f6njrzrqkmhc0g3qxs4gskr7ns2jdqanxa2ww7a99w"))))
2073 (build-system cmake-build-system)
2075 `(("googletest" ,googletest)))
2077 `(#:configure-flags '("-DBUILD_TEST=1")
2079 (modify-phases %standard-phases
2082 (invoke "make" "gloo_test")
2084 (synopsis "Collective communications library")
2086 "Gloo is a collective communications library. It comes with a
2087 number of collective algorithms useful for machine learning applications.
2088 These include a barrier, broadcast, and allreduce.")
2089 (home-page "https://github.com/facebookincubator/gloo")
2090 (license license:bsd-3))))