Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions .github/workflows/gpuzipy-wheels.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
name: GPUZIPy wheels

# Builds manylinux CUDA 12 wheels for GPUZIPy (no GPU needed to compile).
# - Manual run / PRs touching the bindings: build only, wheels kept as workflow artifacts.
# - Tag "gpuzipy-v*" (e.g. gpuzipy-v0.0.1): build, attach to a GitHub Release, publish to PyPI.
# The tag must match the version in GPUZIPy/setup.py.

on:
workflow_dispatch:
pull_request:
paths:
- "GPUZIPy/**"
- "src/Compressor/**"
- ".github/workflows/gpuzipy-wheels.yml"
push:
tags:
- "gpuzipy-v*"

jobs:
wheels:
name: Wheel ${{ matrix.python }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: [cp310, cp311, cp312, cp313]
steps:
- uses: actions/checkout@v4

# cibuildwheel copies the whole repo into the container; GPUZIPy's CMake build
# reads ../src/Compressor from there.
- uses: pypa/cibuildwheel@v2.23.3
with:
package-dir: GPUZIPy
output-dir: wheelhouse
env:
CIBW_BUILD: ${{ matrix.python }}-manylinux_x86_64

- uses: actions/upload-artifact@v4
with:
name: wheel-${{ matrix.python }}
path: wheelhouse/*.whl

sdist:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: pipx run build --sdist --outdir dist GPUZIPy
- uses: actions/upload-artifact@v4
with:
name: sdist
path: dist/*.tar.gz

release:
if: startsWith(github.ref, 'refs/tags/gpuzipy-v')
needs: [wheels, sdist]
runs-on: ubuntu-latest
environment: pypi
permissions:
contents: write # GitHub Release
id-token: write # PyPI trusted publishing
steps:
- uses: actions/download-artifact@v4
with:
path: dist
merge-multiple: true

- uses: softprops/action-gh-release@v2
with:
files: dist/*

- uses: pypa/gh-action-pypi-publish@release/v1
24 changes: 18 additions & 6 deletions GPUZIPy/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ set(BUILD_CUDA ON CACHE BOOL "Build cuszp with CUDA support")
FetchContent_Declare(
cuszp
GIT_REPOSITORY https://github.com/szcompressor/cuSZp.git
GIT_TAG cuSZp-V3.0.0
GIT_TAG master
)
FetchContent_MakeAvailable(cuszp)

Expand Down Expand Up @@ -85,18 +85,32 @@ find_package(nvcomp REQUIRED)
find_package(pybind11 CONFIG REQUIRED)
include_directories(${ZFP_SOURCE_DIR}/include ${NVCOMP_SRC_DIR}/include)

# GPUZIP's compressor sources. In a git checkout they live in ../src; in an sdist,
# setup.py copies them into ./gpuzip_src (see its sdist command).
if (EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../src/Compressor)
set(GPUZIP_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../src)
else()
set(GPUZIP_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/gpuzip_src)
endif()

# cuda_utils.cu: GPU min/max/mean/std reductions used by CompressorBitcomp/CompressorCuSZp.
# Declared in src/Compressor/include/cuda_utils.hpp but defined separately, so it must be
# compiled and linked in explicitly (it is not part of the header-only Compressor include tree).
add_library(gpuzip_cuda_utils STATIC
${CMAKE_CURRENT_SOURCE_DIR}/../src/Compressor/cuda_utils.cu)
${GPUZIP_SRC_DIR}/Compressor/cuda_utils.cu)
target_include_directories(gpuzip_cuda_utils PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/../src/Compressor/include
${GPUZIP_SRC_DIR}/Compressor/include
${CUDAToolkit_INCLUDE_DIRS})
target_link_libraries(gpuzip_cuda_utils PUBLIC Thrust)

pybind11_add_module(gpuzipy ./csrc/gpuzipy.cpp)
target_include_directories(gpuzipy PRIVATE ${CUDAToolkit_INCLUDE_DIRS})
# Only the extension module goes to setup.py's output dir. zfp/cuSZp/nvcomp shared
# libraries stay in the build tree (found via the build RPATH); when building release
# wheels, auditwheel copies them into the wheel.
if (DEFINED GPUZIPY_OUTPUT_DIR)
set_target_properties(gpuzipy PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${GPUZIPY_OUTPUT_DIR})
endif()
# cuSZp_shared, not cuSZp_static: cuSZp is built with relocatable device code, and
# gpuzipy (a pybind11 MODULE target with no .cu sources of its own) can't reliably
# get CMake's device-link step to resolve it. cuSZp_shared is a real CUDA SHARED
Expand All @@ -106,9 +120,7 @@ target_link_libraries(gpuzipy
gpuzip_cuda_utils
zfp::zfp
cuSZp_shared
nvcomp::nvcomp
-lcuda
-lcusparse)
nvcomp::nvcomp)

target_compile_definitions(gpuzipy
PRIVATE VERSION_INFO=${VERSION_INFO})
32 changes: 24 additions & 8 deletions GPUZIPy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,30 @@ Input/output buffers are raw GPU device pointers (e.g. from [CuPy](https://cupy.

> **Note:** Only the `Compressor` component is bound to Python. GPUZIP's `Prefetch`/checkpointing layer is C++/CUDA only.

## Requirements
## Install

Prebuilt wheels (Linux x86_64, Python 3.10-3.13, CUDA 12, GPUs from Volta/sm_70 to Hopper/sm_90):

```sh
pip install gpuzipy
```

Only an NVIDIA driver supporting CUDA 12 is needed; nvcomp (Bitcomp), cuZFP and cuSZp are bundled.

This package has no prebuilt wheels: installing it compiles NVIDIA Bitcomp (nvcomp), cuZFP,
and cuSZp against your local CUDA toolkit.
### Build from source

- NVIDIA CUDA and NVCC (nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2023 NVIDIA Corporation Built on Tue_Aug_15_22:02:13_PDT_2023 Cuda compilation tools, release 12.2, V12.2.140 Build cuda_12.2.r12.2/compiler.33191640_0)
Compiles NVIDIA Bitcomp (nvcomp), cuZFP, and cuSZp against your local CUDA toolkit.

- NVIDIA CUDA and NVCC (tested with CUDA 12.2)
- CMake >= 3.22
- Internet access at install time (build-time dependencies are fetched automatically: Thrust, ZFP, cuSZp, nvcomp)

```sh
pip install .
```

Set `CMAKE_ARGS="-DCMAKE_CUDA_ARCHITECTURES=native"` to compile only for the local GPU.

## Run the examples with Docker

```sh
Expand All @@ -34,11 +49,12 @@ The container is removed after it exits (`--rm`), so without that volume mount t
rendered PSNR/SSIM slice comparisons in `example/output/` would be lost along with it.
With it, results land directly in `GPUZIPy/example/output/` on the host.

## Install
## Releasing wheels

```sh
pip install .
```
`.github/workflows/gpuzipy-wheels.yml` builds the wheels with cibuildwheel (config in
`pyproject.toml`). Bump `version` in `setup.py`, then push a matching tag, e.g.
`git tag gpuzipy-v0.0.2 && git push origin gpuzipy-v0.0.2`, to publish a GitHub Release and
upload to PyPI.

## License

Expand Down
6 changes: 3 additions & 3 deletions GPUZIPy/csrc/gpuzipy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
* @date Feb 24, 2024
*/
#include <pybind11/pybind11.h>
#include "../../src/Compressor/include/CompressorZFP.hpp"
#include "../../src/Compressor/include/CompressorBitcomp.hpp"
#include "../../src/Compressor/include/CompressorCuSZp.hpp"
#include "CompressorZFP.hpp"
#include "CompressorBitcomp.hpp"
#include "CompressorCuSZp.hpp"

#define STRINGIFY(x) #x
#define MACRO_STRINGIFY(x) STRINGIFY(x)
Expand Down
69 changes: 6 additions & 63 deletions GPUZIPy/example/GPUZIPy_Example.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -13,78 +13,21 @@
},
{
"cell_type": "code",
"execution_count": 1,
"execution_count": null,
"metadata": {
"colab": {
"base_uri": "https://localhost:8080/"
},
"id": "IlF2wBWpUY38",
"outputId": "6793eb04-80df-4482-d93e-a66b7f623fac"
},
"outputs": [
{
"output_type": "stream",
"name": "stdout",
"text": [
"\r0% [Working]\r \rGet:1 https://cli.github.com/packages stable InRelease [3,917 B]\n",
"\r0% [Connecting to archive.ubuntu.com] [Connecting to security.ubuntu.com] [Conn\r \rHit:2 https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/ InRelease\n",
"Hit:3 https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64 InRelease\n",
"Err:1 https://cli.github.com/packages stable InRelease\n",
" The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5612B36462313325\n",
"Hit:4 https://r2u.stat.illinois.edu/ubuntu jammy InRelease\n",
"Hit:5 http://archive.ubuntu.com/ubuntu jammy InRelease\n",
"Hit:6 http://archive.ubuntu.com/ubuntu jammy-updates InRelease\n",
"Hit:7 http://security.ubuntu.com/ubuntu jammy-security InRelease\n",
"Hit:8 http://archive.ubuntu.com/ubuntu jammy-backports InRelease\n",
"Hit:9 https://ppa.launchpadcontent.net/deadsnakes/ppa/ubuntu jammy InRelease\n",
"Hit:10 https://ppa.launchpadcontent.net/graphics-drivers/ppa/ubuntu jammy InRelease\n",
"Hit:11 https://ppa.launchpadcontent.net/ubuntugis/ppa/ubuntu jammy InRelease\n",
"Reading package lists... Done\n",
"W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://cli.github.com/packages stable InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5612B36462313325\n",
"W: Skipping acquire of configured file 'main/source/Sources' as repository 'https://r2u.stat.illinois.edu/ubuntu jammy InRelease' does not seem to provide it (sources.list entry misspelt?)\n",
"W: Failed to fetch https://cli.github.com/packages/dists/stable/InRelease The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 5612B36462313325\n",
"W: Some index files failed to download. They have been ignored, or old ones used instead.\n",
"Reading package lists... Done\n",
"Building dependency tree... Done\n",
"Reading state information... Done\n",
"build-essential is already the newest version (12.9ubuntu3).\n",
"make is already the newest version (4.3-4.1build1).\n",
"cmake is already the newest version (3.22.1-1ubuntu1.22.04.2).\n",
"git is already the newest version (1:2.34.1-1ubuntu1.18).\n",
"0 upgraded, 0 newly installed, 0 to remove and 288 not upgraded.\n",
"Cloning into 'GPUZIP'...\n",
"remote: Enumerating objects: 198, done.\u001b[K\n",
"remote: Counting objects: 100% (198/198), done.\u001b[K\n",
"remote: Compressing objects: 100% (136/136), done.\u001b[K\n",
"remote: Total 198 (delta 74), reused 147 (delta 42), pack-reused 0 (from 0)\u001b[K\n",
"Receiving objects: 100% (198/198), 1.15 MiB | 3.81 MiB/s, done.\n",
"Resolving deltas: 100% (74/74), done.\n",
"Processing /content/GPUZIP/GPUZIPy\n",
" Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
" Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
" Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
"Building wheels for collected packages: gpuzipy\n",
" Building wheel for gpuzipy (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
" Created wheel for gpuzipy: filename=gpuzipy-0.0.1-cp312-cp312-linux_x86_64.whl size=10605813 sha256=cb0ed729f3e3f07525f6b2daae56f29697c5b5ca78bea173037733918bbe7753\n",
" Stored in directory: /tmp/pip-ephem-wheel-cache-0f3c7s21/wheels/f0/21/a8/41202f76e1f116001d1f2ceccd5a7db6ca2a4a04ca32db84f1\n",
"Successfully built gpuzipy\n",
"Installing collected packages: gpuzipy\n",
" Attempting uninstall: gpuzipy\n",
" Found existing installation: gpuzipy 0.0.1\n",
" Uninstalling gpuzipy-0.0.1:\n",
" Successfully uninstalled gpuzipy-0.0.1\n",
"Successfully installed gpuzipy-0.0.1\n"
]
}
],
"outputs": [],
"source": [
"# Install system dependencies\n",
"!apt-get update\n",
"!apt-get install -y git cmake make build-essential\n",
"# Prebuilt CUDA 12 wheel (Linux x86_64, Python 3.10-3.13): no compilation needed.\n",
"!pip install gpuzipy\n",
"\n",
"!rm -rf GPUZIP/\n",
"!git clone https://github.com/LSC-Unicamp/GPUZIP.git\n",
"!cd GPUZIP/GPUZIPy && pip install ."
"# Alternatively, build from source (~7 min on Colab):\n",
"# !git clone https://github.com/LSC-Unicamp/GPUZIP.git && cd GPUZIP/GPUZIPy && pip install ."
]
},
{
Expand Down
21 changes: 21 additions & 0 deletions GPUZIPy/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
[build-system]
requires = ["setuptools>=64", "wheel", "cmake>=3.22", "pybind11>=2.11"]
build-backend = "setuptools.build_meta"

# Release wheels: built with cibuildwheel inside manylinux_2_28 (AlmaLinux 8) with the
# CUDA toolkit installed. See .github/workflows/gpuzipy-wheels.yml.
[tool.cibuildwheel]
build = "cp310-* cp311-* cp312-* cp313-*"
skip = "*-musllinux_*"
archs = ["x86_64"]
manylinux-x86_64-image = "manylinux_2_28"
build-verbosity = 1

[tool.cibuildwheel.linux]
before-all = [
"dnf install -y dnf-plugins-core",
"dnf config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel8/x86_64/cuda-rhel8.repo",
"dnf install -y cuda-nvcc-12-4 cuda-cudart-devel-12-4 cuda-nvtx-12-4 cuda-cccl-12-4 gcc-toolset-13-gcc-c++",
]
environment = { PATH = "/opt/rh/gcc-toolset-13/root/usr/bin:/usr/local/cuda/bin:$PATH", CC = "/opt/rh/gcc-toolset-13/root/usr/bin/gcc", CXX = "/opt/rh/gcc-toolset-13/root/usr/bin/g++", CUDACXX = "/usr/local/cuda/bin/nvcc", CMAKE_BUILD_PARALLEL_LEVEL = "4", CMAKE_ARGS = "'-DCMAKE_CUDA_ARCHITECTURES=70-real;75-real;80-real;86-real;89-real;90'" }
# GCC 13 toolset first in PATH: CUDA 12.4's nvcc rejects the image's default GCC 14.
# CUDA 12.4 is kept (not 12.8+, which supports GCC 14) so the wheel runs on older drivers.
# libcuda.so.1 is the GPU driver: it must come from the user's system, never the wheel.
repair-wheel-command = "auditwheel repair --exclude libcuda.so.1 -w {dest_dir} {wheel}"
18 changes: 16 additions & 2 deletions GPUZIPy/setup.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import os
import shutil
import subprocess
import sys
from pathlib import Path

import pybind11
from setuptools import Extension, setup
from setuptools.command.build_ext import build_ext
from setuptools.command.sdist import sdist

HERE = Path(__file__).parent.resolve()
LONG_DESCRIPTION = (HERE / "README.md").read_text(encoding="utf-8")
Expand All @@ -28,7 +30,7 @@ def build_extension(self, ext: CMakeExtension) -> None:

build_args = []
cmake_args = [
f"-DCMAKE_LIBRARY_OUTPUT_DIRECTORY={extdir}{os.sep}",
f"-DGPUZIPY_OUTPUT_DIR={extdir}{os.sep}",
f"-DPYTHON_EXECUTABLE={sys.executable}",
f"-DCMAKE_BUILD_TYPE={cfg}",
f"-Dpybind11_DIR={pybind11.get_cmake_dir()}",
Expand Down Expand Up @@ -56,6 +58,18 @@ def build_extension(self, ext: CMakeExtension) -> None:
)


class SDist(sdist):
"""Bundle GPUZIP's compressor sources (../src/Compressor), which live outside this
package directory, so the sdist builds on its own. CMakeLists.txt falls back to
./gpuzip_src when ../src is absent."""

def make_release_tree(self, base_dir, files):
super().make_release_tree(base_dir, files)
src = HERE.parent / "src" / "Compressor"
if src.is_dir():
shutil.copytree(src, Path(base_dir) / "gpuzip_src" / "Compressor")


# The information here can also be placed in setup.cfg - better separation of
# logic and declaration, and simpler if you include description/version in a file.
setup(
Expand Down Expand Up @@ -84,7 +98,7 @@ def build_extension(self, ext: CMakeExtension) -> None:
"Environment :: GPU :: NVIDIA CUDA",
],
ext_modules=[CMakeExtension("gpuzipy")],
cmdclass={"build_ext": CMakeBuild},
cmdclass={"build_ext": CMakeBuild, "sdist": SDist},
zip_safe=False,
extras_require={
"test": ["pytest>=6.0"],
Expand Down
Loading