Skip to main content

Async and sync client + CLI for the gpu-lock service.

Project description

gpu-lock-client

Python client + CLI for the gpu-lock service — a FIFO priority mutex that coordinates shared GPU access between processes and Docker containers.

pip install gpu-lock-client

Quick use — CLI

export GPU_LOCK_URL=http://192.168.10.13:8090

# Acquire GPU 0, run a command, release on exit (sets CUDA_VISIBLE_DEVICES).
gpu-lock run --gpu 0 -- python train.py

# Let the server pick the least-busy GPU.
gpu-lock run --gpu auto -- bash

# Interactive priorities run ahead of the normal queue.
gpu-lock run --gpu auto --priority high -- python infer.py

# Low-priority batch work yields to everyone else.
gpu-lock run --gpu 0 --priority low -- python nightly_job.py

# Inspection
gpu-lock status
gpu-lock queue --gpu 0

Quick use — Python

from gpu_lock_client import gpu_lock, gpu_lock_sync, Priority

# Async
async with gpu_lock("my-service", gpu=0, ttl=300, priority=Priority.HIGH) as lease:
    if lease:
        os.environ["CUDA_VISIBLE_DEVICES"] = str(lease.gpu)
    ...

# Sync
with gpu_lock_sync("my-service", gpu="auto", ttl=300) as lease:
    ...

The context manager automatically heart-beats the lease in the background, so long-running jobs don't need to pick a huge TTL.

Passthrough mode

If GPU_LOCK_URL is empty or unset, every client call is a no-op: functions return None, context managers yield None, the CLI's run just execs the command. This lets the same code run on single-GPU dev machines without a gpu-lock service.

Auth

Set GPU_LOCK_TOKEN — the client sends it as Authorization: Bearer.

See the project README for the full protocol, server setup, and priority semantics.

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

gpu_lock_client-0.3.0.tar.gz (13.9 kB view details)

Uploaded Source

Built Distribution

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

gpu_lock_client-0.3.0-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file gpu_lock_client-0.3.0.tar.gz.

File metadata

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

File hashes

Hashes for gpu_lock_client-0.3.0.tar.gz
Algorithm Hash digest
SHA256 719ceacd1ecc66afe637c560d30d65863e55ce7000ff5f77058501e1e4d7c3eb
MD5 cad425b8cce22086c2809ebbba6f81cc
BLAKE2b-256 0dbaccf91d0d9afb4a703412e52f0094e525eb5daca7d6be44f52cd50247e106

See more details on using hashes here.

Provenance

The following attestation bundles were made for gpu_lock_client-0.3.0.tar.gz:

Publisher: publish.yml on ildar-idrisov/gpu-lock

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

File details

Details for the file gpu_lock_client-0.3.0-py3-none-any.whl.

File metadata

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

File hashes

Hashes for gpu_lock_client-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 51857198c8bef5510db098239e9e8d09d1b631933e9afeb28a9d89a66809bab1
MD5 9baf1a7f7d3c9ef59ab4af0173c7ae26
BLAKE2b-256 51d8865923e4bf95e6770049e3aff273026552d0a82e9c7cf2737cf6cb7c2743

See more details on using hashes here.

Provenance

The following attestation bundles were made for gpu_lock_client-0.3.0-py3-none-any.whl:

Publisher: publish.yml on ildar-idrisov/gpu-lock

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