blob: d90d6dda4602e9234a8227a1bcfb18f0d05d9ab9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
PORTNAME= pytorch
DISTVERSIONPREFIX= v
DISTVERSION= 2.1.2
CATEGORIES= misc # machine-learning
MASTER_SITES= https://github.com/pytorch/pytorch/releases/download/v${DISTVERSION}/
DIST_SUBDIR= ${PORTNAME}
MAINTAINER= yuri@FreeBSD.org
COMMENT= Tensors and dynamic neural networks in Python (C++ library)
WWW= https://pytorch.org/
LICENSE= BSD3CLAUSE
LICENSE_FILE= ${WRKSRC}/LICENSE
BROKEN_i386= compilation fails: error: use of undeclared identifier 'AVX2'
BUILD_DEPENDS= gmake:devel/gmake \
${LOCALBASE}/include/fxdiv.h:devel/fxdiv
LIB_DEPENDS= libabsl_base.so:devel/abseil \
libblis.so:math/blis \
libopenblas.so:math/openblas \
libmpi.so:net/openmpi \
libonnx.so:misc/onnx \
libpthreadpool.so:devel/pthreadpool \
libprotobuf.so:devel/protobuf \
libsleef.so:math/sleef
USES= compiler:c++17-lang cmake localbase:ldflags python # requires python even with PYTHON=off
CMAKE_OFF= BUILD_CUSTOM_PROTOBUF USE_CUDA USE_ROCM USE_NNPACK USE_QNNPACK USE_PYTORCH_QNNPACK \
USE_FBGEMM # workaround recommended by the upstream here: https://github.com/pytorch/pytorch/issues/28337
CMAKE_ON= USE_SYSTEM_PYBIND11 \
USE_SYSTEM_SLEEF \
USE_SYSTEM_ONNX # see other USE_SYSTEM_xx in CMakeLists.txt
CMAKE_ON+= ONNX_USE_LITE_PROTO # workaround for the protobuf-related failure described here: https://github.com/onnx/optimizer/issues/38
CMAKE_ARGS= -DPSIMD_SOURCE_DIR=${WRKSRC}/third_party/psimd \
-DPYTHON_EXECUTABLE=${PYTHON_CMD}
MAKE_ENV= USE_NINJA=no # ninja breaks for some reason
LDFLAGS+= -lexecinfo
BINARY_ALIAS= make=${GMAKE} git=true
OPTIONS_DEFINE= PYTHON # PYTHON only provides python support for the py-PyTorch port - it's not a python binding
OPTIONS_DEFAULT= PYTHON
OPTIONS_SUB= yes
PYTHON_CMAKE_BOOL= BUILD_PYTHON
PYTHON_PY_DEPENDS= ${PYNUMPY} \
${PYTHON_PKGNAMEPREFIX}typing-extensions>0:devel/py-typing-extensions@${PY_FLAVOR} \
${PYTHON_PKGNAMEPREFIX}yaml>0:devel/py-yaml@${PY_FLAVOR}
PYTHON_BUILD_DEPENDS= ${PYTHON_PY_DEPENDS} \
pybind11>0:devel/pybind11
PYTHON_RUN_DEPENDS= ${PYTHON_PY_DEPENDS}
.include <bsd.port.pre.mk>
.if ${ARCH} == "amd64"
PLIST_SUB+= AMD64=""
.else
PLIST_SUB+= AMD64="@comment "
.endif
post-patch:
# replace malloc.h -> stdlib.h in many places
@cd ${WRKSRC} && for f in $$(${GREP} -rl "include <malloc\.h>" * | ${GREP} -E "\.(c|cpp|h|hpp)$$"); do \
${REINPLACE_CMD} -i'' -E "s|include <malloc\.h>|include <stdlib.h>|" $$f; \
done
post-install:
# functorch.so is installed back into the source directory, see https://github.com/pytorch/pytorch/issues/91524
@${RM} $$(${FIND} ${STAGEDIR} -name functorch.so)
# https://github.com/pytorch/pytorch/issues/24417
@${FIND} ${STAGEDIR} -type d -empty -delete
.include <bsd.port.post.mk>
|