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-25.2.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (736.7 kB view details)

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

kvikio_cu12-25.2.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (682.7 kB view details)

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

kvikio_cu12-25.2.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (755.4 kB view details)

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

kvikio_cu12-25.2.1-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (702.2 kB view details)

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

kvikio_cu12-25.2.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (753.8 kB view details)

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

kvikio_cu12-25.2.1-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl (702.0 kB view details)

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

File details

Details for the file kvikio_cu12-25.2.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-25.2.1-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 357a8068f0bff2d708e7beca9a97bfc32c898819a3812223352b1ae7a08b48cb
MD5 3f06ee7cdf546a551f15e7b4b0716120
BLAKE2b-256 384f23bc6e2ae7f8544f0c2ba3415759a99a660302e368840b9440ac1f4d6a9b

See more details on using hashes here.

File details

Details for the file kvikio_cu12-25.2.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-25.2.1-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 06840ff011251edab58ab53dff29378ef461e398a5af99cf417f53fa8fd4c7ed
MD5 9f0d76e906dcb7b4e59c1a420eaaee44
BLAKE2b-256 7bb61acb0fc704615c3b86a66d22fe3753d81562d2c09be126aa06e097278f8e

See more details on using hashes here.

File details

Details for the file kvikio_cu12-25.2.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-25.2.1-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 36656b1c8f5276e150ec84567a5dce8975788ae05bbf3ee44ff36dcf8c9bc441
MD5 16fb1bb92dc2b4b458d68d81c282f28e
BLAKE2b-256 5ae45a0d8d7d4a46a0d03a8631d01b6896944b2c62ec880e47919b313c1abae3

See more details on using hashes here.

File details

Details for the file kvikio_cu12-25.2.1-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-25.2.1-cp311-cp311-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 cdb2acc2d2897ae9dff3ba23909f604617612766f0ca3ee62109eb2384568401
MD5 22aebfd1a8d5d3e4edca8814ac4fa000
BLAKE2b-256 bc6a3f3c39e214a7db52ea653650ecea96a7baef8c0bce00dac4bc0d16e343df

See more details on using hashes here.

File details

Details for the file kvikio_cu12-25.2.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-25.2.1-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 1406f09a6ff8b4a70676ab8bee6954caa46cef2390e813d2526b02bf6af4eba1
MD5 cac83eec796c8aa049d25511b6094c04
BLAKE2b-256 a36e5272801ed7a92ca39a2d7266918ad5ea33885ae4f4b6ec5ef2415d13176c

See more details on using hashes here.

File details

Details for the file kvikio_cu12-25.2.1-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for kvikio_cu12-25.2.1-cp310-cp310-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 95956d7b100b29bcff19bd0e30ccd4e0ab85c9ee4cb399e7afcd0e229288b023
MD5 b8f23526f6c865169c4f87453a058a12
BLAKE2b-256 d6c36f3d73020d8134a3a969adbe9ddb8a62411d4e095d8f9b6fc8c82d6b91a0

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