From d57f6bf0bfb860405b162a9b4228e32bf3c968b4 Mon Sep 17 00:00:00 2001 From: Frederick Roy Date: Fri, 20 Mar 2026 13:31:50 +0900 Subject: [PATCH] sofacuda: add diagnostic info --- .../plugins/SofaCUDA/Core/CMakeLists.txt | 2 -- .../SofaCUDA/Core/src/sofa/gpu/cuda/mycuda.cu | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/applications/plugins/SofaCUDA/Core/CMakeLists.txt b/applications/plugins/SofaCUDA/Core/CMakeLists.txt index bd186d249c3..05e8d3c428c 100644 --- a/applications/plugins/SofaCUDA/Core/CMakeLists.txt +++ b/applications/plugins/SofaCUDA/Core/CMakeLists.txt @@ -109,8 +109,6 @@ if (${CUDA_HOST_COMPILER} MATCHES "ccache$") endif() add_library(${PROJECT_NAME} SHARED ${HEADER_FILES} ${SOURCE_FILES} ${CUDA_SOURCES}) -set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES "${CMAKE_CUDA_ARCHITECTURES}") -message("CMAKE_CUDA_ARCHITECTURES ${CMAKE_CUDA_ARCHITECTURES}") set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "${SOFACUDA_COMPILE_DEFINITIONS}") if(SOFACUDA_VERBOSE_PTXAS) target_compile_options(${PROJECT_NAME} PUBLIC $<$:--ptxas-options=-v>) diff --git a/applications/plugins/SofaCUDA/Core/src/sofa/gpu/cuda/mycuda.cu b/applications/plugins/SofaCUDA/Core/src/sofa/gpu/cuda/mycuda.cu index 61934bfcb6d..ce9ce60ea00 100644 --- a/applications/plugins/SofaCUDA/Core/src/sofa/gpu/cuda/mycuda.cu +++ b/applications/plugins/SofaCUDA/Core/src/sofa/gpu/cuda/mycuda.cu @@ -80,10 +80,29 @@ int mycudaInit(int device) { if (cudaInitCalled) return 1; + // Driver and API checks #if defined(__cplusplus) mycudaPrintf("C++ standard = %ld", __cplusplus); #endif + // ── Driver & Runtime versions ────────────────────────────────────────── + int driverVersion = 0, runtimeVersion = 0; + cudaDriverGetVersion(&driverVersion); + cudaRuntimeGetVersion(&runtimeVersion); + + mycudaPrintf("=== CUDA Version Diagnostics ===\n"); + mycudaPrintf("Driver version : %d.%d\n", driverVersion / 1000, (driverVersion % 100) / 10); + mycudaPrintf("Runtime version : %d.%d\n", runtimeVersion / 1000, (runtimeVersion % 100) / 10); + + if (driverVersion < runtimeVersion) { + mycudaPrintf("[ERROR] Driver is too old for this runtime!\n"); + mycudaPrintf(" Minimum required driver for runtime %d.%d: see CUDA release notes.\n", + runtimeVersion / 1000, (runtimeVersion % 100) / 10); + return 0; + } + mycudaPrintf("[OK] Driver is compatible with runtime.\n\n"); + + // Hardware checks cudaInitCalled = true; const cudaError_t getDeviceCountError = cudaGetDeviceCount(&deviceCount); if (getDeviceCountError != cudaSuccess)