Socket
Socket
Sign inDemoInstall

pyrsmi

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pyrsmi

Python System Management Library for AMD GPUs


Maintainers
1

pyrsmi

Python Bindings for System Management Library for AMD GPUs


  • pyrsmi is a python package of rocm-smi-lib, for providing a limited features of ROCm System Management Library for assisting Python development involving AMD GPUs.
  • It is based on (rocm-smi-lib)[https://github.com/RadeonOpenCompute/rocm_smi_lib], so its scope of support should be similar to that of the latter.

Requirements

  • pyrsmi runs on latest ROCm-supported Instinct MI-series GPU systems. Scope of tested systems is limited; please create tickets for any issues encountered.

How to install from source

  • Clone this repo:
    • git clone https://github.com/ROCm/pyrsmi
    • cd pyrsmi
  • python -m pip install -e .
  • pyrsmi can be installed as PyPA-compatible Python package.

How to install Python packages

  • Install build package:
    • pip install build
  • At the top directory (where setup.py is), run: python -m build
  • Then by default packages (both sdist and wheel) will be built under dist directory.
  • The packages can be either installed with pip install, or be uploaded to PyPI (release or test) repo, or an artifactory of your choice. The latter can be installed liked beflow.

How to install from PyPI

  • NOTE: Release versions are available at pypi.org, and the package can be installed with :
    • python -m pip install pyrsmi

How to use pyrsmi

  • Environment setup:
    • pyrsmi searches for rocm-smi library from default ROCm environment variable ROCM_PATH. So, for standard ROCm installation, the library will be automatically detected. In some unusual case where the ROCm installation is moved, make sure to set the environment variable as so :
      $ mv /opt/rocm/ /usr/local/xyz/
      $ export ROCM_PATH=/usr/local/xyz/
      
  • Running in python:
    from pyrsmi import rocml
    
    rocml.smi_initialize()
    print(rocml.smi_get_device_count())
    rocml.smi_shutdown()
    

Examples

  • Examples directory contains a number of code snippets showing how to use the package.
  • It also contains an example showing how to use pyrsmi to create a web-based system monitoring tool that displays various dashboards of system status, including memory, CPU/GPU utilization and process names.

List of API functions

  • The list is not exhaustive. Please refer to the code for missing functions.
FunctionDescriptionArgumentReturn TypeNote
smi_initializeinitialize rsmiNoneNone
smi_shutdownshut down rsmiNoneNone
smi_get_versionget version of rsmiNonestr'major.minor.patch'
smi_get_kernel_versionget version of ROCm kernel driverNonestr
smi_get_device_idget device id of GPU devicesNoneuint64id of devices
smi_get_device_countget number of GPU devicesNoneintnum of devices
smi_get_device_nameget name of GPU devicesNonestr
smi_get_device_unique_idget unique id of GPU devicesNoneint64bit integer
smi_get_device_utilizationget device utilization in % busydevice_idint
smi_get_device_memory_usedget device memory usagedevice_idintin Bytes, type 'VRAM'
smi_get_device_memory_totalget device's total memorydevice_idintin Bytes, type 'VRAM'
smi_get_device_memory_busyget percentage of time busy accessing memorydevice_idintin percent time
smi_get_device_memory_reserved_pagesget info of reserved device memorydevice_id(# pages, ptr to block)
smi_get_device_pcie_bandwidthget device's estimated PCIe bandwidthdevice_idfloatin Bytes/sec
smi_get_device_compute_processget list of pid of processes running on the systemNoneList[int]
smi_get_device_average_powerget device's average powerdevice_idfloatpower in Watt
smi_get_device_xgmi_error_statusget XGMI error status for the devicedevice_idint
smi_reset_device_xgmi_errorget device's average powerdevice_idfloatpower in Watt
smi_get_device_compute_partitionget device's compute partitiondevice_idstre.g. 'SPX', 'CPX'
smi_get_device_memory_partitionget device's memory partitiondevice_idstre.g. 'NPS1'
smi_get_device_link_typegets hops and types of link between two devices(device_id, device_id)(int, int)(n_hops, type)
smi_get_device_uuidgets UUID of the device(device_id, format)strdefault with 'GPU-' prefix

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc