Skip to main content

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
import torch

with lupine.connect(host="<server>:14833"):
    device = torch.device("cuda", 0)
    model = model.to(device)

host defaults to LUPINE_SERVER, so a launcher that already bound a session — such as lupine run — needs no argument at all:

with lupine.connect() as s:
    device = s.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:

import torch

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

For multiple LUPINE servers, pass the full host list in one call. devices() uses the native CUDA topology, so it returns every GPU exposed by every server, not one device per server. When local GPUs are enabled, they come first; remote GPUs then follow server order and each server's native device order:

import lupine

with lupine.connect(host=["<server-a>:14833", "<server-b>:14833"]) as s:
    gpus = s.devices()
    model0 = model0.to(gpus[0])
    model1 = model1.to(gpus[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 the previous LUPINE_SERVER value.

connect() selects the native CUDA path by default. On macOS with a CPU-only PyTorch build, it automatically starts a containerized PyTorch sidecar instead:

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

The sidecar option controls that selection explicitly:

  • sidecar=None (the default) automatically uses the sidecar only on macOS when PyTorch has no native CUDA backend.
  • sidecar=True forces the sidecar on any platform.
  • sidecar=False disables the sidecar.

The sidecar auto-detects Apple Container, Docker, Podman, or nerdctl. Apple Container is preferred on macOS; Docker-compatible runtimes use the host's native architecture unless platform=... is passed to lupine.sidecar(). Pass runtime="container", "docker", "podman", or "nerdctl" to lupine.sidecar() to select one explicitly.

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.

Metadata

Release files for lupine 0.5.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for lupine 0.5.0
File Size Uploaded
lupine-0.5.0.tar.gz 51.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for lupine 0.5.0
File Interpreter ABI Platform
lupine-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 70.6 kB

Release files / lupine-0.5.0.tar.gz

Download URL lupine-0.5.0.tar.gz
Size 51.9 kB
Tags Source
SHA-256 checksum
How to use checksums
0ade471d75bf3177c353d5fce6c2750645959344376729962b848bf9d3ee0df9
BLAKE2b-256 checksum
How to use checksums
78c458e2d118b69dce655cf3b3004820454674974266be2082d51d9188c2de88
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.

Transparency log

Release files / lupine-0.5.0-py3-none-any.whl

Download URL lupine-0.5.0-py3-none-any.whl
Size 18.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9f436a09eb8976e7a870f9c2ac1d4acf9577076c292dede66ab6d28fe40ef25a
BLAKE2b-256 checksum
How to use checksums
5ad026070cd6426a84c6d9c5fed92de966ab598ec21c7fcb2e6b2440ec5054f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Aug 4, 2026.

Transparency log

Release history Release notifications | RSS feed

2.0.3

1 release file

2.0.2

1 release file

2.0.1

1 release file

2.0.0

1 release file

1.0.0

2 release files

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.2.0

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page