diff --git a/cmake/onnxruntime_providers.cmake b/cmake/onnxruntime_providers.cmake index 7844ba4ee4..60e9d799f6 100644 --- a/cmake/onnxruntime_providers.cmake +++ b/cmake/onnxruntime_providers.cmake @@ -326,6 +326,11 @@ if (onnxruntime_USE_CUDA) foreach(ORT_FLAG ${ORT_WARNING_FLAGS}) target_compile_options(onnxruntime_providers_cuda PRIVATE "$<$:SHELL:-Xcompiler \"${ORT_FLAG}\">") endforeach() + # CUDA 11.3+ supports parallel compilation + # https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#options-for-guiding-compiler-driver-threads + if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.3) + target_compile_options(onnxruntime_providers_cuda PRIVATE "$<$:SHELL:--threads \"${onnxruntime_NVCC_THREADS}\">") + endif() if (onnxruntime_DEV_MODE) if (UNIX) target_compile_options(onnxruntime_providers_cuda PRIVATE "$<$:SHELL:-Xcompiler -Wno-reorder>" diff --git a/tools/ci_build/build.py b/tools/ci_build/build.py index 793fced048..7898d972ae 100644 --- a/tools/ci_build/build.py +++ b/tools/ci_build/build.py @@ -813,6 +813,7 @@ def generate_build_tree(cmake_path, source_dir, build_dir, cuda_home, cudnn_home "-Donnxruntime_ENABLE_EAGER_MODE=" + ("ON" if args.build_eager_mode else "OFF"), "-Donnxruntime_ENABLE_EXTERNAL_CUSTOM_OP_SCHEMAS=" + ("ON" if args.enable_external_custom_op_schemas else "OFF"), + "-Donnxruntime_NVCC_THREADS=" + str(args.parallel), ] # It should be default ON in CI build pipelines, and OFF in packaging pipelines. # And OFF for the people who are not actively developing onnx runtime.