Skip to content

nvmetrics is a library designed to facilitate the measurement of GPU metrics using NVIDIA CUPTI (CUDA Profiling Tools Interface)

License

Notifications You must be signed in to change notification settings

nlesc-recruit/nvmetrics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

73 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nvmetrics

Introduction

nvmetrics is a library designed to facilitate the measurement of GPU metrics using NVIDIA CUPTI (CUDA Profiling Tools Interface). While tools like NCU (NVIDIA Command-Line Profiler) and GUI-based profilers exist, nvmetrics offers a programmatic approach to GPU profiling, enabling seamless integration into custom workflows and applications.

The core of this library is based on this code. The main changes and additions are:

  • Some refactoring (without altering the behavior of the code)
  • Added linting using pre-commit
  • Added CMake to build this code as a library
  • Added Python interface using pybind11
  • Added C++ and Python demo program to illustrate the use of this library

Features

  • Provides a simple C++ interface for measuring GPU metrics.
  • Enables programmatic access to NVIDIA CUPTI for GPU profiling.
  • Includes a Python interface using pybind11 for easy integration into Python projects.

Installation

Requirements

  • NVIDIA GPU with CUDA support
  • CUDA Toolkit
  • pybind11 (for Python interface)

Build from source

  1. Clone this repository:
git clone https://git.astron.nl/RD/recruit/nvmetrics.git
  1. Navigate to the repository directory:
cd nvmetrics
  1. Build the library:
cmake -S. -Bbuild
make -C build
  1. (Optional) Install the library:
make -C build install

Usage

C++

#include <vector>
#include <string>
#include "nvmetrics.h"

using namespace nvmetrics;

int main() {
    std::vector<std::string> metrics = {"metric1", "metric2", "metric3"};
    
    // Start measuring metrics
    measureMetricsStart(metrics);
    
    // Perform GPU operations
    
    // Stop measuring metrics and retrieve results
    std::vector<double> results = measureMetricsStop();
    
    // Process results
    
    return 0;
}

Python

import nvmetrics

# Define metrics to measure
metrics = ["metric1", "metric2", "metric3"]

# Start measuring metrics
nvmetrics.measureMetricsStart(metrics)

# Perform GPU operations

# Stop measuring metrics and retrieve results
results = nvmetrics.measureMetricsStop()

# Process results

About

nvmetrics is a library designed to facilitate the measurement of GPU metrics using NVIDIA CUPTI (CUDA Profiling Tools Interface)

Resources

License

Stars

Watchers

Forks

Packages

No packages published