gnu: tensorflow: Enable parallel build (at least partially).

There are still many parts of the build that happen sequentially, but at least
this hastens the long build somewhat.

* gnu/packages/machine-learning.scm (tensorflow)[phases]: Remove trailing #t.
{build-pip-package}: Honor the PARALLEL-BUILD? argument.
This commit is contained in:
Maxim Cournoyer 2021-10-09 00:19:56 -04:00
parent a91eaf1bdc
commit 92c3d1c3d0
No known key found for this signature in database
GPG key ID: 1260E46482E63562

View file

@ -1730,7 +1730,7 @@ (define-public tensorflow
((guix build python-build-system)
#:select (python-version)))
#:imported-modules (,@%cmake-build-system-modules
(guix build python-build-system))
(guix build python-build-system))
#:phases
(modify-phases %standard-phases
(add-after 'unpack 'set-source-file-times-to-1980
@ -1853,8 +1853,7 @@ (define-public tensorflow
(("tf_core_cpu grpc") "tf_core_cpu"))
;; This directory is a dependency of many targets.
(mkdir-p "protobuf")
#t))
(mkdir-p "protobuf")))
(add-after 'configure 'unpack-third-party-sources
(lambda* (#:key inputs #:allow-other-keys)
;; This is needed to configure bundled packages properly.
@ -1932,17 +1931,20 @@ (define-public tensorflow
INSTALL_RPATH_USE_LINK_PATH TRUE \
INSTALL_RPATH " (assoc-ref outputs "out") "/lib)\n")))))
(add-after 'build 'build-pip-package
(lambda* (#:key outputs #:allow-other-keys)
(lambda* (#:key outputs parallel-build? #:allow-other-keys)
(setenv "LDFLAGS"
(string-append "-Wl,-rpath="
(assoc-ref outputs "out") "/lib"))
(invoke "make" "tf_python_build_pip_package")))
(invoke "make" "-j" (if parallel-build?
(number->string (parallel-job-count))
"1")
"tf_python_build_pip_package")))
(add-after 'build-pip-package 'install-python
(lambda* (#:key inputs outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))
(wheel (car (find-files "../build/tf_python/dist/" "\\.whl$")))
(python-version (python-version
(assoc-ref inputs "python"))))
(assoc-ref inputs "python"))))
(invoke "python" "-m" "pip" "install" wheel
(string-append "--prefix=" out))