🚀 GPU Runner (gpurun)
Overview
gpurun is a sophisticated command-line tool designed to simplify scheduling GPU jobs on a single machine for machine learning, data science, and computational tasks. It provides intelligent GPU allocation, concurrency control, and seamless integration with CUDA applications using CUDA_VISIBLE_DEVICES. It is inspired by the sem tool from GNU parallel.
Why Use GPU Runner?
Imagine you are on an 8-GPU machine, and you want to run 100 inference jobs. You want to run them in parallel. Each job needs 2 GPUs and each GPU can only run three jobs at a time to avoid GPU memory overflow. You think you need a cluster scheduler like sbatch but for a single machine on GPUs. If this is your problem, GPU Runner is the perfect solution for you!
Think of GPU Runner as a local GPU scheduler that intelligently coordinates job execution, preventing memory overflow and maximizing computational efficiency.
🌟 Key Features
- Flexible GPU Allocation: Automatically assign jobs to GPUs with
CUDA_VISIBLE_DEVICES - Simple Interface: Minimalistic command-line interface
- Concurrent Job Management: Limit and control GPU usage across multiple jobs
- Automatic GPU Detection: Automatically identifies available GPUs
- GNU Parallel Compatibility: Easy to be used with GNU parallel
- Session-based Locking: Prevent GPU contention between different computational tasks
Installation
pip install git+https://github.com/zhou13/gpurun
Usage Examples
Basic Usage
# 1. Run infer.py (needs 1 GPU) on 100 images with all the GPUs in parallel, 1 job per GPU.
for i in $(seq 1 100); do gpurun python infer.py $i.jpg & done
# 2. Same as 1, but put 2 jobs per GPU at the same time.
for i in $(seq 1 100); do gpurun -j2 python infer.py $i.jpg & done
# 3. Same as 2, but use gnu-parallel to simplify the command.
parallel -j0 gpurun -j2 python infer.py {} ::: $(seq 1 100)
# 4. Same as 1, but infer.py now will see 2 GPUs.
parallel -j0 gpurun -g2 python infer.py {} ::: $(seq 1 100)
# 5. You can customize the GPUs to be used with --gpus.
parallel -j0 gpurun --gpus 0,1 python infer.py {} ::: $(seq 1 100)
# 6. You can customize the name of lockfile with --session.
parallel -j0 gpurun --session ml-seesion python infer.py {} ::: $(seq 1 100)
Configuration Options
$ gpurun --help
usage: gpurun [-h] [--session SESSION] [--gpus GPUS] [-j MAX_JOBS_PER_GPU] [-g GPUS_PER_JOB] ...
Run a command with GPU management and scheduling
positional arguments:
command Command to run (e.g., "python run.py")
options:
-h, --help show this help message and exit
--session SESSION String representing the session name used in locks (default: "default-session")
--gpus GPUS Comma-separated list of GPU IDs to use (e.g., "0,1,2") or "auto" for autodetection
-j MAX_JOBS_PER_GPU, --max-jobs-per-gpu MAX_JOBS_PER_GPU
Maximum number of concurrent jobs allowed per GPU group (default: 1)
-g GPUS_PER_JOB, --gpus-per-job GPUS_PER_JOB
Number of GPUs needed for each job (default: 1)
Contributing
Contributions welcome! Feel free to open issues and submit pull requests.
License
This project is licensed under the MIT License.
Metadata
Release files for gpurun 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| gpurun-0.1.1.tar.gz | 7.5 kB | Without provenance | Details for gpurun-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| gpurun-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for gpurun-0.1.1-py3-none-any.whl |
Total release size: 13.1 kB
Release files / gpurun-0.1.1.tar.gz
| Download URL | gpurun-0.1.1.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ca989529407521e6fdff4ebafd6108c4edb5c76330d13aec36f3e5248ec509ab
|
|
BLAKE2b-256 checksum How to use checksums |
9ef2d62b64803e528cef8feb33c916077de487e9d757e28c75252ae2e327fa34
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Release files / gpurun-0.1.1-py3-none-any.whl
| Download URL | gpurun-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9a6780d3189a50c5bd7432fc1c8a13af9e06303e91a5a7bddcce5f20bfc0d347
|
|
BLAKE2b-256 checksum How to use checksums |
2f3846479885d3640f5a52bdf45006366cf37780b019dabe1d62faa320ec6034
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.12.6
|
Security for gpurun 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.