unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
To: 33952@debbugs.gnu.org
Cc: Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
Subject: [bug#33952] [PATCH 02/14] gnu: Add tensorflow-core.
Date: Wed, 2 Jan 2019 17:17:55 +0100	[thread overview]
Message-ID: <20190102161807.28297-2-ricardo.wurmus@mdc-berlin.de> (raw)
In-Reply-To: <20190102161807.28297-1-ricardo.wurmus@mdc-berlin.de>

* gnu/packages/machine-learning.scm (tensorflow-core): New variable.
---
 gnu/packages/machine-learning.scm | 112 ++++++++++++++++++++++++++++++
 1 file changed, 112 insertions(+)

diff --git a/gnu/packages/machine-learning.scm b/gnu/packages/machine-learning.scm
index f4e66b9a3..dd725a609 100644
--- a/gnu/packages/machine-learning.scm
+++ b/gnu/packages/machine-learning.scm
@@ -54,6 +54,7 @@
   #:use-module (gnu packages onc-rpc)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
+  #:use-module (gnu packages protobuf)
   #:use-module (gnu packages python)
   #:use-module (gnu packages statistics)
   #:use-module (gnu packages swig)
@@ -679,6 +680,117 @@ at most 8 bits.  To avoid overflow, results are internally accumulated on more
 than 8 bits, and at the end only some significant 8 bits are kept.")
       (license license:asl2.0))))
 
