From e322a8382fa1d549bd0df5d5b2d27edc03853717 Mon Sep 17 00:00:00 2001 From: Dom Heinzeller Date: Wed, 3 Apr 2024 15:57:54 -0600 Subject: py-torch: Add variant 'internal-protobuf' to build with the internal protobuf (#43056) --- .../repos/builtin/packages/py-torch/package.py | 26 ++++++++++++++-------- 1 file changed, 17 insertions(+), 9 deletions(-) (limited to 'var') diff --git a/var/spack/repos/builtin/packages/py-torch/package.py b/var/spack/repos/builtin/packages/py-torch/package.py index 82630d7c16..95b640ec3e 100644 --- a/var/spack/repos/builtin/packages/py-torch/package.py +++ b/var/spack/repos/builtin/packages/py-torch/package.py @@ -105,6 +105,10 @@ class PyTorch(PythonPackage, CudaPackage, ROCmPackage): description="Enable breakpad crash dump library", when="@1.10:1.11", ) + # py-torch has strict dependencies on old protobuf/py-protobuf versions that + # cause problems with other packages that require newer versions of protobuf + # and py-protobuf --> provide an option to use the internal/vendored protobuf. + variant("custom-protobuf", default=False, description="Use vendored protobuf") conflicts("+cuda+rocm") conflicts("+tensorpipe", when="+rocm ^hip@:5.1", msg="TensorPipe not supported until ROCm 5.2") @@ -176,14 +180,15 @@ class PyTorch(PythonPackage, CudaPackage, ROCmPackage): depends_on("py-pybind11@2.10.0", when="@1.13:1", type=("build", "link", "run")) depends_on("py-pybind11@2.6.2", when="@1.8:1.12", type=("build", "link", "run")) depends_on("py-pybind11@2.3.0", when="@:1.7", type=("build", "link", "run")) - depends_on("py-protobuf@3.12.2:", when="@1.10:", type=("build", "run")) - depends_on("py-protobuf@:3.14", when="@:1.9", type=("build", "run")) - depends_on("protobuf@3.12.2:", when="@1.10:") - depends_on("protobuf@:3.14", when="@:1.9") - # https://github.com/protocolbuffers/protobuf/issues/10051 - # https://github.com/pytorch/pytorch/issues/78362 - depends_on("py-protobuf@:3", type=("build", "run")) - depends_on("protobuf@:3", type=("build", "run")) + with when("~custom-protobuf"): + depends_on("py-protobuf@3.12.2:", when="@1.10:", type=("build", "run")) + depends_on("py-protobuf@:3.14", when="@:1.9", type=("build", "run")) + depends_on("protobuf@3.12.2:", when="@1.10:") + depends_on("protobuf@:3.14", when="@:1.9") + # https://github.com/protocolbuffers/protobuf/issues/10051 + # https://github.com/pytorch/pytorch/issues/78362 + depends_on("py-protobuf@:3", type=("build", "run")) + depends_on("protobuf@:3") depends_on("eigen") # https://github.com/pytorch/pytorch/issues/60329 # depends_on("cpuinfo@2023-01-13", when="@2.1:") @@ -616,7 +621,10 @@ class PyTorch(PythonPackage, CudaPackage, ROCmPackage): env.set("WITH_BLAS", "generic") # Don't use vendored third-party libraries when possible - env.set("BUILD_CUSTOM_PROTOBUF", "OFF") + if self.spec.satisfies("+custom-protobuf"): + env.set("BUILD_CUSTOM_PROTOBUF", "ON") + else: + env.set("BUILD_CUSTOM_PROTOBUF", "OFF") env.set("USE_SYSTEM_NCCL", "ON") env.set("USE_SYSTEM_EIGEN_INSTALL", "ON") env.set("pybind11_DIR", self.spec["py-pybind11"].prefix) -- cgit v1.2.3-70-g09d2