NVIDIA / NVIDIA/nvbench

Detect if GPU is being used for graphical purposes

Open
#15 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P2: nice to have
Dominant language
Cuda
Stars
927
Forks
123
Avg merge
2d 10h
Merged PRs (30d)
2

Description

Recent results show that noise could be increased up to 50% due to X-Server running on the device. To warn users about the noisy environment, we could check if GPU is being used for graphical purposes. It's possible to get this kind of information with NVML:

#include <iostream>
#include <nvml.h>

void chck(nvmlReturn_t status) {
    if (status != NVML_SUCCESS) {
        throw std::runtime_error(std::string("Failed to initialize NVML: ") + nvmlErrorString(status));
    }
}

struct NVML_RAII {
    bool initialized = false;

    NVML_RAII() {
        chck(nvmlInit());
        initialized = true;
    }

    ~NVML_RAII() {
        if (initialized) {
            chck(nvmlShutdown());
        }
    }
};

int main() {
    NVML_RAII nvml_raii;
    unsigned int device_count;

    chck(nvmlDeviceGetCount(&device_count));

    for (unsigned int i = 0; i < device_count; i++) {
        nvmlDevice_t device;
        char name[NVML_DEVICE_NAME_BUFFER_SIZE];
        chck(nvmlDeviceGetHandleByIndex(i, &device));
        chck(nvmlDeviceGetName(device, name, NVML_DEVICE_NAME_BUFFER_SIZE));

        std::cout << "\t" << name << std::endl;

        unsigned int graphics_processes = 0;
        nvmlDeviceGetGraphicsRunningProcesses(device, &graphics_processes, nullptr);

        if (graphics_processes) {
            std::cerr << "X-Server is running, please turn it off (" << graphics_processes << ")" << std::endl;
        }

        unsigned int compute_processes = 0;
        nvmlDeviceGetComputeRunningProcesses(device, &compute_processes, nullptr);

        if (compute_processes) {
            std::cerr << "Target device is in use (" << compute_processes << ")" << std::endl;
        }
    }

    return 0;
}

The header could be easily overlooked, so we could also bring one's attention to the noisy environment by adding a column to the nvbench output.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how nvbench currently produces its output and where NVML-related initialization could fit. Use the issue's NVML graphics-process query as the reference, then determine whether the result belongs in a new output column or a warning. Done means graphical GPU use is detected and clearly reported without obscuring compute-process warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
performance
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.