From 606a0ace677caabe6ed5c1af83378fdd65dcb339 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Mon, 30 Sep 2024 16:43:43 -0400 Subject: [PATCH 1/8] Use nvcomp wheel instead of bundling nvcomp Contributes to https://github.com/rapdisai/build-planning/issues/74 --- dependencies.yaml | 26 +++++++++++++++++++----- python/kvikio/CMakeLists.txt | 7 ------- python/kvikio/kvikio/_lib/CMakeLists.txt | 8 ++++++++ python/kvikio/pyproject.toml | 1 + 4 files changed, 30 insertions(+), 12 deletions(-) diff --git a/dependencies.yaml b/dependencies.yaml index 7f1adc8c14..7f0509628a 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -39,29 +39,30 @@ files: - cuda_version - docs - py_version - py_build: + py_build_kvikio: output: pyproject pyproject_dir: python/kvikio extras: table: build-system includes: - rapids_build_skbuild - py_build_cpp_wheel: + py_build_libkvikio: output: pyproject pyproject_dir: python/libkvikio extras: table: build-system includes: - rapids_build_skbuild - py_run: + py_run_kvikio: output: pyproject pyproject_dir: python/kvikio extras: table: project includes: - depends_on_cupy + - depends_on_nvcomp - run - py_wheel_cpp: + py_rapids_build_libkvikio: output: pyproject pyproject_dir: python/libkvikio extras: @@ -69,7 +70,7 @@ files: key: requires includes: - build-universal - py_wheel_python: + py_rapids_build_kvikio: output: pyproject pyproject_dir: python/kvikio extras: @@ -262,6 +263,21 @@ dependencies: packages: &cupy_packages_cu11 - cupy-cuda11x>=12.0.0 - {matrix: null, packages: *cupy_packages_cu11} + depends_on_nvcomp: + specific: + - output_types: [requirements, pyproject] + matrices: + - matrix: + cuda: "12.*" + packages: + - nvidia-nvcomp-cu12==4.0.1 + - matrix: + cuda: "11.*" + packages: + - nvidia-nvcomp-cu11==4.0.1 + - matrix: + packages: + - nvidia-nvcomp==4.0.1 docs: common: - output_types: [conda, requirements] diff --git a/python/kvikio/CMakeLists.txt b/python/kvikio/CMakeLists.txt index 2b9278fcd1..cbfa333133 100644 --- a/python/kvikio/CMakeLists.txt +++ b/python/kvikio/CMakeLists.txt @@ -40,11 +40,4 @@ add_subdirectory(cmake) set(cython_lib_dir kvikio) -# It would be better to factor nvcomp out into its own wheel. Until that is available, we vendor it -# here. -install_aliased_imported_targets( - TARGETS nvcomp::nvcomp nvcomp::nvcomp_gdeflate nvcomp::nvcomp_bitcomp DESTINATION - ${cython_lib_dir}/_lib -) - add_subdirectory(kvikio/_lib) diff --git a/python/kvikio/kvikio/_lib/CMakeLists.txt b/python/kvikio/kvikio/_lib/CMakeLists.txt index c77d8e3df1..2746f9398c 100644 --- a/python/kvikio/kvikio/_lib/CMakeLists.txt +++ b/python/kvikio/kvikio/_lib/CMakeLists.txt @@ -22,3 +22,11 @@ rapids_cython_create_modules( SOURCE_FILES "${cython_modules}" LINKED_LIBRARIES kvikio::kvikio nvcomp::nvcomp ) +set(rpaths "$ORIGIN/../../nvidia/nvcomp") +foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_property( + TARGET ${tgt} + PROPERTY INSTALL_RPATH ${rpaths} + APPEND + ) +endforeach() diff --git a/python/kvikio/pyproject.toml b/python/kvikio/pyproject.toml index d58dce2cdf..e958b9fb36 100644 --- a/python/kvikio/pyproject.toml +++ b/python/kvikio/pyproject.toml @@ -22,6 +22,7 @@ dependencies = [ "cupy-cuda11x>=12.0.0", "numcodecs !=0.12.0", "numpy>=1.23,<3.0a0", + "nvidia-nvcomp==4.0.1", "packaging", "zarr", ] # This list was generated by `rapids-dependency-file-generator`. To make changes, edit ../../dependencies.yaml and run `rapids-dependency-file-generator`. From 128c2a57968e893e799b626bf1d763187f690f7c Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Mon, 30 Sep 2024 16:51:10 -0400 Subject: [PATCH 2/8] Make rpath usage configurable --- ci/build_wheel_python.sh | 1 + python/kvikio/CMakeLists.txt | 2 ++ python/kvikio/kvikio/_lib/CMakeLists.txt | 18 ++++++++++-------- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index a75ef5b08b..f93b84528e 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -24,6 +24,7 @@ cd "${package_dir}" echo "libkvikio-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo ${CPP_WHEELHOUSE}/libkvikio_*.whl)" > ./constraints.txt PIP_CONSTRAINT="${PWD}/constraints.txt" \ +SKBUILD_CMAKE_ARGS="-DUSE_CUDA_NVCOMP_WHEEL=ON" \ python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check mkdir -p final_dist diff --git a/python/kvikio/CMakeLists.txt b/python/kvikio/CMakeLists.txt index cbfa333133..f735aac702 100644 --- a/python/kvikio/CMakeLists.txt +++ b/python/kvikio/CMakeLists.txt @@ -26,6 +26,8 @@ project( LANGUAGES CXX CUDA ) +option(USE_CUDA_NVCOMP_WHEEL "Use the CUDA nvcomp wheel instead of the system library" OFF) + # TODO: Should we symlink FindcuFile.cmake into python/cmake? find cuFile include(../../cpp/cmake/Modules/FindcuFile.cmake) diff --git a/python/kvikio/kvikio/_lib/CMakeLists.txt b/python/kvikio/kvikio/_lib/CMakeLists.txt index 2746f9398c..0781c41827 100644 --- a/python/kvikio/kvikio/_lib/CMakeLists.txt +++ b/python/kvikio/kvikio/_lib/CMakeLists.txt @@ -22,11 +22,13 @@ rapids_cython_create_modules( SOURCE_FILES "${cython_modules}" LINKED_LIBRARIES kvikio::kvikio nvcomp::nvcomp ) -set(rpaths "$ORIGIN/../../nvidia/nvcomp") -foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) - set_property( - TARGET ${tgt} - PROPERTY INSTALL_RPATH ${rpaths} - APPEND - ) -endforeach() +if(USE_CUDA_NVCOMP_WHEEL) + set(rpaths "$ORIGIN/../../nvidia/nvcomp") + foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) + set_property( + TARGET ${tgt} + PROPERTY INSTALL_RPATH ${rpaths} + APPEND + ) + endforeach() +endif() From 373cde73767c1706b17d5fc3efe60809f69b20ac Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Mon, 30 Sep 2024 17:03:30 -0400 Subject: [PATCH 3/8] Fix auditwheel --- ci/build_wheel_python.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index f93b84528e..1497ddf699 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -28,6 +28,6 @@ SKBUILD_CMAKE_ARGS="-DUSE_CUDA_NVCOMP_WHEEL=ON" \ python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check mkdir -p final_dist -python -m auditwheel repair -w final_dist dist/* +python -m auditwheel repair -w final_dist --exclude libnvcomp.so.4 dist/* RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 final_dist From 8d498c8cca416359a6f1d0a5d9caccf08cf43ae5 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 1 Oct 2024 09:48:22 -0400 Subject: [PATCH 4/8] Review feedback --- ci/build_wheel_python.sh | 5 ++++- dependencies.yaml | 9 +++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 1497ddf699..994e718773 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -28,6 +28,9 @@ SKBUILD_CMAKE_ARGS="-DUSE_CUDA_NVCOMP_WHEEL=ON" \ python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check mkdir -p final_dist -python -m auditwheel repair -w final_dist --exclude libnvcomp.so.4 dist/* +python -m auditwheel repair \ + --exclude libnvcomp.so.4 \ + -w final_dist \ + dist/* RAPIDS_PY_WHEEL_NAME="${package_name}_${RAPIDS_PY_CUDA_SUFFIX}" rapids-upload-wheels-to-s3 final_dist diff --git a/dependencies.yaml b/dependencies.yaml index 7f0509628a..0782ff08a4 100644 --- a/dependencies.yaml +++ b/dependencies.yaml @@ -13,6 +13,7 @@ files: - cuda - cuda_version - depends_on_cupy + - depends_on_nvcomp - docs - py_version - rapids_build_skbuild @@ -198,10 +199,6 @@ dependencies: packages: - cuda-version=12.5 cuda: - common: - - output_types: conda - packages: - - nvcomp==4.0.1 specific: - output_types: conda matrices: @@ -264,6 +261,10 @@ dependencies: - cupy-cuda11x>=12.0.0 - {matrix: null, packages: *cupy_packages_cu11} depends_on_nvcomp: + common: + - output_types: conda + packages: + - nvcomp==4.0.1 specific: - output_types: [requirements, pyproject] matrices: From c3ba6737fa0478b17633225b4567f81409a2a83d Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 1 Oct 2024 12:41:44 -0400 Subject: [PATCH 5/8] Update variable name --- ci/build_wheel_python.sh | 2 +- python/kvikio/CMakeLists.txt | 2 +- python/kvikio/kvikio/_lib/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index 994e718773..e58228e850 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -24,7 +24,7 @@ cd "${package_dir}" echo "libkvikio-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo ${CPP_WHEELHOUSE}/libkvikio_*.whl)" > ./constraints.txt PIP_CONSTRAINT="${PWD}/constraints.txt" \ -SKBUILD_CMAKE_ARGS="-DUSE_CUDA_NVCOMP_WHEEL=ON" \ +SKBUILD_CMAKE_ARGS="-DUSE_NVCOMP_WHEEL=ON" \ python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check mkdir -p final_dist diff --git a/python/kvikio/CMakeLists.txt b/python/kvikio/CMakeLists.txt index f735aac702..543c51fee5 100644 --- a/python/kvikio/CMakeLists.txt +++ b/python/kvikio/CMakeLists.txt @@ -26,7 +26,7 @@ project( LANGUAGES CXX CUDA ) -option(USE_CUDA_NVCOMP_WHEEL "Use the CUDA nvcomp wheel instead of the system library" OFF) +option(USE_NVCOMP_WHEEL "Use the CUDA nvcomp wheel instead of the system library" OFF) # TODO: Should we symlink FindcuFile.cmake into python/cmake? find cuFile include(../../cpp/cmake/Modules/FindcuFile.cmake) diff --git a/python/kvikio/kvikio/_lib/CMakeLists.txt b/python/kvikio/kvikio/_lib/CMakeLists.txt index 0781c41827..c21c59727c 100644 --- a/python/kvikio/kvikio/_lib/CMakeLists.txt +++ b/python/kvikio/kvikio/_lib/CMakeLists.txt @@ -22,7 +22,7 @@ rapids_cython_create_modules( SOURCE_FILES "${cython_modules}" LINKED_LIBRARIES kvikio::kvikio nvcomp::nvcomp ) -if(USE_CUDA_NVCOMP_WHEEL) +if(USE_NVCOMP_WHEEL) set(rpaths "$ORIGIN/../../nvidia/nvcomp") foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) set_property( From caed5d6f5447302e735dbecf14d0e5b242545fad Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 1 Oct 2024 12:42:59 -0400 Subject: [PATCH 6/8] Update description --- python/kvikio/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/kvikio/CMakeLists.txt b/python/kvikio/CMakeLists.txt index 543c51fee5..4e9abe35cb 100644 --- a/python/kvikio/CMakeLists.txt +++ b/python/kvikio/CMakeLists.txt @@ -26,7 +26,7 @@ project( LANGUAGES CXX CUDA ) -option(USE_NVCOMP_WHEEL "Use the CUDA nvcomp wheel instead of the system library" OFF) +option(USE_NVCOMP_WHEEL "Use the nvcomp wheel instead of the system library" OFF) # TODO: Should we symlink FindcuFile.cmake into python/cmake? find cuFile include(../../cpp/cmake/Modules/FindcuFile.cmake) From 78bc4c258ee7e35c6f3b7da928d9243c15a67dc5 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 1 Oct 2024 13:18:05 -0400 Subject: [PATCH 7/8] Update description --- python/kvikio/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/kvikio/CMakeLists.txt b/python/kvikio/CMakeLists.txt index 4e9abe35cb..0c6c740f22 100644 --- a/python/kvikio/CMakeLists.txt +++ b/python/kvikio/CMakeLists.txt @@ -26,7 +26,7 @@ project( LANGUAGES CXX CUDA ) -option(USE_NVCOMP_WHEEL "Use the nvcomp wheel instead of the system library" OFF) +option(USE_NVCOMP_WHEEL "Use the nvcomp wheel at runtime instead of the system library" OFF) # TODO: Should we symlink FindcuFile.cmake into python/cmake? find cuFile include(../../cpp/cmake/Modules/FindcuFile.cmake) From 003eae675d58b643410578645bd5ef0903576a93 Mon Sep 17 00:00:00 2001 From: Kyle Edwards Date: Tue, 1 Oct 2024 13:21:54 -0400 Subject: [PATCH 8/8] Update variable name --- ci/build_wheel_python.sh | 2 +- python/kvikio/CMakeLists.txt | 2 +- python/kvikio/kvikio/_lib/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/build_wheel_python.sh b/ci/build_wheel_python.sh index e58228e850..65ac10e5a3 100755 --- a/ci/build_wheel_python.sh +++ b/ci/build_wheel_python.sh @@ -24,7 +24,7 @@ cd "${package_dir}" echo "libkvikio-${RAPIDS_PY_CUDA_SUFFIX} @ file://$(echo ${CPP_WHEELHOUSE}/libkvikio_*.whl)" > ./constraints.txt PIP_CONSTRAINT="${PWD}/constraints.txt" \ -SKBUILD_CMAKE_ARGS="-DUSE_NVCOMP_WHEEL=ON" \ +SKBUILD_CMAKE_ARGS="-DUSE_NVCOMP_RUNTIME_WHEEL=ON" \ python -m pip wheel . -w dist -vvv --no-deps --disable-pip-version-check mkdir -p final_dist diff --git a/python/kvikio/CMakeLists.txt b/python/kvikio/CMakeLists.txt index 0c6c740f22..4e40e86fa6 100644 --- a/python/kvikio/CMakeLists.txt +++ b/python/kvikio/CMakeLists.txt @@ -26,7 +26,7 @@ project( LANGUAGES CXX CUDA ) -option(USE_NVCOMP_WHEEL "Use the nvcomp wheel at runtime instead of the system library" OFF) +option(USE_NVCOMP_RUNTIME_WHEEL "Use the nvcomp wheel at runtime instead of the system library" OFF) # TODO: Should we symlink FindcuFile.cmake into python/cmake? find cuFile include(../../cpp/cmake/Modules/FindcuFile.cmake) diff --git a/python/kvikio/kvikio/_lib/CMakeLists.txt b/python/kvikio/kvikio/_lib/CMakeLists.txt index c21c59727c..74a6f6562f 100644 --- a/python/kvikio/kvikio/_lib/CMakeLists.txt +++ b/python/kvikio/kvikio/_lib/CMakeLists.txt @@ -22,7 +22,7 @@ rapids_cython_create_modules( SOURCE_FILES "${cython_modules}" LINKED_LIBRARIES kvikio::kvikio nvcomp::nvcomp ) -if(USE_NVCOMP_WHEEL) +if(USE_NVCOMP_RUNTIME_WHEEL) set(rpaths "$ORIGIN/../../nvidia/nvcomp") foreach(tgt IN LISTS RAPIDS_CYTHON_CREATED_TARGETS) set_property(