semvec/pypi-packages huggingface dataset:
pysgm 0.6.0
Wrap user code in a context for dynamic acquisition of GPU(s) on a multi-GPU, multi-user server.
License: MIT
Requires Python: >=3.8

========
Overview
========

The Python Server GPU Manager (``pysgm``) package provides a context for running GPU-accelerated code in a multi-GPU, multi-user server.

Wrapping user code in the ``pysgm``-provided context allows for GPU resources to be *safely*, *dynamically*, and *exclusively* acquired:

1. **Safely**: The ``pysgm`` module temporarily locks a resource reference file during acquisition to prevent race conditions.

2. **Dynamically**: Users request the number of GPUs they want to use. ``pysgm`` then polls the computing environment to determine if there are sufficient resources. If there are sufficient resources, ``pysgm`` assigns the requested number of devices to the user.

3. **Exclusively**: If resources are successfully acquired, ``pysgm`` tracks the specific resources used and prevents them from being acquired by others. The resources are released for others to use when the context closes.

There is one noted downside: in order to guarentee safety (e.g., prevent race conditions, maintain exclusive use of resources), everyone using GPU resources on the server must use ``pysgm``.


Usage
=====

Simply import the `GPUManager` class  and use it in a with statement::

    from pysgm.manager import GPUManager

    with GPUManager():
        <YOUR CODE HERE>

By default, `GPUManager` requests a single GPU. If you want to change from these defauls, use the `requested_gpus` parameter::

    with GPUManager(requested_gpus=2):
        <YOUR CODE HERE>

To print details about resource acquisition events, use the `logger` parameter. The example below prints to the console::

    import logging
    logging.basicConfig(format='%(message)s', level=logging.DEBUG)

    with GPUManager(logger=logging):
        <USER CODE HERE>

Installation
============


The ``pysgm`` package is available on the oeus-lambda-server local conda channel. Use the command below to install ``pysgm`` to the conda environment *YOUR_VENV*::

    conda install -n YOUR_VENV --channel=file:///opt/anaconda3/conda-bld --override-channels pysgm


Documentation
=============

http://osmr6.otsplab.psb.bls.gov/gpu-computing/oeus-lambda-server/pysgm


Changelog
=========

0.3.0 (2021-03-12)
------------------