gnu: python-pytorch-for-r-torch: Update to 2.0.1.

* gnu/packages/machine-learning.scm (python-pytorch-for-r-torch): Update to 2.0.1.
* gnu/packages/patches/python-pytorch2-system-libraries.patch: New file.
* gnu/local.mk (dist_patch_DATA): Add it.

Change-Id: I97551d543e50f6e511aa0529c097d156cf3f96de
This commit is contained in:
Ricardo Wurmus 2023-12-27 23:32:21 +01:00
parent 6055bb3163
commit 1e5faccecd
No known key found for this signature in database
GPG key ID: 197A5888235FACAC
3 changed files with 210 additions and 1 deletions

View file

@ -1777,6 +1777,7 @@ dist_patch_DATA = \
%D%/packages/patches/python-random2-getrandbits-test.patch \
%D%/packages/patches/python-poppler-qt5-fix-build.patch \
%D%/packages/patches/python-pypdf-annotate-tests-appropriately.patch \
%D%/packages/patches/python-pytorch2-system-libraries.patch \
%D%/packages/patches/python-sip-include-dirs.patch \
%D%/packages/patches/python-sgmllib3k-assertions.patch \
%D%/packages/patches/python-sphinx-prompt-docutils-0.19.patch \

View file

@ -4085,7 +4085,59 @@ (define-public python-pytorch
Note: currently this package does not provide GPU support.")
(license license:bsd-3)))
(define-public python-pytorch-for-r-torch python-pytorch)
(define-public python-pytorch-for-r-torch
(package
(inherit python-pytorch)
(name "python-pytorch")
(version "2.0.1")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/pytorch/pytorch")
(commit (string-append "v" version))
(recursive? #t)))
(file-name (git-file-name name version))
(sha256
(base32
"14m7v54zyd2qg2xk9mqdpbf4ps7091mdzinzh4vq9p5k4bpznj65"))
(patches (search-patches "python-pytorch2-system-libraries.patch"
"python-pytorch-runpath.patch"))
(modules '((guix build utils)))
(snippet
'(begin
;; XXX: Let's be clear: this package is a bundling fest. We
;; delete as much as we can, but there's still a lot left.
(for-each (lambda (directory)
(delete-file-recursively
(string-append "third_party/" directory)))
'("benchmark" "cpuinfo" "eigen"
;; FIXME: QNNPACK (of which XNNPACK is a fork)
;; needs these.
;; "FP16" "FXdiv" "gemmlowp" "psimd"
"gloo" "googletest" "ios-cmake" "NNPACK"
"onnx" "protobuf" "pthreadpool"
"pybind11" "python-enum" "python-peachpy"
"python-six" "tbb" "XNNPACK" "zstd"))
(substitute* "caffe2/CMakeLists.txt"
(("target_link_libraries\\(\\$\\{test_name\\}_\\$\\{CPU_CAPABILITY\\} c10 sleef gtest_main\\)")
"target_link_libraries(${test_name}_${CPU_CAPABILITY} c10 sleef gtest gtest_main)"))
(substitute* "functorch/CMakeLists.txt"
(("\\$\\{_rpath_portable_origin\\}/../torch/lib")
"$ORIGIN/../torch/lib"))))))
(inputs
(modify-inputs (package-inputs python-pytorch)
(replace "xnnpack" xnnpack-for-torch2)))
(propagated-inputs
(modify-inputs (package-propagated-inputs python-pytorch)
(append python-filelock
python-jinja2
python-networkx
python-opt-einsum
python-sympy)
(replace "onnx" onnx-for-torch2)
(replace "onnx-optimizer" onnx-optimizer-for-torch2)))))
(define-public python-lightning-cloud
(package

View file

@ -0,0 +1,156 @@
Use our own googletest rather than the bundled one.
Get NNPACK to use our own PeachPy rather than the bundled one.
diff --git a/caffe2/CMakeLists.txt b/caffe2/CMakeLists.txt
--- a/caffe2/CMakeLists.txt 2023-12-27 12:14:24.308751288 +0100
+++ b/caffe2/CMakeLists.txt 2023-12-27 12:30:15.941562126 +0100
@@ -1570,7 +1570,7 @@
add_executable(static_runtime_bench "${STATIC_RUNTIME_BENCHMARK_SRCS}")
add_executable(static_runtime_test "${STATIC_RUNTIME_TEST_SRCS}")
target_link_libraries(static_runtime_bench torch_library benchmark)
- target_link_libraries(static_runtime_test torch_library gtest_main)
+ target_link_libraries(static_runtime_test torch_library gtest_main gtest)
endif()
if(BUILD_TENSOREXPR_BENCHMARK)
@@ -1601,7 +1601,7 @@
foreach(test_src ${ATen_MOBILE_TEST_SRCS})
get_filename_component(test_name ${test_src} NAME_WE)
add_executable(${test_name} "${test_src}")
- target_link_libraries(${test_name} torch_library gtest_main)
+ target_link_libraries(${test_name} torch_library gtest_main gtest)
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 ${ATen_CPU_INCLUDE})
@@ -1628,7 +1628,7 @@
endif()
else()
add_executable(${test_name}_${CPU_CAPABILITY} "${test_src}")
- target_link_libraries(${test_name}_${CPU_CAPABILITY} torch_library gtest_main)
+ target_link_libraries(${test_name}_${CPU_CAPABILITY} torch_library gtest_main gtest)
endif()
target_include_directories(${test_name}_${CPU_CAPABILITY} PRIVATE $<INSTALL_INTERFACE:include>)
target_include_directories(${test_name}_${CPU_CAPABILITY} PRIVATE $<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>)
@@ -1645,7 +1645,7 @@
foreach(test_src ${Caffe2_CPU_TEST_SRCS})
get_filename_component(test_name ${test_src} NAME_WE)
add_executable(${test_name} "${test_src}")
- target_link_libraries(${test_name} torch_library gtest_main)
+ target_link_libraries(${test_name} torch_library gtest_main gtest)
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})
@@ -1666,7 +1666,7 @@
foreach(test_src ${Caffe2_MPS_TEST_SRCS})
get_filename_component(test_name ${test_src} NAME_WE)
add_executable(${test_name} "${test_src}")
- target_link_libraries(${test_name} torch_library gtest_main)
+ target_link_libraries(${test_name} torch_library gtest_main gtest)
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})
diff --git a/cmake/Dependencies.cmake b/cmake/Dependencies.cmake
index 557ab649..ee9cf410 100644
--- a/cmake/Dependencies.cmake
+++ b/cmake/Dependencies.cmake
@@ -732,11 +732,6 @@ if(BUILD_TEST OR BUILD_MOBILE_BENCHMARK OR BUILD_MOBILE_TEST)
# this shouldn't be necessary anymore.
get_property(INC_DIR_temp DIRECTORY PROPERTY INCLUDE_DIRECTORIES)
set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES "")
- add_subdirectory(${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest)
- set_property(DIRECTORY PROPERTY INCLUDE_DIRECTORIES ${INC_DIR_temp})
-
- include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googletest/include)
- include_directories(BEFORE SYSTEM ${CMAKE_CURRENT_LIST_DIR}/../third_party/googletest/googlemock/include)
# We will not need to test benchmark lib itself.
set(BENCHMARK_ENABLE_TESTING OFF CACHE BOOL "Disable benchmark testing as we don't need it.")
@@ -1543,7 +1538,7 @@ if(CAFFE2_CMAKE_BUILDING_WITH_MAIN_REPO AND NOT INTERN_DISABLE_ONNX)
endif()
set_property(TARGET onnx_proto PROPERTY IMPORTED_LOCATION ${ONNX_PROTO_LIBRARY})
message("-- Found onnx: ${ONNX_LIBRARY} ${ONNX_PROTO_LIBRARY}")
- list(APPEND Caffe2_DEPENDENCY_LIBS onnx_proto onnx)
+ list(APPEND Caffe2_DEPENDENCY_LIBS onnx_proto onnx onnx_optimizer)
endif()
include_directories(${FOXI_INCLUDE_DIRS})
list(APPEND Caffe2_DEPENDENCY_LIBS foxi_loader)
diff --git a/cmake/External/nnpack.cmake b/cmake/External/nnpack.cmake
index a41343cb..6075bdd0 100644
--- a/cmake/External/nnpack.cmake
+++ b/cmake/External/nnpack.cmake
@@ -40,7 +40,7 @@ endif()
# (3) Android, iOS, Linux, macOS - supported
##############################################################################
-if(ANDROID OR IOS OR ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" OR ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
+if(FALSE)
message(STATUS "Brace yourself, we are building NNPACK")
set(CAFFE2_THIRD_PARTY_ROOT ${PROJECT_SOURCE_DIR}/third_party)
@@ -114,6 +114,5 @@ endif()
# (4) Catch-all: not supported.
##############################################################################
-message(WARNING "Unknown platform - I don't know how to build NNPACK. "
- "See cmake/External/nnpack.cmake for details.")
-set(USE_NNPACK OFF)
+set(NNPACK_FOUND TRUE)
+set(USE_NNPACK ON)
diff --git a/test/cpp/c10d/CMakeLists.txt b/test/cpp/c10d/CMakeLists.txt
index bf91460c..ef56948f 100644
--- a/test/cpp/c10d/CMakeLists.txt
+++ b/test/cpp/c10d/CMakeLists.txt
@@ -16,14 +16,14 @@ function(c10d_add_test test_src)
add_test(NAME ${test_name} COMMAND $<TARGET_FILE:${test_name}>)
endfunction()
-c10d_add_test(FileStoreTest.cpp torch_cpu gtest_main)
-c10d_add_test(TCPStoreTest.cpp torch_cpu gtest_main)
+c10d_add_test(FileStoreTest.cpp torch_cpu gtest_main gtest)
+c10d_add_test(TCPStoreTest.cpp torch_cpu gtest_main gtest)
if(INSTALL_TEST)
install(TARGETS FileStoreTest DESTINATION bin)
install(TARGETS TCPStoreTest DESTINATION bin)
endif()
if(NOT WIN32)
- c10d_add_test(HashStoreTest.cpp torch_cpu gtest_main)
+ c10d_add_test(HashStoreTest.cpp torch_cpu gtest_main gtest)
if(INSTALL_TEST)
install(TARGETS HashStoreTest DESTINATION bin)
endif()
@@ -31,11 +31,11 @@ endif()
if(USE_CUDA)
if(USE_GLOO AND USE_C10D_GLOO)
- c10d_add_test(ProcessGroupGlooTest.cpp torch_cpu c10d_cuda_test gtest_main)
+ c10d_add_test(ProcessGroupGlooTest.cpp torch_cpu c10d_cuda_test gtest_main gtest)
if(INSTALL_TEST)
install(TARGETS ProcessGroupGlooTest DESTINATION bin)
endif()
- c10d_add_test(ProcessGroupGlooAsyncTest.cpp torch_cpu c10d_cuda_test gtest_main)
+ c10d_add_test(ProcessGroupGlooAsyncTest.cpp torch_cpu c10d_cuda_test gtest_main gtest)
endif()
if(USE_NCCL AND USE_C10D_NCCL)
# NCCL is a private dependency of libtorch, but the tests include some
@@ -56,7 +56,7 @@ if(USE_CUDA)
endif()
else()
if(USE_GLOO AND USE_C10D_GLOO)
- c10d_add_test(ProcessGroupGlooTest.cpp torch_cpu gtest_main)
+ c10d_add_test(ProcessGroupGlooTest.cpp torch_cpu gtest_main gtest)
endif()
endif()
diff --git a/test/cpp/tensorexpr/CMakeLists.txt b/test/cpp/tensorexpr/CMakeLists.txt
index 8fc5a0a1..643202f6 100644
--- a/test/cpp/tensorexpr/CMakeLists.txt
+++ b/test/cpp/tensorexpr/CMakeLists.txt
@@ -53,7 +53,7 @@ target_include_directories(tutorial_tensorexpr PRIVATE ${ATen_CPU_INCLUDE})
# pthreadpool header. For some build environment we need add the dependency
# explicitly.
if(USE_PTHREADPOOL)
- target_link_libraries(test_tensorexpr PRIVATE pthreadpool_interface)
+ target_link_libraries(test_tensorexpr PRIVATE pthreadpool)
endif()
if(USE_CUDA)
target_link_libraries(test_tensorexpr PRIVATE