PyTorch: build with external sleef (#40763)

Co-authored-by: adamjstewart <adamjstewart@users.noreply.github.com>
This commit is contained in:
Adam J. Stewart 2023-11-02 10:09:49 -05:00 committed by GitHub
parent 8b0ab67de4
commit bb64b22066
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 34 deletions

View file

@ -194,10 +194,8 @@ class PyTorch(PythonPackage, CudaPackage, ROCmPackage):
# depends_on("cpuinfo@2022-08-19", when="@1.13:2.0") # depends_on("cpuinfo@2022-08-19", when="@1.13:2.0")
# depends_on("cpuinfo@2020-12-17", when="@1.8:1.12") # depends_on("cpuinfo@2020-12-17", when="@1.8:1.12")
# depends_on("cpuinfo@2020-06-11", when="@1.6:1.7") # depends_on("cpuinfo@2020-06-11", when="@1.6:1.7")
# https://github.com/shibatch/sleef/issues/427 depends_on("sleef@3.5.1_2020-12-22", when="@1.8:")
# depends_on("sleef@3.5.1_2020-12-22", when="@1.8:") depends_on("sleef@3.4.0_2019-07-30", when="@1.6:1.7")
# https://github.com/pytorch/pytorch/issues/60334
# depends_on("sleef@3.4.0_2019-07-30", when="@1.6:1.7")
depends_on("fp16@2020-05-14", when="@1.6:") depends_on("fp16@2020-05-14", when="@1.6:")
depends_on("pthreadpool@2021-04-13", when="@1.9:") depends_on("pthreadpool@2021-04-13", when="@1.9:")
depends_on("pthreadpool@2020-10-05", when="@1.8") depends_on("pthreadpool@2020-10-05", when="@1.8")
@ -308,11 +306,6 @@ class PyTorch(PythonPackage, CudaPackage, ROCmPackage):
# Fixes build error when ROCm is enabled for pytorch-1.5 release # Fixes build error when ROCm is enabled for pytorch-1.5 release
patch("rocm.patch", when="@1.5+rocm") patch("rocm.patch", when="@1.5+rocm")
# Fixes fatal error: sleef.h: No such file or directory
# https://github.com/pytorch/pytorch/pull/35359
# https://github.com/pytorch/pytorch/issues/26555
# patch("sleef.patch", when="@:1.5")
# Fixes compilation with Clang 9.0.0 and Apple Clang 11.0.3 # Fixes compilation with Clang 9.0.0 and Apple Clang 11.0.3
# https://github.com/pytorch/pytorch/pull/37086 # https://github.com/pytorch/pytorch/pull/37086
patch( patch(
@ -628,13 +621,11 @@ def enable_or_disable(variant, keyword="USE", var=None, newer=False):
env.set("pybind11_INCLUDE_DIR", self.spec["py-pybind11"].prefix.include) env.set("pybind11_INCLUDE_DIR", self.spec["py-pybind11"].prefix.include)
if self.spec.satisfies("@1.10:"): if self.spec.satisfies("@1.10:"):
env.set("USE_SYSTEM_PYBIND11", "ON") env.set("USE_SYSTEM_PYBIND11", "ON")
# https://github.com/pytorch/pytorch/issues/60334
# if self.spec.satisfies("@1.8:"):
# env.set("USE_SYSTEM_SLEEF", "ON")
if self.spec.satisfies("@1.6:"): if self.spec.satisfies("@1.6:"):
# env.set("USE_SYSTEM_LIBS", "ON") # env.set("USE_SYSTEM_LIBS", "ON")
# https://github.com/pytorch/pytorch/issues/60329 # https://github.com/pytorch/pytorch/issues/60329
# env.set("USE_SYSTEM_CPUINFO", "ON") # env.set("USE_SYSTEM_CPUINFO", "ON")
env.set("USE_SYSTEM_SLEEF", "ON")
env.set("USE_SYSTEM_GLOO", "ON") env.set("USE_SYSTEM_GLOO", "ON")
env.set("USE_SYSTEM_FP16", "ON") env.set("USE_SYSTEM_FP16", "ON")
env.set("USE_SYSTEM_PTHREADPOOL", "ON") env.set("USE_SYSTEM_PTHREADPOOL", "ON")

View file

@ -1,12 +0,0 @@
diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt
index 8025a7de3c..2e5cdbb5c9 100644
--- a/caffe2/CMakeLists.txt
+++ b/caffe2/CMakeLists.txt
@@ -1232,6 +1232,7 @@ if (BUILD_TEST)
add_executable(${test_name} "${test_src}")
target_link_libraries(${test_name} ${Caffe2_MAIN_LIBS} gtest_main)
target_include_directories(${test_name} PRIVATE $<INSTALL_INTERFACE:include>)
+ target_include_directories(${test_name} PRIVATE $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
target_include_directories(${test_name} PRIVATE ${Caffe2_CPU_INCLUDE})
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
if (INSTALL_TEST)

View file

@ -14,9 +14,7 @@ class Sleef(CMakePackage):
git = "https://github.com/shibatch/sleef.git" git = "https://github.com/shibatch/sleef.git"
version("master", branch="master") version("master", branch="master")
version( version("3.5.1_2020-12-22", commit="e0a003ee838b75d11763aa9c3ef17bf71a725bff") # py-torch@1.8:
"3.5.1_2020-12-22", commit="e0a003ee838b75d11763aa9c3ef17bf71a725bff"
) # py-torch@1.8:1.9
version( version(
"3.5.1", "3.5.1",
sha256="415ee9b1bcc5816989d3d4d92afd0cd3f9ee89cbd5a33eb008e69751e40438ab", sha256="415ee9b1bcc5816989d3d4d92afd0cd3f9ee89cbd5a33eb008e69751e40438ab",
@ -40,17 +38,25 @@ class Sleef(CMakePackage):
) # py-torch@0.4.1:1.0 ) # py-torch@0.4.1:1.0
version("3.2", sha256="3130c5966e204e6d6a3ace81e543d12b5b21f60897f1c185bfa587c1bd77bee2") version("3.2", sha256="3130c5966e204e6d6a3ace81e543d12b5b21f60897f1c185bfa587c1bd77bee2")
# Some versions have ICE when building RelWithDebInfo with GCC 7 # https://github.com/shibatch/sleef/issues/474
# See https://github.com/shibatch/sleef/issues/234 conflicts("%apple-clang@15:")
# See https://github.com/pytorch/pytorch/issues/26892
# See https://github.com/pytorch/pytorch/pull/26993
generator("ninja") generator("ninja")
depends_on("cmake@3.4.3:", type="build") depends_on("cmake@3.4.3:", type="build")
# # https://github.com/shibatch/sleef/issues/475
# depends_on("fftw-api")
# depends_on("mpfr")
# depends_on("openssl")
# # https://github.com/shibatch/sleef/issues/458
# conflicts("^mpfr@4.2:")
def cmake_args(self): def cmake_args(self):
# Taken from PyTorch's aten/src/ATen/CMakeLists.txt
return [ return [
self.define("DISABLE_FFTW", True), self.define("BUILD_SHARED_LIBS", False),
self.define("DISABLE_MPFR", True), self.define("BUILD_DFT", False),
self.define("DISABLE_SSL", True), self.define("BUILD_GNUABI_LIBS", False),
self.define("BUILD_TESTS", False),
] ]