+(define-public tensorflow-core
+  (package
+    (name "tensorflow-core")
+    (version "1.7.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/tensorflow/tensorflow.git")
+             (commit (string-append "v" version))))
+       (file-name (string-append "tensorflow-" version "-checkout"))
+       (sha256
+        (base32
+         "0jljzbwhmxi8crbivwachcmlfrrv279qrsvwc62cnnbyw0n1g0kp"))))
+    (build-system gnu-build-system)
+    (arguments
+     `(#:tests? #f ; no "check" target
+       #:make-flags
+       (list "-f" "tensorflow/contrib/makefile/Makefile"
+             "CC=gcc")
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (add-after 'unpack 'fix-version
+           (lambda _
+             (substitute* "tensorflow/tools/git/gen_git_source.sh"
+               (("^GIT_VERSION=.*")
+                (string-append "GIT_VERSION=" ,version "\n")))
+             #t))
+         (add-after 'unpack 'unpack-third-party
+           (lambda* (#:key inputs #:allow-other-keys)
+             (with-directory-excursion "tensorflow/contrib/makefile/"
+               (let ((fft2d "downloads/fft2d")
+                     (nsync "downloads/nsync"))
+                 (mkdir-p fft2d)
+                 (invoke "tar" "xf" (assoc-ref inputs "fft2d")
+                         "-C" fft2d "--strip-components=1")
+                 (mkdir-p nsync)
+                 (invoke "tar" "xf" (assoc-ref inputs "nsync")
+                         "-C" nsync "--strip-components=1")))))
+         ;; FIXME: it would be nice to build a separate package for nsync and
+         ;; use it here.  Unfortunately, I could not build Tensorflow with a
+         ;; separately built nsync.
+         (add-before 'build 'build-nsync
+           (lambda _
+             (with-directory-excursion "tensorflow/contrib/makefile/"
+               (invoke "bash" "compile_nsync.sh")
+               (setenv "TARGET_NSYNC_LIB"
+                       "tensorflow/contrib/makefile/downloads/nsync/builds/default.linux.c++11/nsync.a")
+               (setenv "HOST_NSYNC_LIB"
+                       "tensorflow/contrib/makefile/downloads/nsync/builds/default.linux.c++11/nsync.a")
+               #t)))
+         (add-after 'unpack 'find-eigen-headers
+           (lambda* (#:key inputs #:allow-other-keys)
+             ;; Ensure that Eigen headers can be found
+             (setenv "CPLUS_INCLUDE_PATH"
+                     (string-append (getenv "CPLUS_INCLUDE_PATH")
+                                    ":"
+                                    (assoc-ref inputs "eigen")
+                                    "/include/eigen3"))
+             #t))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let* ((out (assoc-ref outputs "out"))
+                    (lib (string-append out "/lib"))
+                    (inc (string-append out "/include")))
+               (install-file "tensorflow/contrib/makefile/gen/lib/libtensorflow-core.a" lib)
+               (for-each (lambda (file)
+                           (let ((target (string-append inc "/"
+                                                        (dirname file))))
+                             (mkdir-p target)
+                             (install-file file target)))
+                         (find-files "tensorflow/core" ".*\\.h$"))
+               #t))))))
+    (native-inputs
+     `(("protobuf" ,protobuf)           ; protoc
+       ;; "You may use, copy, modify this code for any purpose and without
+       ;; fee. You may distribute this ORIGINAL package."
+       ("fft2d"
+        ,(origin
+           (method url-fetch)
+           (uri "https://mirror.bazel.build/www.kurims.kyoto-u.ac.jp/~ooura/fft.tgz")
+           (sha256
+            (base32
+             "15jjkfvhqvl2c0753d2di8hz0pyzn598g74wqy79awdrf1y67fsj"))))
+       ("nsync"
+        ,(origin
+           (method url-fetch)
+           (uri (string-append "https://mirror.bazel.build/"
+                               "github.com/google/nsync/archive/"
+                               "0559ce013feac8db639ee1bf776aca0325d28777.tar.gz"))
+           (sha256
+            (base32
+             "0qdkyqym34x739mmzv97ah5r7ph462v5xkxqxvidmcfqbi64b132"))))
+       ("googletest" ,googletest)))
+    (inputs
+     `(("eigen" ,eigen)
+       ("gemmlowp" ,gemmlowp-for-tensorflow)
+       ("protobuf" ,protobuf)
+       ("zlib" ,zlib)))
+    (home-page "https://tensorflow.org")
+    (synopsis "Machine learning framework")
+    (description
+     "TensorFlow is a software library for high performance numerical
+computation.  Its flexible architecture allows easy deployment of computation
+across a variety of platforms, and from desktops to clusters of servers to
+mobile and edge devices.
+
+This package provides only the core library.")
+    (license license:asl2.0)))
+
 (define-public dlib
   (package
     (name "dlib")
-- 
2.19.1

  reply	other threads:[~2019-01-02 16:19 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-02 16:16 [bug#33952] Add tensorflow Ricardo Wurmus
2019-01-02 16:17 ` [bug#33952] [PATCH 01/14] gnu: Add gemmlowp-for-tensorflow Ricardo Wurmus
2019-01-02 16:17   ` Ricardo Wurmus [this message]
2019-01-02 16:17   ` [bug#33952] [PATCH 03/14] gnu: Add c-ares-next Ricardo Wurmus
2019-01-02 16:17   ` [bug#33952] [PATCH 04/14] gnu: Add protobuf-next Ricardo Wurmus
2019-01-02 16:17   ` [bug#33952] [PATCH 05/14] gnu: Add grpc Ricardo Wurmus
2019-01-02 16:17   ` [bug#33952] [PATCH 06/14] gnu: Add graphviz-2.38 Ricardo Wurmus
2019-01-02 16:18   ` [bug#33952] [PATCH 07/14] gnu: Add python-doctest-ignore-unicode Ricardo Wurmus
2019-01-02 16:18   ` [bug#33952] [PATCH 08/14] gnu: Add python-graphviz Ricardo Wurmus
2019-01-02 16:18   ` [bug#33952] [PATCH 09/14] gnu: Add python-absl-py Ricardo Wurmus
2019-01-02 16:25   ` [bug#33952] [PATCH 10/14] gnu: Add python-astor Ricardo Wurmus
2019-01-02 16:25     ` [bug#33952] [PATCH 11/14] gnu: Add python-astunparse Ricardo Wurmus
2019-01-02 16:25     ` [bug#33952] [PATCH 12/14] gnu: Add python-gast Ricardo Wurmus
2019-01-02 16:25     ` [bug#33952] [PATCH 13/14] gnu: Add python-grpcio Ricardo Wurmus
2019-01-02 16:25     ` [bug#33952] [PATCH 14/14] gnu: Add tensorflow Ricardo Wurmus
2019-04-08 12:45 ` [bug#33952] [PATCH v2] " Ricardo Wurmus
2019-04-11 11:28   ` Ludovic Courtès
2019-04-11 15:55     ` bug#33952: " Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190102161807.28297-2-ricardo.wurmus@mdc-berlin.de \
    --to=ricardo.wurmus@mdc-berlin.de \
    --cc=33952@debbugs.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).