Skip to main content

Small PyTorch adapter helpers for LUPINE-backed CUDA devices

Project description

lupine Python adapter

This package provides small PyTorch helpers for LUPINE. It intentionally returns ordinary torch.device("cuda:N") objects so PyTorch continues to use its normal CUDA dispatch path while LUPINE handles CUDA driver/NVML calls underneath.

Declare all LUPINE hosts before any PyTorch CUDA work:

import lupine

with lupine.connect(host="<server>:14833") as s:
    device = s.device()
    model = model.to(device)

connect() loads the LUPINE libcuda.so.1 from ../build/libcuda.so.1 when used from this repository. For an installed package, pass libcuda=... or set LUPINE_LIBCUDA if the library lives somewhere else:

with lupine.connect(host="<server>:14833", libcuda="/opt/lupine/libcuda.so.1") as s:
    device = s.device()

For multiple LUPINE servers, pass the full host list in one call. The order defines the CUDA ordinals that PyTorch sees:

import lupine

with lupine.connect(host=["<server-a>:14833", "<server-b>:14833"]) as s:
    gpu0, gpu1 = s.devices()
    model0 = model0.to(gpu0)  # cuda:0
    model1 = model1.to(gpu1)  # cuda:1

Do not add a second host after tensors have already been moved to the first one. LUPINE opens connections from LUPINE_SERVER when CUDA first initializes, and later changes to LUPINE_SERVER are not picked up by the current process.

Exiting the context restores LUPINE_SERVER only if CUDA was not initialized inside the block. If CUDA was initialized, the process-global LUPINE connection is already active and cannot be disconnected safely.

The adapter does not create a new PyTorch backend such as torch.device("lupine"). A true custom PyTorch device would require registering PrivateUse1 kernels and backend support. LUPINE already works best when PyTorch sees CUDA tensors and the LUPINE library is selected through the dynamic linker.

Project details


Download files

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

Source Distribution

lupine-0.1.1.tar.gz (45.0 kB view details)

Uploaded Source

Built Distribution

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

lupine-0.1.1-py3-none-any.whl (9.2 kB view details)

Uploaded Python 3

File details

Details for the file lupine-0.1.1.tar.gz.

File metadata

  • Download URL: lupine-0.1.1.tar.gz
  • Upload date:
  • Size: 45.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lupine-0.1.1.tar.gz
Algorithm Hash digest
SHA256 b38404e015d677b7c72a93380d6dcafb7db4c98a8d81f638107f5b027cd5fc1f
MD5 7b87ecdb9d0729285a4942a7a92428ac
BLAKE2b-256 03e2e36a01c7d6e1395d76e7c61db909dd0580fae1d0d7b28ae6bb06cab9edd5

See more details on using hashes here.

Provenance

The following attestation bundles were made for lupine-0.1.1.tar.gz:

Publisher: publish.yml on lupinemachines/lupine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file lupine-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: lupine-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 9.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for lupine-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2e9dfe8ee3371c9b3a56a61983b96bcd0a91572c18fd3e881e3f025983edc901
MD5 40c6a60a6eb3c114d7e42b7b7fc476ab
BLAKE2b-256 f67141cda83dfbd7afa303f02ad99f51c44879027b43c7e4951abb1c7d71dec3

See more details on using hashes here.

Provenance

The following attestation bundles were made for lupine-0.1.1-py3-none-any.whl:

Publisher: publish.yml on lupinemachines/lupine

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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