Skip to main content

KvikIO - GPUDirect Storage

Project description

KvikIO: High Performance File IO

Summary

KvikIO (pronounced "kuh-VICK-eye-oh", see here for pronunciation of kvik) is a Python and C++ library for high performance file IO. It provides C++ and Python bindings to cuFile, which enables GPUDirect Storage (GDS). KvikIO also works efficiently when GDS isn't available and can read/write both host and device data seamlessly.

Features

  • Object oriented API of cuFile with C++/Python exception handling.
  • A Python Zarr backend for reading and writing GPU data to file seamlessly.
  • Concurrent reads and writes using an internal thread pool.
  • Non-blocking API.
  • Transparently handles reads and writes to/from memory on both host and device.
  • Provides Python bindings to nvCOMP.

Documentation

Examples

Python

import cupy
import kvikio

def main(path):
    a = cupy.arange(100)
    f = kvikio.CuFile(path, "w")
    # Write whole array to file
    f.write(a)
    f.close()

    b = cupy.empty_like(a)
    f = kvikio.CuFile(path, "r")
    # Read whole array from file
    f.read(b)
    assert all(a == b)
    f.close()

    # Use contexmanager
    c = cupy.empty_like(a)
    with kvikio.CuFile(path, "r") as f:
        f.read(c)
    assert all(a == c)

    # Non-blocking read
    d = cupy.empty_like(a)
    with kvikio.CuFile(path, "r") as f:
        future1 = f.pread(d[:50])
        future2 = f.pread(d[50:], file_offset=d[:50].nbytes)
        # Note: must wait for futures before exiting block
        # at which point the file is closed.
        future1.get()  # Wait for first read
        future2.get()  # Wait for second read
    assert all(a == d)


if __name__ == "__main__":
    main("/tmp/kvikio-hello-world-file")

C++

#include <cstddef>
#include <future>
#include <cuda_runtime.h>
#include <kvikio/file_handle.hpp>

int main()
{
  // Create two arrays `a` and `b`
  constexpr std::size_t size = 100;
  void *a = nullptr;
  void *b = nullptr;
  cudaMalloc(&a, size);
  cudaMalloc(&b, size);

  // Write `a` to file
  kvikio::FileHandle fw("test-file", "w");
  std::size_t written = fw.write(a, size);
  fw.close();

  // Read file into `b`
  kvikio::FileHandle fr("test-file", "r");
  std::size_t read = fr.read(b, size);
  fr.close();

  // Read file into `b` in parallel using 16 threads
  kvikio::default_thread_pool::reset(16);
  {
    // FileHandles have RAII semantics
    kvikio::FileHandle f("test-file", "r");
    std::future<std::size_t> future = f.pread(b_dev, sizeof(a), 0);  // Non-blocking
    std::size_t read = future.get(); // Blocking
    // Notice, `f` closes automatically on destruction.
  }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

kvikio_cu12-24.12.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

kvikio_cu12-24.12.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

kvikio_cu12-24.12.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

kvikio_cu12-24.12.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

kvikio_cu12-24.12.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl (1.1 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ x86-64manylinux: glibc 2.28+ x86-64

kvikio_cu12-24.12.0-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl (1.0 MB view details)

Uploaded CPython 3.10manylinux: glibc 2.27+ ARM64manylinux: glibc 2.28+ ARM64

File details

Details for the file kvikio_cu12-24.12.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-24.12.0-cp312-cp312-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2b35b5ab43429284702393a9b48fe30ec13ef8d280b3289f187d8492d41478c6
MD5 ef712e8ff5799d318af1c1882db896e3
BLAKE2b-256 0ff7e35b9865393d15d7e37e11cb309efe47f06561ad085211314dcae9e98fe7

See more details on using hashes here.

File details

Details for the file kvikio_cu12-24.12.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-24.12.0-cp312-cp312-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 57a4bdeb40303b42580052ed4c2f0ec7b21eb4a2953811660d45014186c2cc79
MD5 2b475e593e92dc98f13f758bf6020810
BLAKE2b-256 834342829c2dba49b8ee5f28ed8cd1696bec95539ef67104c1a99607a10d8c03

See more details on using hashes here.

File details

Details for the file kvikio_cu12-24.12.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-24.12.0-cp311-cp311-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 4f6fd9b066e469715a670ea8f867828e5cd0b6f8679709b413ac6259867abe66
MD5 4754dd5d20b730be8766ff916056506b
BLAKE2b-256 aefc3bda6ef11d86256d06528bf81e6ff3412af40aa4cf9592427dc8b88d9b58

See more details on using hashes here.

File details

Details for the file kvikio_cu12-24.12.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-24.12.0-cp311-cp311-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 be03b7edf3c534c34c6c8914e82925234ab12b48f661a1fe95c4fbc69d9970d8
MD5 47291a972e0c43cf28eae9cc23a4c869
BLAKE2b-256 9d35f84dd61f088ff061ded2f936f06efa02f7921375da9c1b9985a57befbbb5

See more details on using hashes here.

File details

Details for the file kvikio_cu12-24.12.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-24.12.0-cp310-cp310-manylinux_2_27_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 2e89fa34004a7c379d628179170abee71df780b76a6864fe2add26d07745cf09
MD5 64cfbf9ffe2d5e39cd582784566051ca
BLAKE2b-256 1dab07ee9cae6738a1bddcc228a81300e5151f3923276a7277d80cab2904aa10

See more details on using hashes here.

File details

Details for the file kvikio_cu12-24.12.0-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-24.12.0-cp310-cp310-manylinux_2_27_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6caaaba87b9afde8ce99bae8cc415f7f1aaae750b6408a5e92fc6a29377fe3d4
MD5 0c233b5465c9cb08ff4e1ff75a5179b2
BLAKE2b-256 e1887ebd71962b38789a015e03ad687908049544d048f1fb622bda755f00361d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page