Skip to content

Commit

Permalink
Set CMAKE_CUDA_COMPILER
Browse files Browse the repository at this point in the history
  • Loading branch information
jchen351 committed Jan 24, 2024
1 parent cff8ce6 commit 14d6775
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
7 changes: 3 additions & 4 deletions .github/workflows/win-gpu-x64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
ort_url: "https://github.com/microsoft/onnxruntime/releases/download/v1.16.3/onnxruntime-win-x64-gpu-1.16.3.zip"
cuda_dir: "${{ github.workspace }}\\cuda_sdk"
cuda_version: "12.2"
CUDA_PATH: "${{ env.cuda_dir }}\\v${{ env.cuda_version }}"

jobs:
Windows-CUDA-12-Build:
Expand Down Expand Up @@ -50,10 +51,8 @@ jobs:
run: |
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A x64 .. \
-DCMAKE_BUILD_TYPE=Release -DUSE_CUDA=TRUE \
-DCUDAToolkit_ROOT=${{ env.cuda_dir }}\\v${{ env.cuda_version }} \
-DCMAKE_CUDA_COMPILER=${{ env.cuda_dir }}\\v${{ env.cuda_version }}\\bin\\nvcc.exe
cmake -G "Visual Studio 17 2022" -A x64 .. -DCMAKE_BUILD_TYPE=Release -DUSE_CUDA=TRUE -DCUDAToolkit_ROOT=${{ env.cuda_dir }}\\v${{ env.cuda_version }}
# -DCMAKE_CUDA_COMPILER=${{ env.cuda_dir }}\\v${{ env.cuda_version }}\\bin\\nvcc.exe
cmake --build . --config Release --parallel

- name: Verify Build Artifacts
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ set(USE_ORT_EXT 0) # "Build with Onnxruntime Extensions tokenizer support"
# Checking if CUDA is supported
include(FindCUDAToolkit)
if (CUDAToolkit_FOUND)
set (CUDA_FOUND TRUE)
message(STATUS "CUDA found CUDAToolkit_VERSION ${CUDAToolkit_VERSION} with CMAKE_CUDA_COMPILER ${CMAKE_CUDA_COMPILER}" )
else()
message(STATUS "CUDA not found")
endif()
Expand All @@ -36,7 +36,7 @@ set(PYBIND_ROOT ${PROJECT_SOURCE_DIR}/src/pybind)

# CUDA Being enabled will make it not a debug build without this option, so all of the C++ headers will complain
# about a mismatch with the actual debug headers and it'll fail to link. I don't know why this happens, or if this is the best fix.
if(USE_CUDA AND CUDA_FOUND AND CMAKE_BUILD_TYPE STREQUAL "Debug")
if(USE_CUDA AND CUDAToolkit_FOUND AND CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(_DEBUG=1)
endif()

Expand All @@ -59,7 +59,7 @@ file(GLOB pybind_srcs CMAKE_CONFIGURE_DEPENDS
"${PYBIND_ROOT}/*.cpp"
)

if(USE_CUDA AND CUDA_FOUND)
if(USE_CUDA AND CUDAToolkit_FOUND)
# Don't let cmake set a default value for CMAKE_CUDA_ARCHITECTURES
cmake_policy(SET CMP0104 OLD)
enable_language(CUDA)
Expand Down

0 comments on commit 14d6775

Please sign in to comment.