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.2.1.tar.gz (12.5 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.2.1-py3-none-any.whl (13.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gpu_lock_client-0.2.1.tar.gz
  • Upload date:
  • Size: 12.5 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.2.1.tar.gz
Algorithm Hash digest
SHA256 fdd1ac9ce07e23c02d81271ff082931864d1b842137b9c6c1c974b68d37f7296
MD5 eb3e45f49200f925bcefe818a4a11500
BLAKE2b-256 f55647fbcd08efba43672bf68a89c2895f7d3406d363da59ca8f8c2ae205f494

See more details on using hashes here.

Provenance

The following attestation bundles were made for gpu_lock_client-0.2.1.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.2.1-py3-none-any.whl.

File metadata

  • Download URL: gpu_lock_client-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 13.5 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 85d1582c42be587587f6d1108593e4a1c08d1a189ecee6036c6b3c604bba1d58
MD5 f07a0734c35a7a4d5a4fe9267911b7ad
BLAKE2b-256 ee678c041c0d7ea4f6f05088f515995d99552ea9d87e9efa60e13db1c806d64e

See more details on using hashes here.

Provenance

The following attestation bundles were made for gpu_lock_client-0.2.1-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