fetch_ml/native/nvml_gpu/CMakeLists.txt
Jeremie Fraeys 05b7af6991
feat: implement NVML-based GPU monitoring
- Add native/nvml_gpu/ C++ library wrapping NVIDIA Management Library
- Add Go bindings in internal/worker/gpu_nvml_native.go and gpu_nvml_stub.go
- Update gpu_detector.go to use NVML for accurate GPU count detection
- Update native/CMakeLists.txt to build nvml_gpu library
- Provides real-time GPU utilization, memory, temperature, clocks, power
- Falls back to environment variable when NVML unavailable
2026-02-21 15:16:09 -05:00

35 lines
882 B
CMake

add_library(nvml_gpu SHARED
nvml_gpu.cpp
)
target_include_directories(nvml_gpu PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
)
# Find NVML library
find_library(NVML_LIBRARY nvidia-ml
PATHS
/usr/lib/x86_64-linux-gnu
/usr/local/cuda/lib64
/usr/lib64
/usr/lib
/opt/cuda/lib64
DOC "NVIDIA Management Library"
)
if(NVML_LIBRARY)
target_link_libraries(nvml_gpu PRIVATE ${NVML_LIBRARY})
message(STATUS "Found NVML: ${NVML_LIBRARY}")
else()
message(WARNING "NVML library not found. GPU monitoring will be disabled.")
# Create stub library that always returns unavailable
target_compile_definitions(nvml_gpu PRIVATE NVML_STUB)
endif()
set_target_properties(nvml_gpu PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR}
POSITION_INDEPENDENT_CODE ON
C_STANDARD 11
CXX_STANDARD 17
)