-
Notifications
You must be signed in to change notification settings - Fork 86
Compile Error with CUDA 11 #250
Comments
Same here |
Hello friends, I was having this error also when trying to compile this project on Mint 20 (Ubuntu 20.04) with CUDA 11.0 (from nvidia apt ubuntu repo). I was able to get it working with some small modifications, see: ploober@3c81181 To summarize the change: If CUDA 11+ is detected, it will only build with a model handler for @DeadSix27 if this is suitable for PR I can put it up. If not that's fine, I see there is #166 where this could potentially be addressed in a more universal way. |
workground(?) diff --git a/CMakeLists.txt b/CMakeLists.txt
index a13b35d..c7941af 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -378,20 +378,34 @@ if(CUDA_FOUND)
DEPENDS src/modelHandler_CUDA.cu
)
endif()
+ if (CUDA_VERSION_MAJOR LESS 10)
+ add_custom_command(
+ OUTPUT modelHandler_CUDA.ptx30.h
+ COMMAND ${CONV_EXE} modelHandler_CUDA.ptx30 modelHandler_CUDA.ptx30.h str
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/modelHandler_CUDA.ptx20 conv
+ )
+ add_custom_command(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/modelHandler_CUDA.ptx30
+ COMMAND ${CUDA_NVCC_EXECUTABLE} ${CUDA_NVCC_FLAGS} -arch=sm_30 -ptx -o ${CMAKE_CURRENT_BINARY_DIR}/modelHandler_CUDA.ptx30 ${CMAKE_CURRENT_SOURCE_DIR}/src/modelHandler_CUDA.cu
+ DEPENDS src/modelHandler_CUDA.cu
+ )
+ endif()
add_custom_command(
- OUTPUT modelHandler_CUDA.ptx30.h
- COMMAND ${CONV_EXE} modelHandler_CUDA.ptx30 modelHandler_CUDA.ptx30.h str
- DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/modelHandler_CUDA.ptx30 conv
+ OUTPUT modelHandler_CUDA.ptx35.h
+ COMMAND ${CONV_EXE} modelHandler_CUDA.ptx35 modelHandler_CUDA.ptx35.h str
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/modelHandler_CUDA.ptx35 conv
)
add_custom_command(
- OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/modelHandler_CUDA.ptx30
- COMMAND ${CUDA_NVCC_EXECUTABLE} ${CUDA_NVCC_FLAGS} -arch=sm_30 -ptx -o ${CMAKE_CURRENT_BINARY_DIR}/modelHandler_CUDA.ptx30 ${CMAKE_CURRENT_SOURCE_DIR}/src/modelHandler_CUDA.cu
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/modelHandler_CUDA.ptx35
+ COMMAND ${CUDA_NVCC_EXECUTABLE} ${CUDA_NVCC_FLAGS} -arch=sm_35 -ptx -o ${CMAKE_CURRENT_BINARY_DIR}/modelHandler_CUDA.ptx35 ${CMAKE_CURRENT_SOURCE_DIR}/src/modelHandler_CUDA.cu
DEPENDS src/modelHandler_CUDA.cu
)
if (CUDA_VERSION_MAJOR LESS 9)
set(GPU_CODE ${GPU_CODE} modelHandler_CUDA.ptx30.h modelHandler_CUDA.ptx20.h)
- else()
+ elseif (CUDA_VERSION_MAJOR LESS 10)
set(GPU_CODE ${GPU_CODE} modelHandler_CUDA.ptx30.h)
+ else()
+ set(GPU_CODE ${GPU_CODE} modelHandler_CUDA.ptx35.h)
endif()
endif()
diff --git a/src/modelHandler_CUDA.cpp b/src/modelHandler_CUDA.cpp
index af879fe..429200c 100644
--- a/src/modelHandler_CUDA.cpp
+++ b/src/modelHandler_CUDA.cpp
@@ -47,9 +47,14 @@ static void *handle;
static const char prog20[] =
#include "modelHandler_CUDA.ptx20.h"
;
- #endif // CUDART_VERSION < 9000
- static const char prog30[] =
- #include "modelHandler_CUDA.ptx30.h"
+ #endif // CUDART_VERSION < 10000
+ #if CUDART_VERSION < 10000
+ static const char prog30[] =
+ #include "modelHandler_CUDA.ptx30.h"
+ ;
+ #endif // CUDART_VERSION < 10000
+ static const char prog35[] =
+ #include "modelHandler_CUDA.ptx35.h"
;
#endif // HAVE_CUDA
@@ -172,9 +177,15 @@ namespace w2xc
return false;
}
- const char *prog = prog30;
+ const char *prog = prog35;
// cuda 9.0 doesn't support Compute 20
+#if CUDART_VERSION < 10000
+ if (cap_major < 3)
+ {
+ prog = prog30;
+ }
+#endif // CUDART_VERSION < 10000
#if CUDART_VERSION < 9000
if (cap_major < 3)
{ |
If you do not necessarily need to build the whole thing by yourself, you can get the AppImage here: |
If anyone looking at this issue is still experiencing the error and wants a one-line fix: Feel free to replace "sm_60" with your preferred value: |
fixed by PR #252 |
I try to compile it with CUDA 11 but failed.
I guess it is caused by 'Support for Kepler sm_30 architecture based products was dropped in CUDA 11'
log is here:
System Info:
Arch Linux
Rolling 2020-07-25
CUDA 11.0.2-1
The text was updated successfully, but these errors were encountered: