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.2.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.1.2-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lupine-0.1.2.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.1.2.tar.gz
Algorithm Hash digest
SHA256 e6c6075eee4228539f13cb817c88bdcbeaa0a7563431f625557fb92b977ab158
MD5 f7162f34253d32d551e20626dad1a7ce
BLAKE2b-256 af0c9b3c98a592ebb4c448e62161732396528cd4c8e3ce099f2794a81c1991e2

See more details on using hashes here.

Provenance

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

File metadata

  • Download URL: lupine-0.1.2-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.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 2c04290b72ff10631458c5e18db4bc926601ff8232118e371aa1b62a9f96ee42
MD5 f3315e72a6859a9f1186f224861cfd6d
BLAKE2b-256 e2a8c27c4cfc138e45e7409cb41d89489a08eccaa1b7aede05f504abe0404cbf

See more details on using hashes here.

Provenance

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