bug in nvidia gpu detection logic
ireed opened this issue · comments
The method for GPU detection does not handle all cases.
From the code in moonray/moonray/lib/rendering/rt/gpu/GPUUtils.cc:
FILE *fp = fopen("/proc/driver/nvidia/version", "r");
if (fp != NULL)
if (fscanf(fp, "NVRM version: NVIDIA UNIX x86_64 Kernel Module %d.%d", major, minor) == 2)
The issue with this method is the output in /proc/driver/nvidia/version may not match this particular string. In my case, it does not:
# cat /proc/driver/nvidia/version
NVRM version: NVIDIA UNIX Open Kernel Module for x86_64 535.86.10 Release Build (dvs-builder@U16-I2-C05-14-2) Wed Jul 26 23:15:31 UTC 2023
GCC version: gcc version 4.8.5 20150623 (Red Hat 4.8.5-44) (GCC)
Note the 'for x86_64', which results in a string mismatch. This causes Moonray to incorrectly claim that i do not have a GPU:
# moonray -in /openmoonray/testdata/rectangle.rdla -out /tmp/rectangle.exr -exec_mode xpu
Loading Scene File(s): /openmoonray/testdata/rectangle.rdla
Warning (lib.render): GPU: Unable to query NVIDIA driver version ...falling back to CPU vectorized mode
Error: GPU: Unable to query NVIDIA driver version ...falling back to CPU vectorized mode
Render prep time = 00:00:00.296
Of course, i can work around this by using root to manually edit that file.
A possible resolution would be to use nvidia-smi instead of parsing that file, which can change format. Maybe something like
$> nvidia-smi --query-gpu=driver_version --format=csv
Thank you for the detailed bug report!
We have created an internal ticket for this issue and are investigating a fix.
This has been fixed and the fix will appear in the next OpenMoonRay release.