diff --git a/misc/py-pytorch/Makefile b/misc/py-pytorch/Makefile index cdf87794c265..6f43ace1e6ca 100644 --- a/misc/py-pytorch/Makefile +++ b/misc/py-pytorch/Makefile @@ -1,69 +1,70 @@ PORTNAME= pytorch DISTVERSIONPREFIX= v DISTVERSION= 2.1.0 +PORTREVISION= 1 CATEGORIES= misc # machine-learning MASTER_SITES= https://github.com/pytorch/pytorch/releases/download/v${DISTVERSION}/ PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX} DIST_SUBDIR= ${PORTNAME} MAINTAINER= yuri@FreeBSD.org COMMENT= PyTorch: Tensors and dynamic neural networks in Python WWW= https://pytorch.org/ LICENSE= BSD3CLAUSE LICENSE_FILE= ${WRKSRC}/LICENSE BROKEN_aarch64= build fails: CMake Error at third_party/QNNPACK/CMakeLists.txt:47 (MESSAGE): Unrecognized CMAKE_SYSTEM_NAME = FreeBSD BROKEN_i386= build fails: DispatchStub.cpp:162:29: [0m[0;1;31merror: [0m[1muse of undeclared identifier 'AVX2'[0m BUILD_DEPENDS= cmake:devel/cmake-core \ gmake:devel/gmake \ pybind11>0:devel/pybind11 \ ${PYNUMPY} \ ${LOCALBASE}/include/fxdiv.h:devel/fxdiv \ ${PYTHON_PKGNAMEPREFIX}typing-extensions>0:devel/py-typing-extensions@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}yaml>0:devel/py-yaml@${PY_FLAVOR} LIB_DEPENDS= libopenblas.so:math/openblas \ libmpi.so:net/openmpi \ libonnx.so:misc/onnx \ libpthreadpool.so:devel/pthreadpool \ libprotobuf.so:devel/protobuf \ libsleef.so:math/sleef RUN_DEPENDS= ${PYTHON_PKGNAMEPREFIX}filelock>0:sysutils/py-filelock@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}Jinja2>=0:devel/py-Jinja2@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}networkx>0:math/py-networkx@${PY_FLAVOR} \ ${PYNUMPY} \ ${PYTHON_PKGNAMEPREFIX}sympy>0:math/py-sympy@${PY_FLAVOR} \ ${PYTHON_PKGNAMEPREFIX}typing-extensions>0:devel/py-typing-extensions@${PY_FLAVOR} RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}dill>0:devel/py-dill@${PY_FLAVOR} # optional dependency USES= compiler:c++17-lang localbase:ldflags python USE_PYTHON= distutils autoplist MAKE_ENV= USE_NINJA=no # ninja breaks for some reason MAKE_ENV+= BUILD_TEST=0 # ninja breaks for some reason MAKE_ENV+= USE_MKLDNN=0 # disable MKLDNN that doesn't exist, see https://github.com/pytorch/pytorch/issues/100957 MAKE_ENV+= USE_CUDNN=0 LDFLAGS+= -lexecinfo BINARY_ALIAS= make=${GMAKE} POST_PLIST= fix-plist .include .if ${OPSYS} == FreeBSD && ( ${OSVERSION} >= 1400091 || ( ${OSVERSION} >= 1302507 && ${OSVERSION} < 1400000 )) USES+= llvm:max=15 .endif post-install: # strip binaries @${STRIP_CMD} \ ${STAGEDIR}${PYTHON_SITELIBDIR}/torch/bin/torch_shm_manager \ ${STAGEDIR}${PYTHON_SITELIBDIR}/torch/_C${PYTHON_EXT_SUFFIX}.so \ ${STAGEDIR}${PYTHON_SITELIBDIR}/functorch/_C${PYTHON_EXT_SUFFIX}.so \ ${STAGEDIR}${PYTHON_SITELIBDIR}/torch/lib/lib*.so fix-plist: # remove the stray %%PYTHON_SITELIBDIR%%/caffe2 file @${REINPLACE_CMD} -e "s|.*/caffe2$$||" ${TMPPLIST} .include diff --git a/misc/py-pytorch/files/patch-CMakeLists.txt b/misc/py-pytorch/files/patch-CMakeLists.txt index 9ebebccbf2e3..4b319d3c9aac 100644 --- a/misc/py-pytorch/files/patch-CMakeLists.txt +++ b/misc/py-pytorch/files/patch-CMakeLists.txt @@ -1,39 +1,39 @@ ---- CMakeLists.txt.orig 2023-04-03 19:45:59 UTC +--- CMakeLists.txt.orig 2023-10-06 19:49:00 UTC +++ CMakeLists.txt -@@ -138,7 +138,7 @@ endif() +@@ -139,7 +139,7 @@ endif() set(CPU_AARCH64 OFF) set(CPU_INTEL OFF) -if(CMAKE_SYSTEM_PROCESSOR MATCHES "(AMD64|x86_64)") +if(CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64|x86_64)") set(CPU_INTEL ON) elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)") set(CPU_AARCH64 ON) -@@ -163,7 +163,7 @@ include(CMakeDependentOption) +@@ -164,7 +164,7 @@ include(CMakeDependentOption) option(ATEN_NO_TEST "Do not build ATen test binaries" OFF) option(BUILD_BINARY "Build C++ binaries" OFF) option(BUILD_DOCS "Build Caffe2 documentation" OFF) -option(BUILD_CUSTOM_PROTOBUF "Build and use Caffe2's own protobuf under third_party" ON) +option(BUILD_CUSTOM_PROTOBUF "Build and use Caffe2's own protobuf under third_party" OFF) option(BUILD_PYTHON "Build Python binaries" ON) option(BUILD_CAFFE2 "Master flag to build Caffe2" OFF) option(BUILD_LITE_INTERPRETER "Master flag to build Lite Interpreter" OFF) -@@ -398,15 +398,15 @@ endif() +@@ -408,15 +408,15 @@ endif() # USE_SYSTEM_LIBS being "OFF". option(USE_SYSTEM_LIBS "Use all available system-provided libraries." OFF) option(USE_SYSTEM_CPUINFO "Use system-provided cpuinfo." OFF) -option(USE_SYSTEM_SLEEF "Use system-provided sleef." OFF) +option(USE_SYSTEM_SLEEF "Use system-provided sleef." ON) option(USE_SYSTEM_GLOO "Use system-provided gloo." OFF) option(USE_SYSTEM_FP16 "Use system-provided fp16." OFF) -option(USE_SYSTEM_PYBIND11 "Use system-provided PyBind11." OFF) +option(USE_SYSTEM_PYBIND11 "Use system-provided PyBind11." ON) option(USE_SYSTEM_PTHREADPOOL "Use system-provided pthreadpool." OFF) option(USE_SYSTEM_PSIMD "Use system-provided psimd." OFF) option(USE_SYSTEM_FXDIV "Use system-provided fxdiv." OFF) option(USE_SYSTEM_BENCHMARK "Use system-provided google benchmark." OFF) -option(USE_SYSTEM_ONNX "Use system-provided onnx." OFF) +option(USE_SYSTEM_ONNX "Use system-provided onnx." ON) option(USE_SYSTEM_XNNPACK "Use system-provided xnnpack." OFF) + option(USE_SYSTEM_ZSTD "Use system-provided zstd." OFF) option(USE_GOLD_LINKER "Use ld.gold to link" OFF) - if(USE_SYSTEM_LIBS) diff --git a/misc/py-pytorch/files/patch-c10_core_DynamicCast.h b/misc/py-pytorch/files/patch-c10_core_DynamicCast.h index 517085e8bdee..096c85f368f8 100644 --- a/misc/py-pytorch/files/patch-c10_core_DynamicCast.h +++ b/misc/py-pytorch/files/patch-c10_core_DynamicCast.h @@ -1,21 +1,31 @@ - workaround for the failuree diring math/dgl build: - /usr/local/lib/python3.9/site-packages/torch/include/c10/core/DynamicCast.h:112:22: error: use of undeclared identifier '__assert_fail' +- see https://github.com/pytorch/pytorch/issues/113941 ---- c10/core/DynamicCast.h.orig 2023-05-10 02:37:18 UTC +--- c10/core/DynamicCast.h.orig 2023-10-06 19:49:01 UTC +++ c10/core/DynamicCast.h +@@ -54,7 +54,7 @@ namespace c10 { + // + + #ifdef C10_HOST_DEVICE +-#define ERROR_UNSUPPORTED_CAST CUDA_KERNEL_ASSERT(false); ++#define ERROR_UNSUPPORTED_CAST assert(false); + #else + #define ERROR_UNSUPPORTED_CAST TORCH_CHECK(false, "Unexpected scalar type"); + #endif @@ -99,13 +99,13 @@ C10_HOST_DEVICE inline void cast_and_store( template <> \ C10_HOST_DEVICE inline T fetch_and_cast( \ const ScalarType src_type, const void* ptr) { \ - CUDA_KERNEL_ASSERT(ScalarType::scalartype_ == src_type); \ + assert(ScalarType::scalartype_ == src_type); \ return c10::load(ptr); \ } \ template <> \ C10_HOST_DEVICE inline void cast_and_store( \ const ScalarType dest_type, void* ptr, T value) { \ - CUDA_KERNEL_ASSERT(ScalarType::scalartype_ == dest_type); \ + assert(ScalarType::scalartype_ == dest_type); \ *(T*)ptr = value; \ }