/pynvx

Python bindings for NVIDIA CUDA APIs.

Primary LanguagePythonMIT LicenseMIT

██████╗ ██╗   ██╗███╗   ██╗██╗   ██╗██╗  ██╗
██╔══██╗╚██╗ ██╔╝████╗  ██║██║   ██║╚██╗██╔╝
██████╔╝ ╚████╔╝ ██╔██╗ ██║██║   ██║ ╚███╔╝
██╔═══╝   ╚██╔╝  ██║╚██╗██║╚██╗ ██╔╝ ██╔██╗
██║        ██║   ██║ ╚████║ ╚████╔╝ ██╔╝ ██╗
╚═╝        ╚═╝   ╚═╝  ╚═══╝  ╚═══╝  ╚═╝  ╚═╝

pynvx

Python bindings for NVIDIA CUDA APIs.

PyPI Release Version

A Python interface to get GPU information, built with pybind11. The main purpose of this project is providing a solution for managing GPU information on OS X, because there is no NVML library on OS X.

You can use pynvx as:

  • standalone API: pynvx.cuda*
  • pyNVML wrapper: pynvml.nvml*, API call will be invoked to pyNVML on Linux and Windows, or pynvx on OS X.

Table of Contents

Prerequisites

1. CUDA

You should set up CUDA before installation.

2. Compiler

Used When installing from source

On Unix (Linux, OS X)

  • A compiler with C++11 support
  • CMake >= 2.8.12

On Windows

  • Visual Studio 2015, or Visual Studio 2017 for Python 3.11 and above (see notes below)
  • CMake >= 3.1

Installation

1. Install by pip (recommended)

pip install pynvx

2. Install from offline wheel file

Download wheel file in Release page, then install with pip:

pip install pynvx-*.whl

3. Install from source

Please install CUDA and set environment variables first.

See FindCUDA.cmake:548 (message): Specify CUDA_TOOLKIT_ROOT_DIR in TROUBLESHOOTING.

Just clone this repository and pip install. Note the --recursive option which is needed for the pybind11 submodule:

git clone --recursive https://github.com/helloall1900/pynvx.git
pip install ./pynvx

With the setup.py file included in this project, the pip install command will invoke CMake and build the pybind11 module as specified in CMakeLists.txt.

APIs

  • standalone API

    See API

  • pyNVML wrapper

    Please install pyNVML when use pynvx as pyNVML wrapper:
    Python 3: pip install nvidia-ml-py3
    Python 2: pip install nvidia-ml-py

    See WRAPPER

Special notes for Windows

Compiler requirements

Pybind11 requires a C++11 compliant compiler, i.e Visual Studio 2015 on Windows (Visual Studio 2017 for Python 3.11 and above). This applies to all Python versions, including 2.7. Unlike regular C extension modules, it's perfectly fine to compile a pybind11 module with a VS version newer than the target Python's VS version. See the FAQ for more details.

Runtime requirements

The Visual C++ 2015/2017 redistributable packages are a runtime requirement for this project. It can be found here. If you use the Anaconda Python distribution, you can add vs2015_runtime/vs2017_runtime as a platform-dependent runtime requirement for you package: see the conda.recipe/meta.yaml file in this example.

License

pynvx is provided under MIT License, see LICENSE file.

Troubleshooting

If you have problem while installing pynvx, see TROUBLESHOOTING before opening an issue.

Test & Example

Special Thanks

  • Thanks stas00 for the idea of pyNVML wrapper and helping to test.