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.0.tar.gz (39.7 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.0-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lupine-0.1.0.tar.gz
  • Upload date:
  • Size: 39.7 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.0.tar.gz
Algorithm Hash digest
SHA256 9d05ecbcb0d33ecd7d8b97ea7e03afa52de6ab4efa23a526a45ffbeedaa056d1
MD5 e0d1d8ba8b5cb7cbd49ef27c9d2c8088
BLAKE2b-256 33cb333c73f5facd337663208381ba83877beb763d90d21acf98acd489bbe9b5

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lupine-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 4.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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a6a6866e463a895532a5420538421e4b5f003d4ac97e940b4656a68ec3587050
MD5 a7060afd97b7fd19cedb93b90cc2ffa1
BLAKE2b-256 dc7646e8977e63c3210ba3be31c227bbf5addfb89b56fb13b06f0030103ed0fc

See more details on using hashes here.

Provenance

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