1 |
commit: bb46b0f6b4260c8aca367dc153b10a385d9728eb |
2 |
Author: Alexey Chernov <4ernov <AT> gmail <DOT> com> |
3 |
AuthorDate: Mon Feb 10 18:51:53 2020 +0000 |
4 |
Commit: Benda XU <heroxbd <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Feb 19 14:35:57 2020 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/sci.git/commit/?id=bb46b0f6 |
7 |
|
8 |
sci-libs/pytorch: initial commit. |
9 |
|
10 |
This is CPU version only. ROCm and CUDA options will be added later. |
11 |
|
12 |
Reference: https://github.com/aclex/pytorch-ebuild |
13 |
Bug: https://github.com/gentoo/sci/pull/941 |
14 |
Package-Manager: Portage-2.3.88, Repoman-2.3.18 |
15 |
Signed-off-by: Benda Xu <heroxbd <AT> gentoo.org> |
16 |
|
17 |
...-t-build-libtorch-again-for-PyTorch-1.4.0.patch | 30 +++ |
18 |
...path-to-caffe2-build-dir-made-by-libtorch.patch | 46 ++++ |
19 |
...rpath-of-Caffe2-library-for-system-wide-i.patch | 104 ++++++++ |
20 |
...ibrary-directory-according-to-CMake-build.patch | 31 +++ |
21 |
...conversion-ambiguity-in-ternary-operators.patch | 38 +++ |
22 |
sci-libs/pytorch/files/pytorch-1.2.0-setup.patch | 24 ++ |
23 |
sci-libs/pytorch/files/pytorch-1.4.0-eigen.patch | 13 + |
24 |
.../files/pytorch-1.4.0-nccl-nvccflags.patch | 28 +++ |
25 |
.../pytorch/files/pytorch-1.4.0-skip-tests.patch | 28 +++ |
26 |
sci-libs/pytorch/files/pytorch-1.4.0-sleef.patch | 15 ++ |
27 |
sci-libs/pytorch/metadata.xml | 35 +++ |
28 |
sci-libs/pytorch/pytorch-1.4.0_p0.ebuild | 272 +++++++++++++++++++++ |
29 |
12 files changed, 664 insertions(+) |
30 |
|
31 |
diff --git a/sci-libs/pytorch/files/0002-Don-t-build-libtorch-again-for-PyTorch-1.4.0.patch b/sci-libs/pytorch/files/0002-Don-t-build-libtorch-again-for-PyTorch-1.4.0.patch |
32 |
new file mode 100644 |
33 |
index 000000000..de9fe9a0d |
34 |
--- /dev/null |
35 |
+++ b/sci-libs/pytorch/files/0002-Don-t-build-libtorch-again-for-PyTorch-1.4.0.patch |
36 |
@@ -0,0 +1,30 @@ |
37 |
+From e5003b88ad3a504eb04c0ba66c2f439149de2ee3 Mon Sep 17 00:00:00 2001 |
38 |
+From: Alexey Chernov <4ernov@×××××.com> |
39 |
+Date: Tue, 5 Nov 2019 00:58:17 +0300 |
40 |
+Subject: [PATCH 2/7] Don't build `libtorch` again for PyTorch |
41 |
+ |
42 |
+If starting with building of `libtorch` using CMake, |
43 |
+don't build it again for the sake of running `setup.py` |
44 |
+to build Python version (PyTorch). |
45 |
+--- |
46 |
+ setup.py | 7 ------- |
47 |
+ 1 file changed, 7 deletions(-) |
48 |
+ |
49 |
+Index: pytorch-1.4.0_p0/setup.py |
50 |
+=================================================================== |
51 |
+--- pytorch-1.4.0_p0.orig/setup.py |
52 |
++++ pytorch-1.4.0_p0/setup.py |
53 |
+@@ -303,13 +303,6 @@ def build_deps(): |
54 |
+ check_pydep('yaml', 'pyyaml') |
55 |
+ check_pydep('typing', 'typing') |
56 |
+ |
57 |
+- build_caffe2(version=version, |
58 |
+- cmake_python_library=cmake_python_library, |
59 |
+- build_python=True, |
60 |
+- rerun_cmake=RERUN_CMAKE, |
61 |
+- cmake_only=CMAKE_ONLY, |
62 |
+- cmake=cmake) |
63 |
+- |
64 |
+ version_path = os.path.join(cwd, 'torch', 'version.py') |
65 |
+ with open(version_path, 'w') as f: |
66 |
+ f.write("__version__ = '{}'\n".format(version)) |
67 |
|
68 |
diff --git a/sci-libs/pytorch/files/0003-Change-path-to-caffe2-build-dir-made-by-libtorch.patch b/sci-libs/pytorch/files/0003-Change-path-to-caffe2-build-dir-made-by-libtorch.patch |
69 |
new file mode 100644 |
70 |
index 000000000..f71ba17bc |
71 |
--- /dev/null |
72 |
+++ b/sci-libs/pytorch/files/0003-Change-path-to-caffe2-build-dir-made-by-libtorch.patch |
73 |
@@ -0,0 +1,46 @@ |
74 |
+From dbb0bac77986016217cdfe779499a2ccd0e10570 Mon Sep 17 00:00:00 2001 |
75 |
+From: Alexey Chernov <4ernov@×××××.com> |
76 |
+Date: Wed, 6 Nov 2019 00:16:24 +0300 |
77 |
+Subject: [PATCH 3/4] Change path to `caffe2` build dir made by `libtorch` |
78 |
+ |
79 |
+Setup and use properly `caffe2` build dir made while |
80 |
+`libtorch` building with CMake, so that it was used |
81 |
+by the Python installation. |
82 |
+--- |
83 |
+ setup.py | 6 +++--- |
84 |
+ 1 file changed, 3 insertions(+), 3 deletions(-) |
85 |
+ |
86 |
+diff --git a/setup.py b/setup.py |
87 |
+index f4bfdc99cd..60502b6add 100644 |
88 |
+--- a/setup.py |
89 |
++++ b/setup.py |
90 |
+@@ -236,7 +236,7 @@ else: |
91 |
+ cwd = os.path.dirname(os.path.abspath(__file__)) |
92 |
+ lib_path = os.path.join(cwd, "torch", "lib") |
93 |
+ third_party_path = os.path.join(cwd, "third_party") |
94 |
+-caffe2_build_dir = os.path.join(cwd, "build") |
95 |
++caffe2_build_dir = os.environ.get("CMAKE_BUILD_DIR", os.path.join(cwd, "build")) |
96 |
+ # lib/pythonx.x/site-packages |
97 |
+ rel_site_packages = distutils.sysconfig.get_python_lib(prefix='') |
98 |
+ # full absolute path to the dir above |
99 |
+@@ -279,7 +279,7 @@ elif sha != 'Unknown': |
100 |
+ version += '+' + sha[:7] |
101 |
+ report("Building wheel {}-{}".format(package_name, version)) |
102 |
+ |
103 |
+-cmake = CMake() |
104 |
++cmake = CMake(caffe2_build_dir) |
105 |
+ |
106 |
+ # all the work we need to do _before_ setup runs |
107 |
+ def build_deps(): |
108 |
+@@ -445,7 +445,7 @@ class build_ext(setuptools.command.build_ext.build_ext): |
109 |
+ filename = self.get_ext_filename(fullname) |
110 |
+ report("\nCopying extension {}".format(ext.name)) |
111 |
+ |
112 |
+- src = os.path.join("torch", rel_site_packages, filename) |
113 |
++ src = os.path.join(caffe2_build_dir, filename) |
114 |
+ if not os.path.exists(src): |
115 |
+ report("{} does not exist".format(src)) |
116 |
+ del self.extensions[i] |
117 |
+-- |
118 |
+2.23.0 |
119 |
+ |
120 |
|
121 |
diff --git a/sci-libs/pytorch/files/0004-Don-t-fill-rpath-of-Caffe2-library-for-system-wide-i.patch b/sci-libs/pytorch/files/0004-Don-t-fill-rpath-of-Caffe2-library-for-system-wide-i.patch |
122 |
new file mode 100644 |
123 |
index 000000000..c8f57d9e6 |
124 |
--- /dev/null |
125 |
+++ b/sci-libs/pytorch/files/0004-Don-t-fill-rpath-of-Caffe2-library-for-system-wide-i.patch |
126 |
@@ -0,0 +1,104 @@ |
127 |
+From a0ace7295b6895954d2a0f8d6fe311a34a7c4e85 Mon Sep 17 00:00:00 2001 |
128 |
+From: Alexey Chernov <4ernov@×××××.com> |
129 |
+Date: Tue, 12 Nov 2019 02:01:36 +0300 |
130 |
+Subject: [PATCH 4/4] Don't fill rpath of Caffe2 library for system-wide |
131 |
+ install |
132 |
+ |
133 |
+Don't fill in runtime path of Caffe2 library for the case of |
134 |
+building for system-wide installation. |
135 |
+--- |
136 |
+ CMakeLists.txt | 3 +++ |
137 |
+ caffe2/CMakeLists.txt | 18 +++++++++++++++--- |
138 |
+ cmake/Dependencies.cmake | 19 +++++++++++-------- |
139 |
+ 3 files changed, 29 insertions(+), 11 deletions(-) |
140 |
+ |
141 |
+diff --git a/CMakeLists.txt b/CMakeLists.txt |
142 |
+index 20923c0544..45a882ae0e 100644 |
143 |
+--- a/CMakeLists.txt |
144 |
++++ b/CMakeLists.txt |
145 |
+@@ -193,6 +193,9 @@ option(USE_TBB "Use TBB" OFF) |
146 |
+ # Used when building Caffe2 through setup.py |
147 |
+ option(BUILDING_WITH_TORCH_LIBS "Tell cmake if Caffe2 is being built alongside torch libs" ON) |
148 |
+ |
149 |
++# Used when building Caffe2 for further system-wide installation |
150 |
++option(BUILDING_SYSTEM_WIDE "Tell cmake if Caffe2 is being built for system-wide installation" OFF) |
151 |
++ |
152 |
+ # /Z7 override option |
153 |
+ # When generating debug symbols, CMake default to use the flag /Zi. |
154 |
+ # However, it is not compatible with sccache. So we rewrite it off. |
155 |
+diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt |
156 |
+index 1f7d037243..30d5615cdb 100644 |
157 |
+--- a/caffe2/CMakeLists.txt |
158 |
++++ b/caffe2/CMakeLists.txt |
159 |
+@@ -1235,7 +1235,11 @@ if (BUILD_PYTHON) |
160 |
+ if (MSVC AND BUILD_SHARED_LIBS) |
161 |
+ install(FILES $<TARGET_PDB_FILE:caffe2_pybind11_state> DESTINATION "${PYTHON_LIB_REL_PATH}/caffe2/python" OPTIONAL) |
162 |
+ endif() |
163 |
+- set_target_properties(caffe2_pybind11_state PROPERTIES INSTALL_RPATH "${caffe2_pybind11_rpath}") |
164 |
++ if (NOT BUILDING_SYSTEM_WIDE) |
165 |
++ set_target_properties(caffe2_pybind11_state PROPERTIES INSTALL_RPATH "${caffe2_pybind11_rpath}") |
166 |
++else() |
167 |
++ set_target_properties(caffe2_pybind11_state PROPERTIES SKIP_BUILD_RPATH ON) |
168 |
++ endif() |
169 |
+ |
170 |
+ if(USE_CUDA) |
171 |
+ add_library(caffe2_pybind11_state_gpu MODULE ${Caffe2_GPU_PYTHON_SRCS}) |
172 |
+@@ -1261,7 +1265,11 @@ if (BUILD_PYTHON) |
173 |
+ if (MSVC AND BUILD_SHARED_LIBS) |
174 |
+ install(FILES $<TARGET_PDB_FILE:caffe2_pybind11_state_gpu> DESTINATION "${PYTHON_LIB_REL_PATH}/caffe2/python" OPTIONAL) |
175 |
+ endif() |
176 |
+- set_target_properties(caffe2_pybind11_state_gpu PROPERTIES INSTALL_RPATH "${caffe2_pybind11_rpath}") |
177 |
++ if (NOT BUILDING_SYSTEM_WIDE) |
178 |
++ set_target_properties(caffe2_pybind11_state_gpu PROPERTIES INSTALL_RPATH "${caffe2_pybind11_rpath}") |
179 |
++ else() |
180 |
++ set_target_properties(caffe2_pybind11_state_gpu PROPERTIES SKIP_BUILD_RPATH ON) |
181 |
++ endif() |
182 |
+ endif() |
183 |
+ |
184 |
+ if(USE_ROCM) |
185 |
+@@ -1284,7 +1292,11 @@ if (BUILD_PYTHON) |
186 |
+ caffe2_pybind11_state_hip PROPERTIES LIBRARY_OUTPUT_DIRECTORY |
187 |
+ ${CMAKE_BINARY_DIR}/caffe2/python) |
188 |
+ install(TARGETS caffe2_pybind11_state_hip DESTINATION "${PYTHON_LIB_REL_PATH}/caffe2/python") |
189 |
+- set_target_properties(caffe2_pybind11_state_hip PROPERTIES INSTALL_RPATH "${caffe2_pybind11_rpath}") |
190 |
++ if (NOT BUILDING_SYSTEM_WIDE) |
191 |
++ set_target_properties(caffe2_pybind11_state_hip PROPERTIES INSTALL_RPATH "${caffe2_pybind11_rpath}") |
192 |
++ else() |
193 |
++ set_target_properties(caffe2_pybind11_state_hip PROPERTIES SKIP_BUILD_RPATH ON) |
194 |
++ endif() |
195 |
+ endif() |
196 |
+ |
197 |
+ if (MSVC AND CMAKE_GENERATOR MATCHES "Visual Studio") |
198 |
+diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake |
199 |
+index a8e9769536..6ef9d7b0e2 100644 |
200 |
+--- a/cmake/Dependencies.cmake |
201 |
++++ b/cmake/Dependencies.cmake |
202 |
+@@ -6,14 +6,17 @@ if (APPLE) |
203 |
+ else() |
204 |
+ set(_rpath_portable_origin $ORIGIN) |
205 |
+ endif(APPLE) |
206 |
+-# Use separate rpaths during build and install phases |
207 |
+-set(CMAKE_SKIP_BUILD_RPATH FALSE) |
208 |
+-# Don't use the install-rpath during the build phase |
209 |
+-set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) |
210 |
+-set(CMAKE_INSTALL_RPATH "${_rpath_portable_origin}") |
211 |
+-# Automatically add all linked folders that are NOT in the build directory to |
212 |
+-# the rpath (per library?) |
213 |
+-set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
214 |
++ |
215 |
++if (NOT BUILDING_SYSTEM_WIDE) |
216 |
++ # Use separate rpaths during build and install phases |
217 |
++ set(CMAKE_SKIP_BUILD_RPATH FALSE) |
218 |
++ # Don't use the install-rpath during the build phase |
219 |
++ set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE) |
220 |
++ set(CMAKE_INSTALL_RPATH "${_rpath_portable_origin}") |
221 |
++ # Automatically add all linked folders that are NOT in the build directory to |
222 |
++ # the rpath (per library?) |
223 |
++ set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) |
224 |
++endif() |
225 |
+ |
226 |
+ # UBSAN triggers when compiling protobuf, so we need to disable it. |
227 |
+ set(UBSAN_FLAG "-fsanitize=undefined") |
228 |
+-- |
229 |
+2.23.0 |
230 |
+ |
231 |
|
232 |
diff --git a/sci-libs/pytorch/files/0005-Change-library-directory-according-to-CMake-build.patch b/sci-libs/pytorch/files/0005-Change-library-directory-according-to-CMake-build.patch |
233 |
new file mode 100644 |
234 |
index 000000000..324b8f682 |
235 |
--- /dev/null |
236 |
+++ b/sci-libs/pytorch/files/0005-Change-library-directory-according-to-CMake-build.patch |
237 |
@@ -0,0 +1,31 @@ |
238 |
+From 52019a3f395e5fa97b26d424152d91f73b400f8e Mon Sep 17 00:00:00 2001 |
239 |
+From: Alexey Chernov <4ernov@×××××.com> |
240 |
+Date: Wed, 13 Nov 2019 23:44:12 +0300 |
241 |
+Subject: [PATCH 5/5] Change library directory according to CMake build |
242 |
+ |
243 |
+Change `lib_path` in favour of out-of-tree CMake build |
244 |
+directory, so that all the C++ libraries be found. |
245 |
+--- |
246 |
+ setup.py | 5 +++-- |
247 |
+ 1 file changed, 3 insertions(+), 2 deletions(-) |
248 |
+ |
249 |
+diff --git a/setup.py b/setup.py |
250 |
+index 60502b6add..cbced52192 100644 |
251 |
+--- a/setup.py |
252 |
++++ b/setup.py |
253 |
+@@ -234,9 +234,10 @@ else: |
254 |
+ |
255 |
+ # Constant known variables used throughout this file |
256 |
+ cwd = os.path.dirname(os.path.abspath(__file__)) |
257 |
+-lib_path = os.path.join(cwd, "torch", "lib") |
258 |
++cmake_build_dir = os.environ.get("CMAKE_BUILD_DIR", os.path.join(cwd, "build")) |
259 |
++lib_path = os.path.join(cmake_build_dir, "lib") |
260 |
+ third_party_path = os.path.join(cwd, "third_party") |
261 |
+-caffe2_build_dir = os.environ.get("CMAKE_BUILD_DIR", os.path.join(cwd, "build")) |
262 |
++caffe2_build_dir = cmake_build_dir |
263 |
+ # lib/pythonx.x/site-packages |
264 |
+ rel_site_packages = distutils.sysconfig.get_python_lib(prefix='') |
265 |
+ # full absolute path to the dir above |
266 |
+-- |
267 |
+2.23.0 |
268 |
+ |
269 |
|
270 |
diff --git a/sci-libs/pytorch/files/0010-Remove-conversion-ambiguity-in-ternary-operators.patch b/sci-libs/pytorch/files/0010-Remove-conversion-ambiguity-in-ternary-operators.patch |
271 |
new file mode 100644 |
272 |
index 000000000..49835d201 |
273 |
--- /dev/null |
274 |
+++ b/sci-libs/pytorch/files/0010-Remove-conversion-ambiguity-in-ternary-operators.patch |
275 |
@@ -0,0 +1,38 @@ |
276 |
+From 0f3a0d9a948fdd8481a5f7751a255ecd9ed4d37a Mon Sep 17 00:00:00 2001 |
277 |
+From: Alexey Chernov <4ernov@×××××.com> |
278 |
+Date: Mon, 20 Jan 2020 01:21:22 +0300 |
279 |
+Subject: [PATCH 3/3] Remove conversion ambiguity in ternary operators |
280 |
+ |
281 |
+It fails to compile with recent versions of Clang |
282 |
+(namely, version 10 used behind HCC compiler when |
283 |
+being built with ROCm support) with the |
284 |
+`conditional expression is ambiguous` error. |
285 |
+--- |
286 |
+ caffe2/operators/relu_op.cu | 4 ++-- |
287 |
+ 1 file changed, 2 insertions(+), 2 deletions(-) |
288 |
+ |
289 |
+diff --git a/caffe2/operators/relu_op.cu b/caffe2/operators/relu_op.cu |
290 |
+index f6edf7105e..ab49540fc9 100644 |
291 |
+--- a/caffe2/operators/relu_op.cu |
292 |
++++ b/caffe2/operators/relu_op.cu |
293 |
+@@ -51,7 +51,7 @@ __global__ void ReluCUDAKernel<half2>(const int N, const half2* X, half2* Y) { |
294 |
+ #else |
295 |
+ const float2 xx = __half22float2(X[i]); |
296 |
+ Y[i] = |
297 |
+- __floats2half2_rn(xx.x > 0.0f ? xx.x : 0.0f, xx.y > 0.0f ? xx.y : 0.0f); |
298 |
++ __floats2half2_rn(xx.x > 0.0f ? float(xx.x) : 0.0f, xx.y > 0.0f ? float(xx.y) : 0.0f); |
299 |
+ #endif |
300 |
+ } |
301 |
+ } |
302 |
+@@ -101,7 +101,7 @@ __global__ void ReluGradientCUDAKernel<half2>( |
303 |
+ const float2 dy = __half22float2(dY[i]); |
304 |
+ const float2 yy = __half22float2(Y[i]); |
305 |
+ dX[i] = |
306 |
+- __floats2half2_rn(yy.x > 0.0f ? dy.x : 0.0f, yy.y > 0.0f ? dy.y : 0.0f); |
307 |
++ __floats2half2_rn(yy.x > 0.0f ? float(dy.x) : 0.0f, yy.y > 0.0f ? float(dy.y) : 0.0f); |
308 |
+ #endif |
309 |
+ } |
310 |
+ } |
311 |
+-- |
312 |
+2.24.1 |
313 |
+ |
314 |
|
315 |
diff --git a/sci-libs/pytorch/files/pytorch-1.2.0-setup.patch b/sci-libs/pytorch/files/pytorch-1.2.0-setup.patch |
316 |
new file mode 100644 |
317 |
index 000000000..85e796a60 |
318 |
--- /dev/null |
319 |
+++ b/sci-libs/pytorch/files/pytorch-1.2.0-setup.patch |
320 |
@@ -0,0 +1,24 @@ |
321 |
+Index: pytorch-1.4.0_p0/setup.py |
322 |
+=================================================================== |
323 |
+--- pytorch-1.4.0_p0.orig/setup.py |
324 |
++++ pytorch-1.4.0_p0/setup.py |
325 |
+@@ -288,9 +288,7 @@ def build_deps(): |
326 |
+ sys.exit(1) |
327 |
+ |
328 |
+ check_file(os.path.join(third_party_path, "gloo", "CMakeLists.txt")) |
329 |
+- check_file(os.path.join(third_party_path, "pybind11", "CMakeLists.txt")) |
330 |
+ check_file(os.path.join(third_party_path, 'cpuinfo', 'CMakeLists.txt')) |
331 |
+- check_file(os.path.join(third_party_path, 'tbb', 'Makefile')) |
332 |
+ check_file(os.path.join(third_party_path, 'onnx', 'CMakeLists.txt')) |
333 |
+ check_file(os.path.join(third_party_path, 'foxi', 'CMakeLists.txt')) |
334 |
+ check_file(os.path.join(third_party_path, 'QNNPACK', 'CMakeLists.txt')) |
335 |
+@@ -341,9 +339,6 @@ def build_deps(): |
336 |
+ if not same: |
337 |
+ shutil.copyfile(orig_file, sym_file) |
338 |
+ |
339 |
+- dir_util.copy_tree('third_party/pybind11/include/pybind11/', |
340 |
+- 'torch/include/pybind11') |
341 |
+- |
342 |
+ ################################################################################ |
343 |
+ # Building dependent libraries |
344 |
+ ################################################################################ |
345 |
|
346 |
diff --git a/sci-libs/pytorch/files/pytorch-1.4.0-eigen.patch b/sci-libs/pytorch/files/pytorch-1.4.0-eigen.patch |
347 |
new file mode 100644 |
348 |
index 000000000..54ea3a5e0 |
349 |
--- /dev/null |
350 |
+++ b/sci-libs/pytorch/files/pytorch-1.4.0-eigen.patch |
351 |
@@ -0,0 +1,13 @@ |
352 |
+Index: pytorch-1.4.0/CMakeLists.txt |
353 |
+=================================================================== |
354 |
+--- pytorch-1.4.0.orig/CMakeLists.txt |
355 |
++++ pytorch-1.4.0/CMakeLists.txt |
356 |
+@@ -173,7 +173,7 @@ option(USE_REDIS "Use Redis" OFF) |
357 |
+ option(USE_ROCKSDB "Use RocksDB" OFF) |
358 |
+ option(USE_SNPE "Use Qualcomm's SNPE library" OFF) |
359 |
+ option(USE_SYSTEM_EIGEN_INSTALL |
360 |
+- "Use system Eigen instead of the one under third_party" OFF) |
361 |
++ "Use system Eigen instead of the one under third_party" ON) |
362 |
+ option(USE_TENSORRT "Using Nvidia TensorRT library" OFF) |
363 |
+ option(USE_ZMQ "Use ZMQ" OFF) |
364 |
+ option(USE_ZSTD "Use ZSTD" OFF) |
365 |
|
366 |
diff --git a/sci-libs/pytorch/files/pytorch-1.4.0-nccl-nvccflags.patch b/sci-libs/pytorch/files/pytorch-1.4.0-nccl-nvccflags.patch |
367 |
new file mode 100644 |
368 |
index 000000000..165e79dd4 |
369 |
--- /dev/null |
370 |
+++ b/sci-libs/pytorch/files/pytorch-1.4.0-nccl-nvccflags.patch |
371 |
@@ -0,0 +1,28 @@ |
372 |
+Index: nccl-7c72dee660e4d055b81721dd6b03e4e1c0a983cf/makefiles/common.mk |
373 |
+=================================================================== |
374 |
+--- nccl-7c72dee660e4d055b81721dd6b03e4e1c0a983cf.orig/makefiles/common.mk |
375 |
++++ nccl-7c72dee660e4d055b81721dd6b03e4e1c0a983cf/makefiles/common.mk |
376 |
+@@ -46,7 +46,7 @@ endif |
377 |
+ CXXFLAGS := -DCUDA_MAJOR=$(CUDA_MAJOR) -DCUDA_MINOR=$(CUDA_MINOR) -fPIC -fvisibility=hidden |
378 |
+ CXXFLAGS += -Wall -Wno-unused-function -Wno-sign-compare -std=c++11 -Wvla |
379 |
+ CXXFLAGS += -I $(CUDA_INC) |
380 |
+-NVCUFLAGS := -ccbin $(CXX) $(NVCC_GENCODE) -lineinfo -std=c++11 -Xptxas -maxrregcount=96 -Xfatbin -compress-all |
381 |
++NVCUFLAGS := $(NVCCFLAGS) $(NVCC_GENCODE) -lineinfo -std=c++11 -Xptxas -maxrregcount=96 -Xfatbin -compress-all |
382 |
+ # Use addprefix so that we can specify more than one path |
383 |
+ NVLDFLAGS := -L${CUDA_LIB} -lcudart -lrt |
384 |
+ |
385 |
+@@ -60,14 +60,6 @@ NVLDFLAGS += ${GCOV_FLAGS:%=-Xcompiler |
386 |
+ # $(warning GCOV_FLAGS=${GCOV_FLAGS}) |
387 |
+ ########## GCOV ########## |
388 |
+ |
389 |
+-ifeq ($(DEBUG), 0) |
390 |
+-NVCUFLAGS += -O3 |
391 |
+-CXXFLAGS += -O3 -g |
392 |
+-else |
393 |
+-NVCUFLAGS += -O0 -G -g |
394 |
+-CXXFLAGS += -O0 -g -ggdb3 |
395 |
+-endif |
396 |
+- |
397 |
+ ifneq ($(VERBOSE), 0) |
398 |
+ NVCUFLAGS += -Xptxas -v -Xcompiler -Wall,-Wextra,-Wno-unused-parameter |
399 |
+ CXXFLAGS += -Wall -Wextra |
400 |
|
401 |
diff --git a/sci-libs/pytorch/files/pytorch-1.4.0-skip-tests.patch b/sci-libs/pytorch/files/pytorch-1.4.0-skip-tests.patch |
402 |
new file mode 100644 |
403 |
index 000000000..3682469d7 |
404 |
--- /dev/null |
405 |
+++ b/sci-libs/pytorch/files/pytorch-1.4.0-skip-tests.patch |
406 |
@@ -0,0 +1,28 @@ |
407 |
+Disable expected test failures. |
408 |
+ |
409 |
+TCPStoreTest is too slow to run. |
410 |
+ |
411 |
+Reference: https://github.com/pytorch/pytorch/issues/13746 |
412 |
+Reference: https://github.com/pytorch/pytorch/issues/21873 |
413 |
+ |
414 |
+Index: pytorch-1.4.0_p0/torch/lib/c10d/test/CMakeLists.txt |
415 |
+=================================================================== |
416 |
+--- pytorch-1.4.0_p0.orig/torch/lib/c10d/test/CMakeLists.txt |
417 |
++++ pytorch-1.4.0_p0/torch/lib/c10d/test/CMakeLists.txt |
418 |
+@@ -14,7 +14,6 @@ function(c10d_add_test test_src) |
419 |
+ endfunction() |
420 |
+ |
421 |
+ c10d_add_test(FileStoreTest.cpp c10d) |
422 |
+-c10d_add_test(TCPStoreTest.cpp c10d) |
423 |
+ |
424 |
+ if(USE_CUDA) |
425 |
+ if(USE_C10D_GLOO) |
426 |
+Index: pytorch-1.4.0_p0/caffe2/share/contrib/depthwise/CMakeLists.txt |
427 |
+=================================================================== |
428 |
+--- pytorch-1.4.0_p0.orig/caffe2/share/contrib/depthwise/CMakeLists.txt |
429 |
++++ pytorch-1.4.0_p0/caffe2/share/contrib/depthwise/CMakeLists.txt |
430 |
+@@ -6,4 +6,3 @@ set(Caffe2_CONTRIB_DEPTHWISE3x3_TEST_CPU |
431 |
+ ) |
432 |
+ |
433 |
+ set(Caffe2_CPU_SRCS ${Caffe2_CPU_SRCS} ${Caffe2_CONTRIB_DEPTHWISE3x3_CPU_SRC} PARENT_SCOPE) |
434 |
+-set(Caffe2_CPU_TEST_SRCS ${Caffe2_CPU_TEST_SRCS} ${Caffe2_CONTRIB_DEPTHWISE3x3_TEST_CPU_SRC} PARENT_SCOPE) |
435 |
|
436 |
diff --git a/sci-libs/pytorch/files/pytorch-1.4.0-sleef.patch b/sci-libs/pytorch/files/pytorch-1.4.0-sleef.patch |
437 |
new file mode 100644 |
438 |
index 000000000..222a0f73e |
439 |
--- /dev/null |
440 |
+++ b/sci-libs/pytorch/files/pytorch-1.4.0-sleef.patch |
441 |
@@ -0,0 +1,15 @@ |
442 |
+Give the location of sleef.h. |
443 |
+ |
444 |
+Reference: https://github.com/pytorch/pytorch/issues/26555 |
445 |
+Index: pytorch-1.4.0/caffe2/CMakeLists.txt |
446 |
+=================================================================== |
447 |
+--- pytorch-1.4.0.orig/caffe2/CMakeLists.txt |
448 |
++++ pytorch-1.4.0/caffe2/CMakeLists.txt |
449 |
+@@ -1062,6 +1062,7 @@ if (BUILD_TEST) |
450 |
+ add_executable(${test_name} "${test_src}") |
451 |
+ target_link_libraries(${test_name} ${Caffe2_MAIN_LIBS} gtest_main) |
452 |
+ target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>) |
453 |
++ target_include_directories(${test_name} PRIVATE $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>) |
454 |
+ target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE}) |
455 |
+ add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>) |
456 |
+ if (INSTALL_TEST) |
457 |
|
458 |
diff --git a/sci-libs/pytorch/metadata.xml b/sci-libs/pytorch/metadata.xml |
459 |
new file mode 100644 |
460 |
index 000000000..78e46cc35 |
461 |
--- /dev/null |
462 |
+++ b/sci-libs/pytorch/metadata.xml |
463 |
@@ -0,0 +1,35 @@ |
464 |
+<?xml version="1.0" encoding="UTF-8"?> |
465 |
+<!DOCTYPE pkgmetadata SYSTEM "http://www.gentoo.org/dtd/metadata.dtd"> |
466 |
+<pkgmetadata> |
467 |
+ <maintainer type="person"> |
468 |
+ <email>4ernov@×××××.com</email> |
469 |
+ <name>Alexey Chernov</name> |
470 |
+ </maintainer> |
471 |
+ <use> |
472 |
+ <flag name="asan">Build with address sanitizer (ASAN)</flag> |
473 |
+ <flag name="atlas">Use ATLAS as BLAS implementation</flag> |
474 |
+ <flag name="cuda">Enable support for nVidia CUDA</flag> |
475 |
+ <flag name="eigen">Use Eigen as BLAS implementation</flag> |
476 |
+ <flag name="fbgemm">Enable FBGEMM (Facebook GEneral Matrix Multiplication) support</flag> |
477 |
+ <flag name="gflags">Build with gflags</flag> |
478 |
+ <flag name="glog">Build with glog support</flag> |
479 |
+ <flag name="gloo">Build gloo distributed communication backend support</flag> |
480 |
+ <flag name="leveldb">Enable support for LevelDB</flag> |
481 |
+ <flag name="lmdb">Enable support for LMDB</flag> |
482 |
+ <flag name="mkl">Use Intel MKL as BLAS implementation</flag> |
483 |
+ <flag name="mkldnn">Build with Intel MKL-DNN support</flag> |
484 |
+ <flag name="namedtensor">Enable support for named tensors</flag> |
485 |
+ <flag name="nnpack">Enable NNPACK support</flag> |
486 |
+ <flag name="numa">Enable support for NUMA</flag> |
487 |
+ <flag name="numpy">Enable NumPy support</flag> |
488 |
+ <flag name="observers">Build observers</flag> |
489 |
+ <flag name="openblas">Use OpenBLAS as BLAS implementation</flag> |
490 |
+ <flag name="opencv">Enable support for OpenCV</flag> |
491 |
+ <flag name="opencl">Enable support for OpenCL</flag> |
492 |
+ <flag name="qnnpack">Enable QNNPACK support</flag> |
493 |
+ <flag name="redis">Enable support for Redis</flag> |
494 |
+ <flag name="tbb">Build with Intel TBB enabled</flag> |
495 |
+ <flag name="tools">Build binary tools</flag> |
496 |
+ <flag name="zeromq">Enable support for ZeroMQ</flag> |
497 |
+ </use> |
498 |
+</pkgmetadata> |
499 |
|
500 |
diff --git a/sci-libs/pytorch/pytorch-1.4.0_p0.ebuild b/sci-libs/pytorch/pytorch-1.4.0_p0.ebuild |
501 |
new file mode 100644 |
502 |
index 000000000..06ee528f2 |
503 |
--- /dev/null |
504 |
+++ b/sci-libs/pytorch/pytorch-1.4.0_p0.ebuild |
505 |
@@ -0,0 +1,272 @@ |
506 |
+# Copyright 1999-2020 Gentoo Authors |
507 |
+# Distributed under the terms of the GNU General Public License v2 |
508 |
+ |
509 |
+EAPI=7 |
510 |
+ |
511 |
+PYTHON_COMPAT=( python3_6 ) |
512 |
+ |
513 |
+inherit distutils-r1 cmake-utils cuda |
514 |
+ |
515 |
+MPV=${PV/_p/a} |
516 |
+ |
517 |
+DESCRIPTION="Tensors and Dynamic neural networks in Python with strong GPU acceleration" |
518 |
+HOMEPAGE="https://pytorch.org/" |
519 |
+SRC_URI="https://github.com/pytorch/${PN}/archive/v${MPV}.tar.gz -> ${P}.tar.gz |
520 |
+https://github.com/facebookincubator/gloo/archive/ca528e32.tar.gz -> gloo-ca528e32.tar.gz |
521 |
+https://github.com/google/benchmark/archive/505be96a.tar.gz -> benchmark-505be96a.tar.gz |
522 |
+https://github.com/google/gemmlowp/archive/3fb5c176.tar.gz -> gemmlowp-3fb5c176.tar.gz |
523 |
+https://github.com/google/googletest/archive/2fe3bd99.tar.gz -> googletest-2fe3bd99.tar.gz |
524 |
+https://github.com/houseroad/foxi/archive/8f74bc4d.tar.gz -> foxi-8f74bc4d.tar.gz |
525 |
+https://github.com/intel/ideep/archive/78eafa5d.tar.gz -> ideep-78eafa5d.tar.gz |
526 |
+https://github.com/Maratyszcza/FP16/archive/febbb1c1.tar.gz -> FP16-febbb1c1.tar.gz |
527 |
+https://github.com/Maratyszcza/FXdiv/archive/b742d114.tar.gz -> FXdiv-b742d114.tar.gz |
528 |
+https://github.com/Maratyszcza/NNPACK/archive/c039579a.tar.gz -> NNPACK-c039579a.tar.gz |
529 |
+https://github.com/Maratyszcza/PeachPy/archive/07d8fde8.tar.gz -> PeachPy-07d8fde8.tar.gz |
530 |
+https://github.com/Maratyszcza/psimd/archive/90a938f3.tar.gz -> psimd-90a938f3.tar.gz |
531 |
+https://github.com/Maratyszcza/pthreadpool/archive/13da0b4c.tar.gz -> pthreadpool-13da0b4c.tar.gz |
532 |
+cuda? ( https://github.com/NVIDIA/nccl/archive/7c72dee6.tar.gz -> nccl-7c72dee6.tar.gz ) |
533 |
+https://github.com/NVlabs/cub/archive/285aeeba.tar.gz -> cub-285aeeba.tar.gz |
534 |
+https://github.com/onnx/onnx/archive/2891e145.tar.gz -> onnx-2891e145.tar.gz |
535 |
+https://github.com/onnx/onnx-tensorrt/archive/cb3d8066.tar.gz -> onnx-tensorrt-cb3d8066.tar.gz |
536 |
+https://github.com/pytorch/cpuinfo/archive/89fe1695.tar.gz -> cpuinfo-89fe1695.tar.gz |
537 |
+https://github.com/pytorch/fbgemm/archive/82d259da.tar.gz -> fbgemm-82d259da.tar.gz |
538 |
+https://github.com/pytorch/QNNPACK/archive/7d2a4e99.tar.gz -> QNNPACK-7d2a4e99.tar.gz |
539 |
+https://github.com/shibatch/sleef/archive/7f523de6.tar.gz -> sleef-7f523de6.tar.gz |
540 |
+https://github.com/asmjit/asmjit/archive/17556b2d.tar.gz -> asmjit-17556b2d.tar.gz |
541 |
+ " |
542 |
+ |
543 |
+LICENSE="BSD" |
544 |
+SLOT="0" |
545 |
+KEYWORDS="~amd64" |
546 |
+ |
547 |
+IUSE="asan atlas cuda doc eigen +fbgemm ffmpeg gflags glog +gloo leveldb lmdb mkl mkldnn mpi namedtensor +nnpack numa +numpy +observers +openblas opencl opencv +openmp +python +qnnpack redis static tbb test tools zeromq" |
548 |
+ |
549 |
+REQUIRED_USE=" |
550 |
+ python? ( ${PYTHON_REQUIRED_USE} ) |
551 |
+ numpy? ( python ) |
552 |
+ ^^ ( atlas eigen mkl openblas ) |
553 |
+" |
554 |
+ |
555 |
+DEPEND=" |
556 |
+ dev-libs/protobuf |
557 |
+ dev-python/pyyaml[${PYTHON_USEDEP}] |
558 |
+ virtual/python-typing[${PYTHON_USEDEP}] |
559 |
+ atlas? ( sci-libs/atlas ) |
560 |
+ cuda? ( dev-util/nvidia-cuda-toolkit:0= ) |
561 |
+ doc? ( dev-python/pytorch-sphinx-theme[${PYTHON_USEDEP}] ) |
562 |
+ ffmpeg? ( virtual/ffmpeg ) |
563 |
+ gflags? ( dev-cpp/gflags ) |
564 |
+ glog? ( dev-cpp/glog ) |
565 |
+ leveldb? ( dev-libs/leveldb ) |
566 |
+ lmdb? ( dev-db/lmdb ) |
567 |
+ mkl? ( sci-libs/mkl ) |
568 |
+ mpi? ( virtual/mpi ) |
569 |
+ numpy? ( dev-python/numpy[${PYTHON_USEDEP}] ) |
570 |
+ openblas? ( sci-libs/openblas ) |
571 |
+ opencl? ( dev-libs/clhpp virtual/opencl ) |
572 |
+ opencv? ( media-libs/opencv ) |
573 |
+ python? ( ${PYTHON_DEPS} |
574 |
+ dev-python/pybind11[${PYTHON_USEDEP}] |
575 |
+ ) |
576 |
+ redis? ( dev-db/redis ) |
577 |
+ zeromq? ( net-libs/zeromq ) |
578 |
+ eigen? ( dev-cpp/eigen |
579 |
+ cuda? ( dev-cpp/eigen[cuda] ) ) |
580 |
+" |
581 |
+RDEPEND="${DEPEND}" |
582 |
+BDEPEND=" |
583 |
+ doc? ( app-doc/doxygen ) |
584 |
+" |
585 |
+ |
586 |
+DEPEND=" |
587 |
+ test? ( dev-python/pytest[${PYTHON_USEDEP}] ) |
588 |
+ dev-python/setuptools[${PYTHON_USEDEP}] |
589 |
+ dev-cpp/tbb |
590 |
+ app-arch/zstd |
591 |
+ dev-python/protobuf-python[${PYTHON_USEDEP}] |
592 |
+ dev-python/pybind11[${PYTHON_USEDEP}] |
593 |
+ sys-fabric/libibverbs |
594 |
+ sys-process/numactl |
595 |
+" |
596 |
+ |
597 |
+PATCHES=( |
598 |
+ "${FILESDIR}"/${PN}-1.2.0-setup.patch |
599 |
+ "${FILESDIR}"/${PN}-1.4.0-eigen.patch |
600 |
+ "${FILESDIR}"/${PN}-1.4.0-sleef.patch |
601 |
+ "${FILESDIR}"/${PN}-1.4.0-skip-tests.patch |
602 |
+ "${FILESDIR}"/0002-Don-t-build-libtorch-again-for-PyTorch-1.4.0.patch |
603 |
+ "${FILESDIR}"/0003-Change-path-to-caffe2-build-dir-made-by-libtorch.patch |
604 |
+ "${FILESDIR}"/0005-Change-library-directory-according-to-CMake-build.patch |
605 |
+) |
606 |
+ |
607 |
+src_unpack() { |
608 |
+ default |
609 |
+ |
610 |
+ mv -v ${PN}-${MPV} ${P} || die |
611 |
+} |
612 |
+ |
613 |
+src_prepare() { |
614 |
+ cmake-utils_src_prepare |
615 |
+ |
616 |
+ mv -v third_party/miniz-* ../ || die |
617 |
+ rm -r third_party || die |
618 |
+ ln -s .. third_party || die |
619 |
+ cd .. || die |
620 |
+ for d in *; do |
621 |
+ case ${d} in |
622 |
+ ${PN}* | miniz-*) continue ;; |
623 |
+ PeachPy-*) mv -v ${d} python-peachpy || die ;; |
624 |
+ *) mv -v ${d} ${d%-*} || die ;; |
625 |
+ esac |
626 |
+ done |
627 |
+ |
628 |
+ mv -v FBGEMM fbgemm || die |
629 |
+ cd fbgemm || die |
630 |
+ rm -r third_party || die |
631 |
+ ln -s .. third_party || die |
632 |
+ |
633 |
+ cd ../onnx || die |
634 |
+ rm -r third_party || die |
635 |
+ ln -s .. third_party || die |
636 |
+ |
637 |
+ if use cuda; then |
638 |
+ cd ../nccl || die |
639 |
+ eapply "${FILESDIR}"/${PN}-1.4.0-nccl-nvccflags.patch |
640 |
+ ln -s . nccl || die |
641 |
+ |
642 |
+ cuda_src_prepare |
643 |
+ export CUDAHOSTCXX=$(cuda_gccdir)/g++ |
644 |
+ fi |
645 |
+} |
646 |
+ |
647 |
+src_configure() { |
648 |
+ local blas="Eigen" |
649 |
+ |
650 |
+ if use atlas; then |
651 |
+ blas="ATLAS" |
652 |
+ elif use mkl; then |
653 |
+ blas="MKL" |
654 |
+ elif use openblas; then |
655 |
+ blas="OpenBLAS" |
656 |
+ fi |
657 |
+ |
658 |
+ local mycmakeargs=( |
659 |
+ -DTORCH_BUILD_VERSION=${PV} |
660 |
+ -DTORCH_INSTALL_LIB_DIR=$(get_libdir) |
661 |
+ -DBUILD_BINARY=$(usex tools ON OFF) |
662 |
+ -DBUILD_CUSTOM_PROTOBUF=OFF |
663 |
+ -DBUILD_DOCS=$(usex doc ON OFF) |
664 |
+ -DBUILD_PYTHON=$(usex python ON OFF) |
665 |
+ -DBUILD_SHARED_LIBS=$(usex static OFF ON) |
666 |
+ -DBUILD_TEST=$(usex test ON OFF) |
667 |
+ -DUSE_ASAN=$(usex asan ON OFF) |
668 |
+ -DUSE_CUDA=$(usex cuda ON OFF) |
669 |
+ -DUSE_NCCL=$(usex cuda ON OFF) |
670 |
+ -DUSE_ROCM=OFF |
671 |
+ -DUSE_FBGEMM=$(usex fbgemm ON OFF) |
672 |
+ -DUSE_FFMPEG=$(usex ffmpeg ON OFF) |
673 |
+ -DUSE_GFLAGS=$(usex gflags ON OFF) |
674 |
+ -DUSE_GLOG=$(usex glog ON OFF) |
675 |
+ -DUSE_LEVELDB=$(usex leveldb ON OFF) |
676 |
+ -DUSE_LITE_PROTO=OFF |
677 |
+ -DUSE_LMDB=$(usex lmdb ON OFF) |
678 |
+ -DCAFFE2_USE_MKL=$(usex mkl ON OFF) |
679 |
+ -DUSE_MKLDNN=$(usex mkldnn ON OFF) |
680 |
+ -DUSE_MKLDNN_CBLAS=OFF |
681 |
+ -DUSE_NCCL=OFF |
682 |
+ -DUSE_NNPACK=$(usex nnpack ON OFF) |
683 |
+ -DUSE_NUMPY=$(usex numpy ON OFF) |
684 |
+ -DUSE_NUMA=$(usex numa ON OFF) |
685 |
+ -DUSE_OBSERVERS=$(usex observers ON OFF) |
686 |
+ -DUSE_OPENCL=$(usex opencl ON OFF) |
687 |
+ -DUSE_OPENCV=$(usex opencv ON OFF) |
688 |
+ -DUSE_OPENMP=$(usex openmp ON OFF) |
689 |
+ -DUSE_TBB=OFF |
690 |
+ -DUSE_PROF=OFF |
691 |
+ -DUSE_QNNPACK=$(usex qnnpack ON OFF) |
692 |
+ -DUSE_REDIS=$(usex redis ON OFF) |
693 |
+ -DUSE_ROCKSDB=OFF |
694 |
+ -DUSE_ZMQ=$(usex zeromq ON OFF) |
695 |
+ -DUSE_MPI=$(usex mpi ON OFF) |
696 |
+ -DUSE_GLOO=$(usex gloo ON OFF) |
697 |
+ -DBUILD_NAMEDTENSOR=$(usex namedtensor ON OFF) |
698 |
+ -DBLAS=${blas} |
699 |
+ -DBUILDING_SYSTEM_WIDE=ON # to remove insecure DT_RUNPATH header |
700 |
+ ) |
701 |
+ |
702 |
+ cmake-utils_src_configure |
703 |
+ |
704 |
+ if use python; then |
705 |
+ CMAKE_BUILD_DIR=${BUILD_DIR} distutils-r1_src_configure |
706 |
+ fi |
707 |
+} |
708 |
+ |
709 |
+src_compile() { |
710 |
+ cmake-utils_src_compile |
711 |
+ |
712 |
+ if use python; then |
713 |
+ CMAKE_BUILD_DIR=${BUILD_DIR} distutils-r1_src_compile |
714 |
+ fi |
715 |
+} |
716 |
+ |
717 |
+src_install() { |
718 |
+ cmake-utils_src_install |
719 |
+ |
720 |
+ local multilib_failing_files=( |
721 |
+ libc10.so |
722 |
+ libtbb.so |
723 |
+ libcaffe2_observers.so |
724 |
+ libshm.so |
725 |
+ libcaffe2_detectron_ops.so |
726 |
+ ) |
727 |
+ |
728 |
+ local LIB=$(get_libdir) |
729 |
+ if [[ ${LIB} != lib ]]; then |
730 |
+ for file in ${multilib_failing_files[@]}; do |
731 |
+ mv -fv "${ED}/usr/lib/$file" "${ED}/usr/${LIB}" |
732 |
+ done |
733 |
+ fi |
734 |
+ |
735 |
+ rm -rfv "${ED}/torch" |
736 |
+ rm -rfv "${ED}/var" |
737 |
+ rm -rfv "${ED}/usr/lib" |
738 |
+ |
739 |
+ rm -fv "${ED}/usr/include/*.{h,hpp}" |
740 |
+ rm -rfv "${ED}/usr/include/asmjit" |
741 |
+ rm -rfv "${ED}/usr/include/c10d" |
742 |
+ rm -rfv "${ED}/usr/include/fbgemm" |
743 |
+ rm -rfv "${ED}/usr/include/fp16" |
744 |
+ rm -rfv "${ED}/usr/include/gloo" |
745 |
+ rm -rfv "${ED}/usr/include/include" |
746 |
+ rm -rfv "${ED}/usr/include/var" |
747 |
+ |
748 |
+ cp -rv "${WORKDIR}/${P}/third_party/pybind11/include/pybind11" "${ED}/usr/include/" |
749 |
+ |
750 |
+ rm -fv "${ED}/usr/lib64/libtbb.so" |
751 |
+ rm -rfv "${ED}/usr/lib64/cmake" |
752 |
+ |
753 |
+ rm -rfv "${ED}/usr/share/doc/mkldnn" |
754 |
+ |
755 |
+ if use python; then |
756 |
+ install_shm_manager() { |
757 |
+ TORCH_BIN_DIR="${ED}/usr/lib64/${EPYTHON}/site-packages/torch/bin" |
758 |
+ |
759 |
+ mkdir -pv ${TORCH_BIN_DIR} |
760 |
+ cp -v "${ED}/usr/bin/torch_shm_manager" "${TORCH_BIN_DIR}" |
761 |
+ } |
762 |
+ |
763 |
+ python_foreach_impl install_shm_manager |
764 |
+ |
765 |
+ scanelf -r --fix "${BUILD_DIR}/caffe2/python" |
766 |
+ CMAKE_BUILD_DIR=${BUILD_DIR} distutils-r1_src_install |
767 |
+ |
768 |
+ python_foreach_impl python_optimize |
769 |
+ fi |
770 |
+ |
771 |
+ find "${ED}/usr/lib64" -name "*.a" -exec rm -fv {} \; |
772 |
+ |
773 |
+ use test && rm -rfv "${ED}/usr/test" "${ED}"/usr/bin/test_{api,jit} |
774 |
+ |
775 |
+ # Remove the empty directories by CMake Python: |
776 |
+ find "${ED}" -type d -empty -delete || die |
777 |
+} |