From d053dfd5fcc79e2e413150e3d27e04458050a5ad Mon Sep 17 00:00:00 2001 From: Zeng Jinle <32832641+sneaxiy@users.noreply.github.com> Date: Wed, 22 Apr 2020 12:49:06 +0800 Subject: [PATCH] fix cuda arch detection (#24036) --- cmake/cuda.cmake | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/cmake/cuda.cmake b/cmake/cuda.cmake index 514937f760d..170a8667e0b 100644 --- a/cmake/cuda.cmake +++ b/cmake/cuda.cmake @@ -26,7 +26,9 @@ function(detect_installed_gpus out_variable) set(cufile ${PROJECT_BINARY_DIR}/detect_cuda_archs.cu) file(WRITE ${cufile} "" - "#include \n" + "#include \"stdio.h\"\n" + "#include \"cuda.h\"\n" + "#include \"cuda_runtime.h\"\n" "int main() {\n" " int count = 0;\n" " if (cudaSuccess != cudaGetDeviceCount(&count)) return -1;\n" @@ -34,12 +36,12 @@ function(detect_installed_gpus out_variable) " for (int device = 0; device < count; ++device) {\n" " cudaDeviceProp prop;\n" " if (cudaSuccess == cudaGetDeviceProperties(&prop, device))\n" - " std::printf(\"%d.%d \", prop.major, prop.minor);\n" + " printf(\"%d.%d \", prop.major, prop.minor);\n" " }\n" " return 0;\n" "}\n") - execute_process(COMMAND "${CUDA_NVCC_EXECUTABLE}" "-ccbin=${CUDA_HOST_COMPILER}" + execute_process(COMMAND "${CUDA_NVCC_EXECUTABLE}" "--run" "${cufile}" WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/CMakeFiles/" RESULT_VARIABLE nvcc_res OUTPUT_VARIABLE nvcc_out -- GitLab