diff --git a/0001-Fix-for-PyTorch-mobile-flatbuffer-loader-out-of-bounds-reads.patch b/0001-Fix-for-PyTorch-mobile-flatbuffer-loader-out-of-bounds-reads.patch deleted file mode 100644 index aab86ea5f074876559c32b5acf00af34f20d53f8..0000000000000000000000000000000000000000 --- a/0001-Fix-for-PyTorch-mobile-flatbuffer-loader-out-of-bounds-reads.patch +++ /dev/null @@ -1,37 +0,0 @@ -From 0d3ceb3058201868765ff3aa1126685f3f7f9ecc Mon Sep 17 00:00:00 2001 -From: Andrew Calvano -Date: Fri, 17 Nov 2023 17:29:04 +0000 -Subject: [PATCH] Fix for PyTorch mobile flatbuffer loader out of bounds reads - (#110162) - -Summary: -The mobile_ivalue_size field in the mobile_bytecode flatbuffer schema can be larger than the ivalues vector. This introduces potential for memory corruption when parsing the mobile_bytecode Module. - -This diff fixes the issue by ensuring that mobile_ivalue_size is less than the size of the ivalues vector. - -Test Plan: contbuild & OSS CI - -Differential Revision: D49687548 - -Pull Request resolved: https://github.com/pytorch/pytorch/pull/110162 -Approved by: https://github.com/malfet ---- - torch/csrc/jit/mobile/flatbuffer_loader.cpp | 2 +- - 1 file changed, 1 insertion(+), 1 deletion(-) - -diff --git a/torch/csrc/jit/mobile/flatbuffer_loader.cpp b/torch/csrc/jit/mobile/flatbuffer_loader.cpp -index 2fb12a4f..2069330b 100644 ---- a/torch/csrc/jit/mobile/flatbuffer_loader.cpp -+++ b/torch/csrc/jit/mobile/flatbuffer_loader.cpp -@@ -302,7 +302,7 @@ mobile::Module FlatbufferLoader::parseModule( - storage_loaded_.resize(module->storage_data_size(), false); - - mobile_ivalue_size_ = module_->mobile_ivalue_size(); -- if (mobile_ivalue_size_ == 0) { -+ if (mobile_ivalue_size_ == 0 || mobile_ivalue_size_ > ivalues->size()) { - mobile_ivalue_size_ = ivalues->size(); - } - --- -2.43.0 - diff --git a/0001-add-Wno-error-nonnull-for-test-cpp-api.patch b/0001-add-Wno-error-nonnull-for-test-cpp-api.patch deleted file mode 100644 index b49872605158f4d847d0d2354eee60949d522cab..0000000000000000000000000000000000000000 --- a/0001-add-Wno-error-nonnull-for-test-cpp-api.patch +++ /dev/null @@ -1,29 +0,0 @@ -From 367387bab836c73c23719f97d929572c8b4e0fad Mon Sep 17 00:00:00 2001 -From: Nick Rossenbach -Date: Tue, 18 Apr 2023 23:31:51 +0200 -Subject: [PATCH] Add -Wno-error=nonnull for test/cpp/api/ - -On some platforms the build might fail due to the nonnull error -being triggered by different compiler behavior. - -Fix for #99278. ---- - test/cpp/api/CMakeLists.txt | 5 +++++ - 1 file changed, 5 insertions(+) - -diff --git a/test/cpp/api/CMakeLists.txt b/test/cpp/api/CMakeLists.txt -index 6b801a073182794..181139b01360c30 100644 ---- a/test/cpp/api/CMakeLists.txt -+++ b/test/cpp/api/CMakeLists.txt -@@ -80,6 +80,11 @@ if(NOT MSVC) - target_compile_options_if_supported(test_api "-Wno-maybe-uninitialized") - # gcc gives nonsensical warnings about variadic.h - target_compile_options_if_supported(test_api "-Wno-unused-but-set-parameter") -+ # the nonnull check might trigger for some build configurations, -+ # probably happening due to different code optimization -+ # (see e.g. https://rkoucha.fr/tech_corner/nonnull_gcc_attribute.html) -+ # this happened for a riscv build: https://github.com/pytorch/pytorch/issues/99278 -+ target_compile_options_if_supported(test_api "-Wno-error=nonnull") - endif() - - if(INSTALL_TEST) diff --git a/0001-remove-nccl-check.patch b/0001-remove-nccl-check.patch new file mode 100644 index 0000000000000000000000000000000000000000..5ad8cbc731dbc646331f3526eaee21e60d4263ec --- /dev/null +++ b/0001-remove-nccl-check.patch @@ -0,0 +1,25 @@ +From 0f51b22f75a7250559c4b3ff48afbe18ec858a91 Mon Sep 17 00:00:00 2001 +From: Icey <1790571317@qq.com> +Date: Mon, 14 Jul 2025 06:30:01 +0000 +Subject: [PATCH] remove nccl check + +--- + tools/build_pytorch_libs.py | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/tools/build_pytorch_libs.py b/tools/build_pytorch_libs.py +index 5dd5a221975..ca315302fc3 100644 +--- a/tools/build_pytorch_libs.py ++++ b/tools/build_pytorch_libs.py +@@ -119,7 +119,8 @@ def build_pytorch( + cmake: CMake, + ) -> None: + my_env = _create_build_env() +- checkout_nccl() ++ if os.getenv("USE_NCCL", "1") != "0": ++ checkout_nccl() + build_test = not check_negative_env_flag("BUILD_TEST") + cmake.generate( + version, cmake_python_library, build_python, build_test, my_env, rerun_cmake +-- +2.34.1 diff --git a/0003-Add-loongarch64-support-for-third_party.patch b/0003-Add-loongarch64-support-for-third_party.patch deleted file mode 100644 index 11944314148307a35bc79b895e560a0e45685eb5..0000000000000000000000000000000000000000 --- a/0003-Add-loongarch64-support-for-third_party.patch +++ /dev/null @@ -1,81 +0,0 @@ -From cba0eb7a9a7504847f48366c2efc901d3f3652ec Mon Sep 17 00:00:00 2001 -From: zhangzikang -Date: Tue, 21 May 2024 15:28:14 +0800 -Subject: [PATCH] Add loongarch64 support for third_party - ---- - third_party/benchmark/src/cycleclock.h | 2 +- - .../third_party/onnx/third_party/benchmark/src/cycleclock.h | 2 +- - third_party/onnx/third_party/benchmark/src/cycleclock.h | 2 +- - third_party/protobuf/third_party/benchmark/src/cycleclock.h | 2 +- - third_party/sleef/src/arch/helperpurec_scalar.h | 2 +- - 5 files changed, 5 insertions(+), 5 deletions(-) - -diff --git a/third_party/benchmark/src/cycleclock.h b/third_party/benchmark/src/cycleclock.h -index d65d32a3..4efaf582 100644 ---- a/third_party/benchmark/src/cycleclock.h -+++ b/third_party/benchmark/src/cycleclock.h -@@ -208,7 +208,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { - asm volatile("rdcycle %0" : "=r"(cycles)); - return cycles; - #endif --#elif defined(__e2k__) || defined(__elbrus__) -+#elif defined(__e2k__) || defined(__elbrus__) || defined(__loongarch64) - struct timeval tv; - gettimeofday(&tv, nullptr); - return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; -diff --git a/third_party/onnx-tensorrt/third_party/onnx/third_party/benchmark/src/cycleclock.h b/third_party/onnx-tensorrt/third_party/onnx/third_party/benchmark/src/cycleclock.h -index 3b376ac5..b0a3c0cb 100644 ---- a/third_party/onnx-tensorrt/third_party/onnx/third_party/benchmark/src/cycleclock.h -+++ b/third_party/onnx-tensorrt/third_party/onnx/third_party/benchmark/src/cycleclock.h -@@ -153,7 +153,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { - struct timeval tv; - gettimeofday(&tv, nullptr); - return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; --#elif defined(__mips__) -+#elif defined(__mips__) || defined(__loongarch64) - // mips apparently only allows rdtsc for superusers, so we fall - // back to gettimeofday. It's possible clock_gettime would be better. - struct timeval tv; -diff --git a/third_party/onnx/third_party/benchmark/src/cycleclock.h b/third_party/onnx/third_party/benchmark/src/cycleclock.h -index d65d32a3..4efaf582 100644 ---- a/third_party/onnx/third_party/benchmark/src/cycleclock.h -+++ b/third_party/onnx/third_party/benchmark/src/cycleclock.h -@@ -208,7 +208,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { - asm volatile("rdcycle %0" : "=r"(cycles)); - return cycles; - #endif --#elif defined(__e2k__) || defined(__elbrus__) -+#elif defined(__e2k__) || defined(__elbrus__) || defined(__loongarch64) - struct timeval tv; - gettimeofday(&tv, nullptr); - return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; -diff --git a/third_party/protobuf/third_party/benchmark/src/cycleclock.h b/third_party/protobuf/third_party/benchmark/src/cycleclock.h -index 4251fe4c..694e03dc 100644 ---- a/third_party/protobuf/third_party/benchmark/src/cycleclock.h -+++ b/third_party/protobuf/third_party/benchmark/src/cycleclock.h -@@ -153,7 +153,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { - struct timeval tv; - gettimeofday(&tv, nullptr); - return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; --#elif defined(__mips__) -+#elif defined(__mips__) || defined(__loongarch64) - // mips apparently only allows rdtsc for superusers, so we fall - // back to gettimeofday. It's possible clock_gettime would be better. - struct timeval tv; -diff --git a/third_party/sleef/src/arch/helperpurec_scalar.h b/third_party/sleef/src/arch/helperpurec_scalar.h -index e77e518f..a8c96e3b 100644 ---- a/third_party/sleef/src/arch/helperpurec_scalar.h -+++ b/third_party/sleef/src/arch/helperpurec_scalar.h -@@ -54,7 +54,7 @@ - #define ENABLE_FMA_SP - //@#define ENABLE_FMA_SP - --#if defined(__AVX2__) || defined(__aarch64__) || defined(__arm__) || defined(__powerpc64__) || defined(__zarch__) || CONFIG == 3 -+#if defined(__AVX2__) || defined(__aarch64__) || defined(__arm__) || defined(__powerpc64__) || defined(__zarch__) || defined(__loongarch64) || CONFIG == 3 - #ifndef FP_FAST_FMA - #define FP_FAST_FMA - //@#define FP_FAST_FMA --- -2.33.0 - diff --git a/0004-Fix-build-error-for-riscv64.patch b/0004-Fix-build-error-for-riscv64.patch deleted file mode 100644 index c3115f7d272eda9e268e1a5a3156a49e5d40a66b..0000000000000000000000000000000000000000 --- a/0004-Fix-build-error-for-riscv64.patch +++ /dev/null @@ -1,74 +0,0 @@ -From 1dc0fa9e37959b8fedfd1799670388e3f06d0ecc Mon Sep 17 00:00:00 2001 -From: Dingli Zhang -Date: Tue, 16 Jul 2024 17:52:28 +0000 -Subject: [PATCH] Fix build error for riscv64 - - -diff --git a/third_party/benchmark/src/cycleclock.h b/third_party/benchmark/src/cycleclock.h -index d65d32a3..452e11e4 100644 ---- a/third_party/benchmark/src/cycleclock.h -+++ b/third_party/benchmark/src/cycleclock.h -@@ -208,7 +208,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { - asm volatile("rdcycle %0" : "=r"(cycles)); - return cycles; - #endif --#elif defined(__e2k__) || defined(__elbrus__) -+#elif defined(__e2k__) || defined(__elbrus__) || defined(__riscv) - struct timeval tv; - gettimeofday(&tv, nullptr); - return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; -diff --git a/third_party/onnx-tensorrt/third_party/onnx/third_party/benchmark/src/cycleclock.h b/third_party/onnx-tensorrt/third_party/onnx/third_party/benchmark/src/cycleclock.h -index 3b376ac5..add2f298 100644 ---- a/third_party/onnx-tensorrt/third_party/onnx/third_party/benchmark/src/cycleclock.h -+++ b/third_party/onnx-tensorrt/third_party/onnx/third_party/benchmark/src/cycleclock.h -@@ -153,7 +153,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { - struct timeval tv; - gettimeofday(&tv, nullptr); - return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; --#elif defined(__mips__) -+#elif defined(__mips__) || defined(__riscv) - // mips apparently only allows rdtsc for superusers, so we fall - // back to gettimeofday. It's possible clock_gettime would be better. - struct timeval tv; -diff --git a/third_party/onnx/third_party/benchmark/src/cycleclock.h b/third_party/onnx/third_party/benchmark/src/cycleclock.h -index d65d32a3..452e11e4 100644 ---- a/third_party/onnx/third_party/benchmark/src/cycleclock.h -+++ b/third_party/onnx/third_party/benchmark/src/cycleclock.h -@@ -208,7 +208,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { - asm volatile("rdcycle %0" : "=r"(cycles)); - return cycles; - #endif --#elif defined(__e2k__) || defined(__elbrus__) -+#elif defined(__e2k__) || defined(__elbrus__) || defined(__riscv) - struct timeval tv; - gettimeofday(&tv, nullptr); - return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; -diff --git a/third_party/protobuf/third_party/benchmark/src/cycleclock.h b/third_party/protobuf/third_party/benchmark/src/cycleclock.h -index 4251fe4c..07d63307 100644 ---- a/third_party/protobuf/third_party/benchmark/src/cycleclock.h -+++ b/third_party/protobuf/third_party/benchmark/src/cycleclock.h -@@ -153,7 +153,7 @@ inline BENCHMARK_ALWAYS_INLINE int64_t Now() { - struct timeval tv; - gettimeofday(&tv, nullptr); - return static_cast(tv.tv_sec) * 1000000 + tv.tv_usec; --#elif defined(__mips__) -+#elif defined(__mips__) || defined(__riscv) - // mips apparently only allows rdtsc for superusers, so we fall - // back to gettimeofday. It's possible clock_gettime would be better. - struct timeval tv; -diff --git a/third_party/sleef/src/arch/helperpurec_scalar.h b/third_party/sleef/src/arch/helperpurec_scalar.h -index e77e518f..f28c2b83 100644 ---- a/third_party/sleef/src/arch/helperpurec_scalar.h -+++ b/third_party/sleef/src/arch/helperpurec_scalar.h -@@ -54,7 +54,7 @@ - #define ENABLE_FMA_SP - //@#define ENABLE_FMA_SP - --#if defined(__AVX2__) || defined(__aarch64__) || defined(__arm__) || defined(__powerpc64__) || defined(__zarch__) || CONFIG == 3 -+#if defined(__AVX2__) || defined(__aarch64__) || defined(__arm__) || defined(__powerpc64__) || defined(__zarch__) || defined(__riscv) || CONFIG == 3 - #ifndef FP_FAST_FMA - #define FP_FAST_FMA - //@#define FP_FAST_FMA --- -2.41.0 - diff --git a/pytorch-v2.1.2.tar.gz b/pytorch-v2.7.0.tar.gz similarity index 90% rename from pytorch-v2.1.2.tar.gz rename to pytorch-v2.7.0.tar.gz index 97be513875b5699cc85864d0611097d4883aec16..83dc3f6ccc7225555c5076afa7ce83b43d4600b6 100644 Binary files a/pytorch-v2.1.2.tar.gz and b/pytorch-v2.7.0.tar.gz differ diff --git a/pytorch.spec b/pytorch.spec index 27eda9b5d1f9fa8d900221207eecbf16ceca7d24..c58f3756f4e32d7225cc87ad44775b8e95d819d3 100644 --- a/pytorch.spec +++ b/pytorch.spec @@ -1,24 +1,16 @@ %global _empty_manifest_terminate_build 0 -Name: pytorch -Version: 2.1.2 -Release: 5 -Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration -License: BSD-3-Clause -URL: https://pytorch.org/ -Source0: https://github.com/pytorch/pytorch/releases/download/v%{version}/pytorch-v%{version}.tar.gz - -Patch1: 0001-add-Wno-error-nonnull-for-test-cpp-api.patch -Patch2: 0001-Fix-for-PyTorch-mobile-flatbuffer-loader-out-of-bounds-reads.patch -%ifarch loongarch64 -Patch3: 0003-Add-loongarch64-support-for-third_party.patch -%endif -%ifarch riscv64 -Patch4: 0004-Fix-build-error-for-riscv64.patch -%endif - +Name: pytorch +Version: 2.7.0 +Release: 1 +Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration +License: BSD-3-Clause +URL: https://pytorch.org/ +Source0: https://github.com/pytorch/pytorch/releases/download/v%{version}/pytorch-v%{version}.tar.gz + +Patch1: 0001-remove-nccl-check.patch BuildRequires: g++ -Requires: python3-future -Requires: python3-numpy +Requires: python3-future +Requires: python3-numpy %description PyTorch is a Python package that provides two high-level features: @@ -27,8 +19,8 @@ PyTorch is a Python package that provides two high-level features: You can reuse your favorite Python packages such as NumPy, SciPy and Cython to extend PyTorch when needed. %package -n python3-pytorch -Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration -Provides: python-torch +Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration +Provides: python-torch BuildRequires: python3-devel BuildRequires: python3-setuptools BuildRequires: python3-setuptools_scm @@ -37,12 +29,20 @@ BuildRequires: python3-pip BuildRequires: python3-wheel BuildRequires: python3-hatchling -BuildRequires: python3-astunparse -BuildRequires: python3-numpy -BuildRequires: python3-pyyaml -BuildRequires: cmake -BuildRequires: python3-typing-extensions -BuildRequires: python3-requests +BuildRequires: python3-astunparse +BuildRequires: cmake +BuildRequires: python3-filelock +BuildRequires: python3-fsspec +BuildRequires: python3-hypothesis +BuildRequires: python3-jinja2 +BuildRequires: python3-networkx +BuildRequires: python3-ninja +BuildRequires: python3-numpy +BuildRequires: python3-packaging +BuildRequires: python3-pyyaml +BuildRequires: python3-requests +BuildRequires: python3-sympy +BuildRequires: python3-typing-extensions %description -n python3-pytorch PyTorch is a Python package that provides two high-level features: @@ -51,8 +51,8 @@ PyTorch is a Python package that provides two high-level features: You can reuse your favorite Python packages such as NumPy, SciPy and Cython to extend PyTorch when needed. %package help -Summary: Development documents and examples for torch -Provides: python3-pytorch-doc +Summary: Development documents and examples for torch +Provides: python3-pytorch-doc %description help PyTorch is a Python package that provides two high-level features: - Tensor computation (like NumPy) with strong GPU acceleration @@ -63,6 +63,9 @@ You can reuse your favorite Python packages such as NumPy, SciPy and Cython to e %autosetup -p1 -n %{name}-v%{version} %build +export USE_CUDA=0 +export USE_NCCL=0 +export USE_SYSTEM_NCCL=0 export CFLAGS+=" -Wno-error=maybe-uninitialized -Wno-error=uninitialized -Wno-error=restrict -fPIC" export CXXFLAGS+=" -Wno-error=maybe-uninitialized -Wno-error=uninitialized -Wno-error=restrict -fPIC" %pyproject_build @@ -77,16 +80,16 @@ if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi pushd %{buildroot} touch doclist.lst if [ -d usr/share/man ]; then - find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst fi popd mv %{buildroot}/doclist.lst . + %files -n python3-pytorch %doc *.md %license LICENSE -%{_bindir}/convert-caffe2-to-onnx -%{_bindir}/convert-onnx-to-caffe2 +%{_bindir}/torchfrtrace %{_bindir}/torchrun %{python3_sitearch}/* @@ -94,6 +97,9 @@ mv %{buildroot}/doclist.lst . %{_docdir}/* %changelog +* Fri Jul 11 2025 Xiaoshuang Wang <1790571317@qq.com> - 2.7.0-1 +- upgrade to 2.7.0 + * Wed Jul 17 2024 Dingli Zhang - 2.1.2-5 - Fix build error for riscv64