1 |
commit: 08fd73895803f777a23820de619412ac3e03c68a |
2 |
Author: Jason Zaman <perfinion <AT> gentoo <DOT> org> |
3 |
AuthorDate: Sat Oct 16 12:19:48 2021 +0000 |
4 |
Commit: Jason Zaman <perfinion <AT> gentoo <DOT> org> |
5 |
CommitDate: Sat Oct 16 12:20:24 2021 +0000 |
6 |
URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=08fd7389 |
7 |
|
8 |
sci-libs/tensorflow: Fix system protobuf |
9 |
|
10 |
When tensorflow and python protobuf use the same instance of |
11 |
libprotobuf, pywrap_tensorflow must be imported before anything |
12 |
else that would import protobuf definitions. |
13 |
|
14 |
Package-Manager: Portage-3.0.20, Repoman-3.0.3 |
15 |
Signed-off-by: Jason Zaman <perfinion <AT> gentoo.org> |
16 |
|
17 |
sci-libs/tensorflow/Manifest | 1 + |
18 |
sci-libs/tensorflow/tensorflow-2.5.0-r2.ebuild | 413 +++++++++++++++++++++++++ |
19 |
2 files changed, 414 insertions(+) |
20 |
|
21 |
diff --git a/sci-libs/tensorflow/Manifest b/sci-libs/tensorflow/Manifest |
22 |
index ff0e11a9eb4..7fe3a6d8b67 100644 |
23 |
--- a/sci-libs/tensorflow/Manifest |
24 |
+++ b/sci-libs/tensorflow/Manifest |
25 |
@@ -32,4 +32,5 @@ DIST sobol_data-835a7d7b1ee3bc83e575e302a985c66ec4b65249.tar.gz 2569603 BLAKE2B |
26 |
DIST tensorflow-1.15.0-python-license.rst.txt 45132 BLAKE2B 8a8ace4b64fd9eda1932272704dd4fea002d2562cd9c2c94470d3ff5de58bb171ff849d3f998ea90cd779d1084d39af1267aca8400b74b701205d2e76e6a2628 SHA512 c79c42f4ceecf33c8f8778ca17b53595b75d5d0bdf30b11058cf01dd70a6351f530ca9dd846460aba14edc1d5876f7bf6fa0f9f49f7915590b0f54d267ce3856 |
27 |
DIST tensorflow-2.5.0.tar.gz 55999506 BLAKE2B 0f1f29ed9ff6e5fd3fc0c98419bca636f48085810f934290885b3469c45817b2ce17e9dbd3d93d70b09ec7975088edd0973f147449f527a8f2e23b388e2592ce SHA512 637c63b1bed1c0eb7bb018f1ff7f29f7f0d78e75dac384df4ecb5dfb92bbcb28209e3d3d2204145abddf88e3247d8c31bbb4cea032a73b7122b2ef3eb0d2b947 |
28 |
DIST tensorflow-patches-2.5.0-r1.tar.bz2 5180 BLAKE2B aafebb5cc4616ad93982e0fd8299f91c22063b96841b920a98a4cb54bcdc0cad51011f943ca62055239a0c21ed69d1f5b985710dcf0c28346b7ba12114583842 SHA512 38acd53136f3f1e061b71624cc5a1cefbdcb1d897b7728bc93462e8f52e998c3d72453ca9c94fa53dd28279cae5c591b7cbe9f61684784ff94c451a641524f31 |
29 |
+DIST tensorflow-patches-2.5.0-r2.tar.bz2 5538 BLAKE2B df289d77a79bb2143ebe26685f3c8f2efe64819a2fd6bd9866bc05638d2c19e822ddb90df3f342f1fc27827b3799531ad4ed280f9cc5291e75b1c2042a61603f SHA512 4f5ecb4efb56e735ee79dd07e0e8737f535da4e9ba8f63f769d548813e5aa7017e03cd1bd0d661e1958fa2916df7c7f25a7c0d141dbfe9716586ca82c021169f |
30 |
DIST tensorflow-toolchains-v1.1.10.tar.gz 137512 BLAKE2B 774b22a599070564c0f77ed0da79f6a96359b196dd3007370be885b796c236b9a29c01597507a3049f82cf489824c8016740b778cacb2b8cd859500f9ecb1887 SHA512 1daf4684f5b364a89b3cc475cf2d13d0d0622fc14d2b32d7ad8518932538e716782d755cfcedc98d129a3986bc7c38bfc7854c8ad596891e397510b75ae2f93e |
31 |
|
32 |
diff --git a/sci-libs/tensorflow/tensorflow-2.5.0-r2.ebuild b/sci-libs/tensorflow/tensorflow-2.5.0-r2.ebuild |
33 |
new file mode 100644 |
34 |
index 00000000000..5f4f341f0cb |
35 |
--- /dev/null |
36 |
+++ b/sci-libs/tensorflow/tensorflow-2.5.0-r2.ebuild |
37 |
@@ -0,0 +1,413 @@ |
38 |
+# Copyright 1999-2021 Gentoo Authors |
39 |
+# Distributed under the terms of the GNU General Public License v2 |
40 |
+ |
41 |
+EAPI=7 |
42 |
+ |
43 |
+DISTUTILS_OPTIONAL=1 |
44 |
+PYTHON_COMPAT=( python3_{7,8,9} ) |
45 |
+DISTUTILS_USE_SETUPTOOLS=rdepend |
46 |
+MY_PV=${PV/_rc/-rc} |
47 |
+MY_P=${PN}-${MY_PV} |
48 |
+ |
49 |
+inherit bazel check-reqs cuda distutils-r1 flag-o-matic prefix toolchain-funcs |
50 |
+ |
51 |
+DESCRIPTION="Computation framework using data flow graphs for scalable machine learning" |
52 |
+HOMEPAGE="https://www.tensorflow.org/" |
53 |
+ |
54 |
+LICENSE="Apache-2.0" |
55 |
+SLOT="0" |
56 |
+KEYWORDS="~amd64" |
57 |
+IUSE="cuda mpi +python xla" |
58 |
+CPU_USE_FLAGS_X86="sse sse2 sse3 sse4_1 sse4_2 avx avx2 fma3 fma4" |
59 |
+for i in $CPU_USE_FLAGS_X86; do |
60 |
+ IUSE+=" cpu_flags_x86_${i}" |
61 |
+done |
62 |
+ |
63 |
+# distfiles that bazel uses for the workspace, will be copied to basel-distdir |
64 |
+bazel_external_uris=" |
65 |
+ https://github.com/abseil/abseil-cpp/archive/6f9d96a1f41439ac172ee2ef7ccd8edf0e5d068c.tar.gz -> abseil-cpp-6f9d96a1f41439ac172ee2ef7ccd8edf0e5d068c.tar.gz |
66 |
+ https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz |
67 |
+ https://github.com/bazelbuild/bazel-toolchains/archive/92dd8a7a518a2fb7ba992d47c8b38299fe0be825.tar.gz -> bazel-toolchains-92dd8a7a518a2fb7ba992d47c8b38299fe0be825.tar.gz |
68 |
+ https://github.com/bazelbuild/rules_android/archive/v0.1.1.zip -> bazelbuild-rules_android-v0.1.1.zip |
69 |
+ https://github.com/bazelbuild/rules_cc/archive/01d4a48911d5e7591ecb1c06d3b8af47fe872371.zip -> bazelbuild-rules_cc-01d4a48911d5e7591ecb1c06d3b8af47fe872371.zip |
70 |
+ https://github.com/bazelbuild/rules_closure/archive/308b05b2419edb5c8ee0471b67a40403df940149.tar.gz -> bazelbuild-rules_closure-308b05b2419edb5c8ee0471b67a40403df940149.tar.gz |
71 |
+ https://github.com/bazelbuild/rules_docker/releases/download/v0.10.0/rules_docker-v0.10.0.tar.gz -> bazelbuild-rules_docker-v0.10.0.tar.gz |
72 |
+ https://github.com/bazelbuild/rules_java/archive/7cf3cefd652008d0a64a419c34c13bdca6c8f178.zip -> bazelbuild-rules_java-7cf3cefd652008d0a64a419c34c13bdca6c8f178.zip |
73 |
+ https://github.com/bazelbuild/rules_proto/archive/97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz -> bazelbuild-rules_proto-97d8af4dc474595af3900dd85cb3a29ad28cc313.tar.gz |
74 |
+ https://github.com/bazelbuild/rules_python/releases/download/0.0.1/rules_python-0.0.1.tar.gz -> bazelbuild-rules_python-0.0.1.tar.gz |
75 |
+ https://github.com/bazelbuild/rules_swift/archive/3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8.tar.gz -> bazelbuild-rules_swift-3eeeb53cebda55b349d64c9fc144e18c5f7c0eb8.tar.gz |
76 |
+ https://github.com/dmlc/dlpack/archive/3efc489b55385936531a06ff83425b719387ec63.tar.gz -> dlpack-3efc489b55385936531a06ff83425b719387ec63.tar.gz |
77 |
+ https://github.com/google/farmhash/archive/816a4ae622e964763ca0862d9dbd19324a1eaf45.tar.gz -> farmhash-816a4ae622e964763ca0862d9dbd19324a1eaf45.tar.gz |
78 |
+ https://github.com/google/gemmlowp/archive/fda83bdc38b118cc6b56753bd540caa49e570745.zip -> gemmlowp-fda83bdc38b118cc6b56753bd540caa49e570745.zip |
79 |
+ https://github.com/google/highwayhash/archive/fd3d9af80465e4383162e4a7c5e2f406e82dd968.tar.gz -> highwayhash-fd3d9af80465e4383162e4a7c5e2f406e82dd968.tar.gz |
80 |
+ https://github.com/google/re2/archive/506cfa4bffd060c06ec338ce50ea3468daa6c814.tar.gz -> re2-506cfa4bffd060c06ec338ce50ea3468daa6c814.tar.gz |
81 |
+ https://github.com/google/ruy/archive/54774a7a2cf85963777289193629d4bd42de4a59.zip -> ruy-54774a7a2cf85963777289193629d4bd42de4a59.zip |
82 |
+ https://github.com/joe-kuo/sobol_data/archive/835a7d7b1ee3bc83e575e302a985c66ec4b65249.tar.gz -> sobol_data-835a7d7b1ee3bc83e575e302a985c66ec4b65249.tar.gz |
83 |
+ https://github.com/llvm/llvm-project/archive/1f6a57c1a0fad922e04a2b1f414b092d4b0cd8b0.tar.gz -> llvm-1f6a57c1a0fad922e04a2b1f414b092d4b0cd8b0.tar.gz |
84 |
+ https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/openmp-10.0.1.src.tar.xz -> llvmorg-10.0.1-openmp-10.0.1.src.tar.xz |
85 |
+ https://github.com/mborgerding/kissfft/archive/36dbc057604f00aacfc0288ddad57e3b21cfc1b8.tar.gz -> kissfft-36dbc057604f00aacfc0288ddad57e3b21cfc1b8.tar.gz |
86 |
+ https://github.com/oneapi-src/oneDNN/archive/v2.2.tar.gz -> oneDNN-v2.2.tar.gz |
87 |
+ https://github.com/petewarden/OouraFFT/archive/v1.0.tar.gz -> OouraFFT-v1.0.tar.gz |
88 |
+ https://github.com/pytorch/cpuinfo/archive/5916273f79a21551890fd3d56fc5375a78d1598d.zip -> pytorch-cpuinfo-5916273f79a21551890fd3d56fc5375a78d1598d.zip |
89 |
+ https://github.com/pytorch/cpuinfo/archive/d5e37adf1406cf899d7d9ec1d317c47506ccb970.tar.gz -> pytorch-cpuinfo-d5e37adf1406cf899d7d9ec1d317c47506ccb970.tar.gz |
90 |
+ https://github.com/tensorflow/toolchains/archive/v1.1.10.tar.gz -> tensorflow-toolchains-v1.1.10.tar.gz |
91 |
+ https://gitlab.com/libeigen/eigen/-/archive/f612df273689a19d25b45ca4f8269463207c4fee/eigen-f612df273689a19d25b45ca4f8269463207c4fee.tar.gz |
92 |
+ cuda? ( |
93 |
+ https://github.com/NVIDIA/cudnn-frontend/archive/360d6e7164dfb7c802493fd1c0464f0d815b852a.zip -> cudnn-frontend-360d6e7164dfb7c802493fd1c0464f0d815b852a.zip |
94 |
+ https://github.com/NVlabs/cub/archive/1.9.9.zip -> cub-1.9.9.zip |
95 |
+ https://github.com/nvidia/nccl/archive/v2.8.3-1.tar.gz -> nvidia-nccl-v2.8.3-1.tar.gz |
96 |
+ ) |
97 |
+ python? ( |
98 |
+ https://github.com/intel/ARM_NEON_2_x86_SSE/archive/1200fe90bb174a6224a525ee60148671a786a71f.tar.gz -> ARM_NEON_2_x86_SSE-1200fe90bb174a6224a525ee60148671a786a71f.tar.gz |
99 |
+ https://storage.googleapis.com/mirror.tensorflow.org/docs.python.org/2.7/_sources/license.rst.txt -> tensorflow-1.15.0-python-license.rst.txt |
100 |
+ https://pypi.python.org/packages/bc/cc/3cdb0a02e7e96f6c70bd971bc8a90b8463fda83e264fa9c5c1c98ceabd81/backports.weakref-1.0rc1.tar.gz |
101 |
+ )" |
102 |
+ |
103 |
+SRC_URI="https://github.com/${PN}/${PN}/archive/v${MY_PV}.tar.gz -> ${P}.tar.gz |
104 |
+ https://dev.gentoo.org/~perfinion/patches/tensorflow-patches-${PVR}.tar.bz2 |
105 |
+ ${bazel_external_uris}" |
106 |
+ |
107 |
+RDEPEND=" |
108 |
+ app-arch/snappy |
109 |
+ dev-db/lmdb |
110 |
+ dev-db/sqlite |
111 |
+ dev-libs/double-conversion |
112 |
+ dev-libs/icu:= |
113 |
+ >=dev-libs/jsoncpp-1.9.2 |
114 |
+ dev-libs/libpcre |
115 |
+ dev-libs/nsync |
116 |
+ dev-libs/openssl:0= |
117 |
+ >=dev-libs/protobuf-3.13.0:= |
118 |
+ >=dev-libs/re2-0.2019.06.01:= |
119 |
+ media-libs/giflib |
120 |
+ media-libs/libjpeg-turbo |
121 |
+ media-libs/libpng:0 |
122 |
+ >=net-libs/grpc-1.28:= |
123 |
+ net-misc/curl |
124 |
+ sys-libs/zlib |
125 |
+ >=sys-apps/hwloc-2 |
126 |
+ cuda? ( |
127 |
+ =dev-util/nvidia-cuda-toolkit-11*[profiler] |
128 |
+ =dev-libs/cudnn-8* |
129 |
+ ) |
130 |
+ mpi? ( virtual/mpi ) |
131 |
+ python? ( |
132 |
+ ${PYTHON_DEPS} |
133 |
+ >=dev-libs/flatbuffers-1.12.0:= |
134 |
+ dev-python/absl-py[${PYTHON_USEDEP}] |
135 |
+ >=dev-python/astor-0.7.1[${PYTHON_USEDEP}] |
136 |
+ dev-python/astunparse[${PYTHON_USEDEP}] |
137 |
+ dev-python/dill[${PYTHON_USEDEP}] |
138 |
+ dev-python/flatbuffers[${PYTHON_USEDEP}] |
139 |
+ >=dev-python/gast-0.3.3[${PYTHON_USEDEP}] |
140 |
+ dev-python/h5py[${PYTHON_USEDEP}] |
141 |
+ >=dev-python/numpy-1.19[${PYTHON_USEDEP}] |
142 |
+ >=dev-python/google-pasta-0.1.8[${PYTHON_USEDEP}] |
143 |
+ >=dev-python/opt-einsum-3.3.0[${PYTHON_USEDEP}] |
144 |
+ >=dev-python/protobuf-python-3.13.0[${PYTHON_USEDEP}] |
145 |
+ dev-python/pybind11[${PYTHON_USEDEP}] |
146 |
+ dev-python/six[${PYTHON_USEDEP}] |
147 |
+ dev-python/tblib[${PYTHON_USEDEP}] |
148 |
+ dev-python/termcolor[${PYTHON_USEDEP}] |
149 |
+ dev-python/typing-extensions[${PYTHON_USEDEP}] |
150 |
+ >=dev-python/grpcio-1.28[${PYTHON_USEDEP}] |
151 |
+ >=dev-python/wrapt-1.11.1[${PYTHON_USEDEP}] |
152 |
+ >=net-libs/google-cloud-cpp-0.10.0 |
153 |
+ >=sci-libs/keras-applications-1.0.8[${PYTHON_USEDEP}] |
154 |
+ >=sci-libs/keras-preprocessing-1.1.2[${PYTHON_USEDEP}] |
155 |
+ >=sci-visualization/tensorboard-2.5.0[${PYTHON_USEDEP}] |
156 |
+ )" |
157 |
+DEPEND="${RDEPEND} |
158 |
+ python? ( |
159 |
+ dev-python/mock |
160 |
+ dev-python/setuptools |
161 |
+ )" |
162 |
+PDEPEND="python? ( |
163 |
+ >=sci-libs/tensorflow-estimator-2.5.0[${PYTHON_USEDEP}] |
164 |
+ )" |
165 |
+BDEPEND=" |
166 |
+ app-arch/unzip |
167 |
+ >=dev-libs/protobuf-3.8.0 |
168 |
+ dev-java/java-config |
169 |
+ >=dev-util/bazel-3.7.2 |
170 |
+ cuda? ( |
171 |
+ >=dev-util/nvidia-cuda-toolkit-9.1[profiler] |
172 |
+ ) |
173 |
+ !python? ( dev-lang/python ) |
174 |
+ python? ( |
175 |
+ dev-python/cython |
176 |
+ dev-python/mock |
177 |
+ >=dev-python/grpcio-tools-1.28 |
178 |
+ )" |
179 |
+REQUIRED_USE="python? ( ${PYTHON_REQUIRED_USE} )" |
180 |
+ |
181 |
+S="${WORKDIR}/${MY_P}" |
182 |
+ |
183 |
+PATCHES=( |
184 |
+ "${FILESDIR}/0008-patch-ruy-for-gcc-11.patch" |
185 |
+) |
186 |
+DOCS=( AUTHORS CONTRIBUTING.md ISSUE_TEMPLATE.md README.md RELEASE.md ) |
187 |
+CHECKREQS_MEMORY="5G" |
188 |
+CHECKREQS_DISK_BUILD="10G" |
189 |
+ |
190 |
+get-cpu-flags() { |
191 |
+ local i f=() |
192 |
+ # Keep this list in sync with tensorflow/core/platform/cpu_feature_guard.cc. |
193 |
+ for i in sse sse2 sse3 sse4_1 sse4_2 avx avx2 fma4; do |
194 |
+ use cpu_flags_x86_${i} && f+=( -m${i/_/.} ) |
195 |
+ done |
196 |
+ use cpu_flags_x86_fma3 && f+=( -mfma ) |
197 |
+ echo "${f[*]}" |
198 |
+} |
199 |
+ |
200 |
+pkg_setup() { |
201 |
+ ewarn "TensorFlow 2.0 is a major release that contains some incompatibilities" |
202 |
+ ewarn "with TensorFlow 1.x. For more information about migrating to TF2.0 see:" |
203 |
+ ewarn "https://www.tensorflow.org/guide/migrate" |
204 |
+ |
205 |
+ local num_pythons_enabled |
206 |
+ num_pythons_enabled=0 |
207 |
+ count_impls() { |
208 |
+ num_pythons_enabled=$((${num_pythons_enabled} + 1)) |
209 |
+ } |
210 |
+ use python && python_foreach_impl count_impls |
211 |
+ |
212 |
+ # 10G to build C/C++ libs, 5G per python impl |
213 |
+ CHECKREQS_DISK_BUILD="$((10 + 6 * ${num_pythons_enabled}))G" |
214 |
+ check-reqs_pkg_setup |
215 |
+} |
216 |
+ |
217 |
+src_unpack() { |
218 |
+ # Only unpack the main distfile |
219 |
+ unpack "${P}.tar.gz" |
220 |
+ unpack tensorflow-patches-${PVR}.tar.bz2 |
221 |
+ bazel_load_distfiles "${bazel_external_uris}" |
222 |
+} |
223 |
+ |
224 |
+src_prepare() { |
225 |
+ export JAVA_HOME=$(java-config --jre-home) # so keepwork works |
226 |
+ |
227 |
+ append-flags $(get-cpu-flags) |
228 |
+ append-cxxflags -std=c++14 # bug 787938 |
229 |
+ filter-flags '-fvtable-verify=@(std|preinit)' |
230 |
+ bazel_setup_bazelrc |
231 |
+ |
232 |
+ eapply "${WORKDIR}"/patches/*.patch |
233 |
+ |
234 |
+ # Relax version checks in setup.py |
235 |
+ sed -i "/^ '/s/==/>=/g" tensorflow/tools/pip_package/setup.py || die |
236 |
+ sed -i "/config_googleapis/d" tensorflow/workspace0.bzl || die |
237 |
+ |
238 |
+ # Prefixify hard-coded command locations |
239 |
+ hprefixify -w /host_compiler_prefix/ third_party/gpus/cuda_configure.bzl |
240 |
+ |
241 |
+ default |
242 |
+ use python && python_copy_sources |
243 |
+ |
244 |
+ use cuda && cuda_add_sandbox |
245 |
+} |
246 |
+ |
247 |
+src_configure() { |
248 |
+ export JAVA_HOME=$(java-config --jre-home) # so keepwork works |
249 |
+ export KERAS_HOME="${T}/.keras" # otherwise sandbox violation writing ~/.keras |
250 |
+ |
251 |
+ do_configure() { |
252 |
+ export CC_OPT_FLAGS=" " |
253 |
+ export TF_ENABLE_XLA=$(usex xla 1 0) |
254 |
+ export TF_NEED_OPENCL_SYCL=0 |
255 |
+ export TF_NEED_OPENCL=0 |
256 |
+ export TF_NEED_COMPUTECPP=0 |
257 |
+ export TF_NEED_ROCM=0 |
258 |
+ export TF_NEED_MPI=$(usex mpi 1 0) |
259 |
+ export TF_SET_ANDROID_WORKSPACE=0 |
260 |
+ |
261 |
+ if use python; then |
262 |
+ export PYTHON_BIN_PATH="${PYTHON}" |
263 |
+ export PYTHON_LIB_PATH="$(python_get_sitedir)" |
264 |
+ else |
265 |
+ export PYTHON_BIN_PATH="$(which python)" |
266 |
+ export PYTHON_LIB_PATH="$(python -c 'from distutils.sysconfig import *; print(get_python_lib())')" |
267 |
+ fi |
268 |
+ |
269 |
+ export TF_NEED_CUDA=$(usex cuda 1 0) |
270 |
+ export TF_DOWNLOAD_CLANG=0 |
271 |
+ export TF_CUDA_CLANG=0 |
272 |
+ export TF_NEED_TENSORRT=0 |
273 |
+ if use cuda; then |
274 |
+ export TF_CUDA_PATHS="${EPREFIX}/opt/cuda" |
275 |
+ export GCC_HOST_COMPILER_PATH="$(cuda_gccdir)/$(tc-getCC)" |
276 |
+ export TF_CUDA_VERSION="$(cuda_toolkit_version)" |
277 |
+ export TF_CUDNN_VERSION="$(cuda_cudnn_version)" |
278 |
+ einfo "Setting CUDA version: $TF_CUDA_VERSION" |
279 |
+ einfo "Setting CUDNN version: $TF_CUDNN_VERSION" |
280 |
+ |
281 |
+ if [[ $(cuda-config -s) != *$(gcc-version)* ]]; then |
282 |
+ ewarn "TensorFlow is being built with Nvidia CUDA support. Your default compiler" |
283 |
+ ewarn "version is not supported by the currently installed CUDA. TensorFlow will" |
284 |
+ ewarn "instead be compiled using: ${GCC_HOST_COMPILER_PATH}." |
285 |
+ ewarn "If the build fails with linker errors try rebuilding the relevant" |
286 |
+ ewarn "dependencies using the same compiler version." |
287 |
+ fi |
288 |
+ |
289 |
+ if [[ -z "$TF_CUDA_COMPUTE_CAPABILITIES" ]]; then |
290 |
+ ewarn "WARNING: TensorFlow is being built with its default CUDA compute capabilities: 3.5 and 7.0." |
291 |
+ ewarn "These may not be optimal for your GPU." |
292 |
+ ewarn "" |
293 |
+ ewarn "To configure TensorFlow with the CUDA compute capability that is optimal for your GPU," |
294 |
+ ewarn "set TF_CUDA_COMPUTE_CAPABILITIES in your make.conf, and re-emerge tensorflow." |
295 |
+ ewarn "For example, to use CUDA capability 7.5 & 3.5, add: TF_CUDA_COMPUTE_CAPABILITIES=7.5,3.5" |
296 |
+ ewarn "" |
297 |
+ ewarn "You can look up your GPU's CUDA compute capability at https://developer.nvidia.com/cuda-gpus" |
298 |
+ ewarn "or by running /opt/cuda/extras/demo_suite/deviceQuery | grep 'CUDA Capability'" |
299 |
+ fi |
300 |
+ fi |
301 |
+ |
302 |
+ # com_googlesource_code_re2 weird branch using absl, doesnt work with released re2 |
303 |
+ #com_github_googleapis_googleapis |
304 |
+ local SYSLIBS=( |
305 |
+ absl_py |
306 |
+ astor_archive |
307 |
+ astunparse_archive |
308 |
+ boringssl |
309 |
+ com_github_googlecloudplatform_google_cloud_cpp |
310 |
+ com_github_grpc_grpc |
311 |
+ com_google_protobuf |
312 |
+ curl |
313 |
+ cython |
314 |
+ dill_archive |
315 |
+ double_conversion |
316 |
+ enum34_archive |
317 |
+ flatbuffers |
318 |
+ functools32_archive |
319 |
+ gast_archive |
320 |
+ gif |
321 |
+ hwloc |
322 |
+ icu |
323 |
+ jsoncpp_git |
324 |
+ libjpeg_turbo |
325 |
+ lmdb |
326 |
+ nasm |
327 |
+ nsync |
328 |
+ opt_einsum_archive |
329 |
+ org_sqlite |
330 |
+ pasta |
331 |
+ pcre |
332 |
+ png |
333 |
+ pybind11 |
334 |
+ six_archive |
335 |
+ snappy |
336 |
+ tblib_archive |
337 |
+ termcolor_archive |
338 |
+ typing_extensions_archive |
339 |
+ wrapt |
340 |
+ zlib |
341 |
+ ) |
342 |
+ |
343 |
+ export TF_SYSTEM_LIBS="${SYSLIBS[@]}" |
344 |
+ export TF_IGNORE_MAX_BAZEL_VERSION=1 |
345 |
+ |
346 |
+ # This is not autoconf |
347 |
+ ./configure || die |
348 |
+ |
349 |
+ echo 'build --config=noaws --config=nohdfs' >> .bazelrc || die |
350 |
+ echo 'build --define tensorflow_mkldnn_contraction_kernel=0' >> .bazelrc || die |
351 |
+ echo "build --action_env=KERAS_HOME=\"${T}/.keras\"" >> .bazelrc || die |
352 |
+ echo "build --host_action_env=KERAS_HOME=\"${T}/.keras\"" >> .bazelrc || die |
353 |
+ |
354 |
+ for cflag in $($(tc-getPKG_CONFIG) jsoncpp --cflags) |
355 |
+ do |
356 |
+ echo "build --copt=\"${cflag}\"" >> .bazelrc || die |
357 |
+ echo "build --host_copt=\"${cflag}\"" >> .bazelrc || die |
358 |
+ done |
359 |
+ } |
360 |
+ if use python; then |
361 |
+ python_foreach_impl run_in_build_dir do_configure |
362 |
+ else |
363 |
+ do_configure |
364 |
+ fi |
365 |
+} |
366 |
+ |
367 |
+src_compile() { |
368 |
+ export JAVA_HOME=$(java-config --jre-home) # so keepwork works |
369 |
+ export KERAS_HOME="${T}/.keras" # otherwise sandbox violation writing ~/.keras |
370 |
+ |
371 |
+ if use python; then |
372 |
+ python_setup |
373 |
+ BUILD_DIR="${S}-${EPYTHON/./_}" |
374 |
+ cd "${BUILD_DIR}" |
375 |
+ fi |
376 |
+ |
377 |
+ # fail early if any deps are missing |
378 |
+ ebazel build -k --nobuild \ |
379 |
+ //tensorflow:libtensorflow_framework.so \ |
380 |
+ //tensorflow:libtensorflow.so \ |
381 |
+ //tensorflow:libtensorflow_cc.so \ |
382 |
+ $(usex python '//tensorflow/tools/pip_package:build_pip_package' '') |
383 |
+ |
384 |
+ ebazel build \ |
385 |
+ //tensorflow:libtensorflow_framework.so \ |
386 |
+ //tensorflow:libtensorflow.so |
387 |
+ ebazel build //tensorflow:libtensorflow_cc.so |
388 |
+ |
389 |
+ do_compile() { |
390 |
+ ebazel build //tensorflow/tools/pip_package:build_pip_package |
391 |
+ } |
392 |
+ BUILD_DIR="${S}" |
393 |
+ cd "${BUILD_DIR}" |
394 |
+ use python && python_foreach_impl run_in_build_dir do_compile |
395 |
+ ebazel shutdown |
396 |
+} |
397 |
+ |
398 |
+src_install() { |
399 |
+ local i l |
400 |
+ export JAVA_HOME=$(java-config --jre-home) # so keepwork works |
401 |
+ export KERAS_HOME="${T}/.keras" # otherwise sandbox violation writing ~/.keras |
402 |
+ |
403 |
+ do_install() { |
404 |
+ einfo "Installing ${EPYTHON} files" |
405 |
+ local srcdir="${T}/src-${MULTIBUILD_VARIANT}" |
406 |
+ mkdir -p "${srcdir}" || die |
407 |
+ bazel-bin/tensorflow/tools/pip_package/build_pip_package --src "${srcdir}" || die |
408 |
+ cd "${srcdir}" || die |
409 |
+ esetup.py install |
410 |
+ |
411 |
+ # libtensorflow_framework.so is in /usr/lib already |
412 |
+ rm -f "${D}/$(python_get_sitedir)"/${PN}/lib${PN}_framework.so* || die |
413 |
+ rm -f "${D}/$(python_get_sitedir)"/${PN}_core/lib${PN}_framework.so* || die |
414 |
+ python_optimize |
415 |
+ } |
416 |
+ |
417 |
+ if use python; then |
418 |
+ python_foreach_impl run_in_build_dir do_install |
419 |
+ |
420 |
+ # Symlink to python-exec scripts |
421 |
+ for i in "${ED}"/usr/lib/python-exec/*/*; do |
422 |
+ n="${i##*/}" |
423 |
+ [[ -e "${ED}/usr/bin/${n}" ]] || dosym ../lib/python-exec/python-exec2 "/usr/bin/${n}" |
424 |
+ done |
425 |
+ |
426 |
+ python_setup |
427 |
+ local BUILD_DIR="${S}-${EPYTHON/./_}" |
428 |
+ cd "${BUILD_DIR}" || die |
429 |
+ fi |
430 |
+ |
431 |
+ einfo "Installing headers" |
432 |
+ ebazel build //tensorflow:install_headers |
433 |
+ ebazel shutdown |
434 |
+ insinto /usr/include/${PN}/ |
435 |
+ doins -r bazel-bin/tensorflow/include/* |
436 |
+ |
437 |
+ einfo "Installing libs" |
438 |
+ # Generate $(tc-getPKG_CONFIG) file |
439 |
+ ${PN}/c/generate-pc.sh --prefix="${EPREFIX}"/usr --libdir=$(get_libdir) --version=${MY_PV} || die |
440 |
+ insinto /usr/$(get_libdir)/pkgconfig |
441 |
+ doins ${PN}.pc ${PN}_cc.pc |
442 |
+ |
443 |
+ for l in libtensorflow{,_framework,_cc}.so; do |
444 |
+ dolib.so bazel-bin/tensorflow/${l} |
445 |
+ dolib.so bazel-bin/tensorflow/${l}.$(ver_cut 1) |
446 |
+ dolib.so bazel-bin/tensorflow/${l}.$(ver_cut 1-3) |
447 |
+ done |
448 |
+ |
449 |
+ einstalldocs |
450 |
+} |