Skip to content

support nvgpu event - #210

Open
winterddd wants to merge 1 commit into
mchehab:masterfrom
winterddd:nvgpu
Open

support nvgpu event #210
winterddd wants to merge 1 commit into
mchehab:masterfrom
winterddd:nvgpu

Conversation

@winterddd

Copy link
Copy Markdown

Use nvml library to report nvgpu event. New environment NVGPU_EVENT_TYPES indicate registered events.
rasdaemon print like follow:

       <...>-0          [-01] .... 0.000000                       xid: xid: 43 pci_port: 00000000:00:03.0 gpu-i: 0 gpu-ci: 0 

@winterddd
winterddd force-pushed the nvgpu branch 7 times, most recently from 34863d6 to 52d6d4d Compare April 15, 2025 05:55
Use nvml library to report nvgpu event. New environment
NVGPU_DISABLE_EVENT indicate registered events.

Signed-off-by: Ruidong Tian <tianruidong@linux.alibaba.com>
Comment thread contrib/nvml.py
@@ -0,0 +1,77 @@
import re

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Explicitly add Python env:
#!/usr/bin/env python

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use:
#!/usr/bin/env python3

As some distributions don't provide a python -> python3 alias.

Comment thread contrib/nvml.py
flags=re.MULTILINE
)

with open(PATH, 'r') as file:

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add exception handling, e.g:

try:
with open(PATH, 'r') as file:
content = file.read()
except FileNotFoundError:
print(f"Error: File {PATH} not found.")
exit(1)
except IOError as e:
print(f"Error reading file {PATH}: {e}")
exit(1)

Comment thread rasdaemon.c

#ifdef HAVE_NVGPU
if (nvgpu_enable)
pthread_cancel(nvgpu_thread);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure thread cancellation is handled safely, Join with thread to see what its exit status was.
pthread_cancel(nvgpu_thread);
pthread_join(nvgpu_thread, NULL); // Wait for thread to terminate

@mchehab

mchehab commented Nov 14, 2025

Copy link
Copy Markdown
Owner

Patch breaks when cuda is not loaded:

File "rasdaemon/contrib/nvml.py", line 25, in
with open(PATH, 'r') as file:
~~~~^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: '/usr/local/cuda/include/nvml.h'
make: *** [Makefile:2108: ras-nvgpu-nvml.h] Error 1
make: *** Waiting for unfinished jobs....

Also:

  • it assumes cuda to be under /usr/local, instead of letting configure discover its locations.
  • for python, use 4 spaces for indentation, without tabs, as this is the most common standard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants