aboutsummaryrefslogtreecommitdiff
path: root/misc/py-pytorch
diff options
context:
space:
mode:
Diffstat (limited to 'misc/py-pytorch')
-rw-r--r--misc/py-pytorch/Makefile18
-rw-r--r--misc/py-pytorch/distinfo6
-rw-r--r--misc/py-pytorch/files/patch-CMakeLists.txt10
-rw-r--r--misc/py-pytorch/files/patch-third__party_fbgemm_third__party_asmjit_src_asmjit_core_virtmem.cpp10
-rw-r--r--misc/py-pytorch/files/patch-third__party_tensorpipe_tensorpipe_common_system.cc30
-rw-r--r--misc/py-pytorch/files/patch-tools_build__pytorch__libs.py15
-rw-r--r--misc/py-pytorch/files/patch-torch_csrc_distributed_c10d_ProcessGroupGloo.cpp22
7 files changed, 82 insertions, 29 deletions
diff --git a/misc/py-pytorch/Makefile b/misc/py-pytorch/Makefile
index 4b20c667b5c1..227e1ea21933 100644
--- a/misc/py-pytorch/Makefile
+++ b/misc/py-pytorch/Makefile
@@ -1,7 +1,7 @@
PORTNAME= pytorch
DISTVERSIONPREFIX= v
-DISTVERSION= 2.7.1
-PORTREVISION= 1
+DISTVERSION= 2.8.0
+PORTREVISION= 2
CATEGORIES= misc # machine-learning
MASTER_SITES= https://github.com/pytorch/pytorch/releases/download/v${DISTVERSION}/
PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}
@@ -50,6 +50,7 @@ RUN_DEPENDS+= ${PYTHON_PKGNAMEPREFIX}astunparse>0:devel/py-astunparse@${PY_FLAVO
USES= compiler:c++17-lang localbase:ldflags python
USE_PYTHON= distutils autoplist
+USE_LDCONFIG= ${PYTHON_SITELIBDIR}/torch/lib
USE_GITHUB= nodefault
GH_TUPLE= pytorch:cpuinfo:1e83a2f:cpuinfo/cpuinfo-with-freebsd-support # https://github.com/pytorch/cpuinfo/pull/230/commits
@@ -60,6 +61,7 @@ MAKE_ENV+= USE_MKLDNN=0 # disable MKLDNN that doesn't exist, see https://github.
MAKE_ENV+= USE_CUDNN=0
MAKE_ENV+= USE_LAPACK=1 # needed on FreeBSD to run w/out GPU
MAKE_ENV+= USE_QNNPACK=0
+MAKE_ENV+= USE_DISTRIBUTED=1
LDFLAGS+= -lexecinfo
LDFLAGS_powerpc64le= -pthread
@@ -70,6 +72,14 @@ POST_PLIST= fix-plist
TEST_ENV= ${MAKE_ENV} PYTHONPATH=${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}
TEST_WRKSRC= ${WRKSRC}/test
+OPTIONS_DEFINE= VULKAN
+OPTIONS_DEFAULT= VULKAN # VULKAN is experimental in PyTorch and only simple computations work
+
+VULKAN_MAKE_ENV= USE_VULKAN=1 USE_VULKAN_SHADERC_RUNTIME=1 USE_VULKAN_WRAPPER=0 # see https://docs.pytorch.org/tutorials/unstable/vulkan_workflow.html
+VULKAN_BUILD_DEPENDS= glslc:graphics/shaderc \
+ vulkan-headers>0:graphics/vulkan-headers
+VULKAN_LIB_DEPENDS= libvulkan.so:graphics/vulkan-loader
+
.include <bsd.port.options.mk>
.if ${OPSYS} == FreeBSD
@@ -78,9 +88,9 @@ USES+= llvm:max=15
post-patch:
@cd ${WRKSRC} && \
- ${RM} -r third_party/cpuinfo third_party/fbgemm/third_party/cpuinfo && \
+ ${RM} -r third_party/cpuinfo third_party/fbgemm/external/cpuinfo && \
${CP} -r cpuinfo-with-freebsd-support third_party/cpuinfo && \
- ${CP} -r cpuinfo-with-freebsd-support third_party/fbgemm/third_party/cpuinfo
+ ${CP} -r cpuinfo-with-freebsd-support third_party/fbgemm/external/cpuinfo
post-install: # strip binaries
@${STRIP_CMD} \
diff --git a/misc/py-pytorch/distinfo b/misc/py-pytorch/distinfo
index 40aad9e52cc9..83e007ea33e1 100644
--- a/misc/py-pytorch/distinfo
+++ b/misc/py-pytorch/distinfo
@@ -1,5 +1,5 @@
-TIMESTAMP = 1749972703
-SHA256 (pytorch/pytorch-v2.7.1.tar.gz) = 5befd2e540fd55ce4782d0ca7610ce5b572d756d7ea38090ef0f3c7c428fb20f
-SIZE (pytorch/pytorch-v2.7.1.tar.gz) = 285998076
+TIMESTAMP = 1755586021
+SHA256 (pytorch/pytorch-v2.8.0.tar.gz) = c70a2c9488f6f6e8af5982a10d1cc2c37b7df5e6506d839daa5d5e250953d7b5
+SIZE (pytorch/pytorch-v2.8.0.tar.gz) = 330943132
SHA256 (pytorch/pytorch-cpuinfo-1e83a2f_GH0.tar.gz) = b8945cf45d4f13054d7f52e8bd9314690ea840d4d0ff21febd95ff04de3c613e
SIZE (pytorch/pytorch-cpuinfo-1e83a2f_GH0.tar.gz) = 3541839
diff --git a/misc/py-pytorch/files/patch-CMakeLists.txt b/misc/py-pytorch/files/patch-CMakeLists.txt
index 2a92cee61cdc..f7b4af5cd8d0 100644
--- a/misc/py-pytorch/files/patch-CMakeLists.txt
+++ b/misc/py-pytorch/files/patch-CMakeLists.txt
@@ -1,6 +1,6 @@
---- CMakeLists.txt.orig 2025-04-23 16:19:35 UTC
+--- CMakeLists.txt.orig 2025-08-06 17:08:00 UTC
+++ CMakeLists.txt
-@@ -182,7 +182,7 @@ set(CPU_POWER OFF)
+@@ -173,7 +173,7 @@ set(CPU_POWER OFF)
set(CPU_INTEL OFF)
set(CPU_POWER OFF)
@@ -9,7 +9,7 @@
set(CPU_INTEL ON)
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64|arm64)")
set(CPU_AARCH64 ON)
-@@ -212,7 +212,7 @@ option(BUILD_CUSTOM_PROTOBUF
+@@ -203,7 +203,7 @@ option(BUILD_CUSTOM_PROTOBUF
option(ATEN_NO_TEST "Do not build ATen test binaries" OFF)
option(BUILD_BINARY "Build C++ binaries" OFF)
option(BUILD_CUSTOM_PROTOBUF
@@ -18,7 +18,7 @@
option(BUILD_PYTHON "Build Python binaries" ON)
option(BUILD_LITE_INTERPRETER "Master flag to build Lite Interpreter" OFF)
option(BUILD_SHARED_LIBS "Build libcaffe2.so" ON)
-@@ -263,7 +263,7 @@ option(USE_GLOG "Use GLOG" OFF)
+@@ -254,7 +254,7 @@ option(USE_GLOG "Use GLOG" OFF)
option(USE_FAKELOWP "Use FakeLowp operators" OFF)
option(USE_GFLAGS "Use GFLAGS" OFF)
option(USE_GLOG "Use GLOG" OFF)
@@ -27,7 +27,7 @@
option(USE_MAGMA "Use MAGMA" ON)
option(USE_PYTORCH_METAL "Use Metal for PyTorch iOS build" OFF)
option(USE_PYTORCH_METAL_EXPORT "Export Metal models on MacOSX desktop" OFF)
-@@ -453,15 +453,15 @@ option(USE_SYSTEM_CPUINFO "Use system-provided cpuinfo
+@@ -451,15 +451,15 @@ option(USE_SYSTEM_CPUINFO "Use system-provided cpuinfo
# 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)
diff --git a/misc/py-pytorch/files/patch-third__party_fbgemm_third__party_asmjit_src_asmjit_core_virtmem.cpp b/misc/py-pytorch/files/patch-third__party_fbgemm_third__party_asmjit_src_asmjit_core_virtmem.cpp
deleted file mode 100644
index 09a801db1dfc..000000000000
--- a/misc/py-pytorch/files/patch-third__party_fbgemm_third__party_asmjit_src_asmjit_core_virtmem.cpp
+++ /dev/null
@@ -1,10 +0,0 @@
---- third_party/fbgemm/third_party/asmjit/src/asmjit/core/virtmem.cpp.orig 2022-12-16 00:23:48 UTC
-+++ third_party/fbgemm/third_party/asmjit/src/asmjit/core/virtmem.cpp
-@@ -45,6 +45,7 @@
- #endif
-
- #include <atomic>
-+#include <sys/stat.h>
-
- #if defined(__APPLE__) || defined(__BIONIC__)
- #define ASMJIT_VM_SHM_DETECT 0
diff --git a/misc/py-pytorch/files/patch-third__party_tensorpipe_tensorpipe_common_system.cc b/misc/py-pytorch/files/patch-third__party_tensorpipe_tensorpipe_common_system.cc
new file mode 100644
index 000000000000..cc052f650cfa
--- /dev/null
+++ b/misc/py-pytorch/files/patch-third__party_tensorpipe_tensorpipe_common_system.cc
@@ -0,0 +1,30 @@
+--- third_party/tensorpipe/tensorpipe/common/system.cc.orig 2025-06-04 18:15:56 UTC
++++ third_party/tensorpipe/tensorpipe/common/system.cc
+@@ -102,6 +102,27 @@ std::string getPathForLinuxNamespace(LinuxNamespace ns
+ return oss.str();
+ }
+
++#elif defined(__FreeBSD__)
++
++#include <unistd.h>
++#include <stdio.h>
++#include <sys/sysctl.h>
++#include <time.h>
++
++optional<std::string> getBootIDInternal() {
++ char hostname[256];
++ (void)::gethostname(hostname, sizeof(hostname));
++
++ struct timeval boottime;
++ size_t size = sizeof(boottime);
++ (void)sysctlbyname("kern.boottime", &boottime, &size, nullptr, 0);
++
++ char buf[512];
++ ::sprintf(buf, "%s-%ld-%ld", hostname, boottime.tv_sec, boottime.tv_usec);
++
++ return std::string(buf);
++}
++
+ #endif
+
+ } // namespace
diff --git a/misc/py-pytorch/files/patch-tools_build__pytorch__libs.py b/misc/py-pytorch/files/patch-tools_build__pytorch__libs.py
index 2ab33dd899a4..7a421c1bd8e3 100644
--- a/misc/py-pytorch/files/patch-tools_build__pytorch__libs.py
+++ b/misc/py-pytorch/files/patch-tools_build__pytorch__libs.py
@@ -1,11 +1,12 @@
---- tools/build_pytorch_libs.py.orig 2025-04-24 16:28:33 UTC
+--- tools/build_pytorch_libs.py.orig 2025-08-06 17:08:06 UTC
+++ tools/build_pytorch_libs.py
-@@ -119,7 +119,7 @@ def build_pytorch(
- cmake: CMake,
- ) -> None:
- my_env = _create_build_env()
-- checkout_nccl()
-+ #checkout_nccl()
+@@ -91,7 +91,8 @@ def build_pytorch(
+ and not check_negative_env_flag("USE_NCCL")
+ and not check_env_flag("USE_SYSTEM_NCCL")
+ ):
+- checkout_nccl()
++ #checkout_nccl()
++ pass
build_test = not check_negative_env_flag("BUILD_TEST")
cmake.generate(
version, cmake_python_library, build_python, build_test, my_env, rerun_cmake
diff --git a/misc/py-pytorch/files/patch-torch_csrc_distributed_c10d_ProcessGroupGloo.cpp b/misc/py-pytorch/files/patch-torch_csrc_distributed_c10d_ProcessGroupGloo.cpp
new file mode 100644
index 000000000000..7977852226dd
--- /dev/null
+++ b/misc/py-pytorch/files/patch-torch_csrc_distributed_c10d_ProcessGroupGloo.cpp
@@ -0,0 +1,22 @@
+--- torch/csrc/distributed/c10d/ProcessGroupGloo.cpp.orig 2025-06-04 18:15:57 UTC
++++ torch/csrc/distributed/c10d/ProcessGroupGloo.cpp
+@@ -111,6 +111,10 @@
+ }
+ #endif
+
++#if defined(__FreeBSD__)
++#define HOST_NAME_MAX 256
++#endif
++
+ namespace c10d {
+
+ namespace {
+@@ -705,7 +709,7 @@ std::shared_ptr<::gloo::transport::Device> ProcessGrou
+ return ::c10d::GlooDeviceFactory::makeDeviceForHostname(hostname);
+ }
+
+-#if defined(__linux__) || defined(_WIN32)
++#if defined(__linux__) || defined(__FreeBSD__) || defined(_WIN32)
+ std::shared_ptr<::gloo::transport::Device> ProcessGroupGloo::
+ createDefaultDevice() {
+ // Use the hostname to resolve the network address to