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.2.0.tar.gz (45.5 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.2.0-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for lupine-0.2.0.tar.gz
Algorithm Hash digest
SHA256 7d60dade19ccb14f2bb11de22666163a7d8f5f27ec40757cbc067c76c56ce1fd
MD5 b5527dc4b518a2d945ebc62b8ac58665
BLAKE2b-256 dd82fd30484492f908d29441755a9262ed5c4309ee5cbacaeae8422f532e3278

See more details on using hashes here.

Provenance

The following attestation bundles were made for lupine-0.2.0.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: lupine-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 9.4 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9546cd0aa4b33909f5bd6d256be9b31c9389709ac2c8c0a75193c25ad7e8ed6
MD5 06c097923ddf00752fb55a2975430471
BLAKE2b-256 d82dee63365d0bf5efb9b1aea465979e4792ed6daf60807ba5684b2a5e9fc1b1

See more details on using hashes here.

Provenance

The following attestation bundles were made for lupine-0.2.0-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