Dark Mode

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jan 29, 2022. It is now read-only.

fabgeyer/gpudlock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

11 Commits

Repository files navigation

Distributed GPU lock

gpudlock is a small python library to share Nvidia GPUs between multiple processes. The library performs the following steps:

  1. Probes the system with nvidia-smi to know the current usage of GPUs;
  2. Iterates through the unused GPUs and locks one using a distributed lock.

The distributed lock mechanism is based on redis using the redlock-py library.

## Library installation

$ sudo apt install redis-server
$ pip install --upgrade https://github.com/fabgeyer/gpudlock/archive/master.tar.gz

## Library usage

Directly in python:

from gpudlock import select_gpu

def main():
...
try:
select_gpu()
except:
print("Failed to allocate GPU")
...

In a bash script:

#!/bin/sh

export CUDA_VISIBLE_DEVICES=`gpudlock --random`

About

Distributed locking for GPUs

Topics

Resources

Readme

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors

Languages