PixarAnimationStudios / OpenSubdiv

An Open-Source subdivision surface library.
graphics.pixar.com/opensubdiv
Other
2.89k stars 561 forks source link

CMake failure with CUDA 12 #1299

Closed gonsolo closed 1 year ago

gonsolo commented 1 year ago

Build fails with CUDA 12. This patch solves the issue:

Subject: [PATCH] CUDA 12 doesn't know older GPU architecture.

---
 CMakeLists.txt | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8616b2f2..c7c69f0e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -590,8 +590,10 @@ if(CUDA_FOUND)
         if (NOT DEFINED OSD_CUDA_NVCC_FLAGS)
             if (CUDA_VERSION_MAJOR LESS 6)
                 set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_11 )
-            else()
+           elseif (CUDA_VERSION_MAJOR LESS 12)
                 set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_20 )
+            else()
+                set( OSD_CUDA_NVCC_FLAGS --gpu-architecture compute_50 )
             endif()
         endif()
     endif()
-- 
2.37.2

Already mentioned in https://github.com/PixarAnimationStudios/OpenSubdiv/issues/965 which is three years old.

davidgyu commented 1 year ago

Filed as internal issue #OSD-411

davidgyu commented 1 year ago

The solution is the same as for #965 you should specify OSD_CUDA_NVCC_FLAGS in your CMake configuration to specify the CUDA gpu architecture that you want to use.

It's not feasible for us to patch OpenSubdiv for each release of a new CUDA architecture. In future OpenSubdiv releases we may remove these fallback settings of --gpu-architecture.

Agree that this should be described more clearly in the documentation! Thanks!