Skip to content

Commit 5bfca1d

Browse files
authored
[Build] Change onnxruntime_NVCC_THREADS from option to cache entry (#20768)
### Description Changes the `onnxruntime_NVCC_THREADS` CMake variable from an [`option`](https://cmake.org/cmake/help/latest/command/option.html) to a [cache entry](https://cmake.org/cmake/help/latest/command/set.html#set-cache-entry). ### Motivation and Context Fixes #19833. `option` in CMake (confusingly, IMHO) always defines a *boolean* option. The original definition of `onnxruntime_NVCC_THREADS` specified a default of `1`, which I presume is coerced to `ON`. Thus, if the option is not overridden with a value of another type, NVCC will receive a malformed option `--threads ON` (rather than the expected `--threads 1`), which causes the error reported in #19833. This error only occurred if compiling ONNX Runtime via CMake with `-Donnxruntime_USE_CUDA=ON`; the CI build script always overrode `onnxruntime_NVCC_THREADS` with a string value: https://github.com/microsoft/onnxruntime/blob/f1fef19b6e248023ec23b85bea8644ab2b95e831/tools/ci_build/build.py#L1152-L1154
1 parent 798cea2 commit 5bfca1d

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

cmake/onnxruntime_providers_cuda.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@
153153
# CUDA 11.3+ supports parallel compilation
154154
# https://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/index.html#options-for-guiding-compiler-driver-threads
155155
if (CMAKE_CUDA_COMPILER_VERSION VERSION_GREATER_EQUAL 11.3)
156-
option(onnxruntime_NVCC_THREADS "Number of threads that NVCC can use for compilation." 1)
156+
set(onnxruntime_NVCC_THREADS "1" CACHE STRING "Number of threads that NVCC can use for compilation.")
157157
target_compile_options(${target} PRIVATE "$<$<COMPILE_LANGUAGE:CUDA>:SHELL:--threads \"${onnxruntime_NVCC_THREADS}\">")
158158
endif()
159159

0 commit comments

Comments
 (0)