Skip to content

Commit

Permalink
Merge pull request #33 from microsoft/Cjian/fix-linux-gpu
Browse files Browse the repository at this point in the history
Fix CUDAToolkit_ROOT
  • Loading branch information
jchen351 authored Jan 25, 2024
2 parents b07e369 + c557c2e commit 5824bf1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux-gpu-x64-build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Linux GPU x64 Build"
on: [ workflow_dispatch, pull_request ]
on: [ workflow_dispatch ]

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
Expand Down
9 changes: 6 additions & 3 deletions .github/workflows/win-gpu-x64-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ env:
ort_dir: "onnxruntime-win-x64-gpu-1.16.3"
ort_zip: "onnxruntime-win-x64-gpu-1.16.3.zip"
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"

jobs:
Windows-CUDA-12-Build:
Expand All @@ -25,7 +27,8 @@ jobs:
architecture: 'x64'

- name: Download cuda
run: azcopy.exe cp --recursive "https://lotusscus.blob.core.windows.net/models/cuda_sdk/v12.2" cuda_sdk
run: |
azcopy.exe cp --recursive "https://lotusscus.blob.core.windows.net/models/cuda_sdk/v${{ env.cuda_version }}" ${{ env.cuda_dir}}
- name: Download OnnxRuntime
run: |
Expand All @@ -42,12 +45,12 @@ jobs:
- name: Git Submodule Update
run: |
git submodule update --init --recursive
# The build machine doesn't have a GPU. So the value of CMAKE_CUDA_ARCHITECTURES doesn't matter.
- name: Build with CMake
run: |
mkdir build
cd build
cmake -G "Visual Studio 17 2022" -A x64 .. -DCMAKE_BUILD_TYPE=Release -DUSE_CUDA=TRUE
cmake -G "Visual Studio 17 2022" -A x64 -T cuda=${{ env.cuda_dir }}\\v${{ env.cuda_version }} .. -DCMAKE_BUILD_TYPE=Release -DUSE_CUDA=TRUE
cmake --build . --config Release --parallel
- name: Verify Build Artifacts
Expand Down
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ set(USE_ORT_EXT 0) # "Build with Onnxruntime Extensions tokenizer support"
include(CheckLanguage)
check_language(CUDA)
if (CMAKE_CUDA_COMPILER)
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()

if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 9)
Expand All @@ -35,7 +37,7 @@ set(PYTHON_ROOT ${PROJECT_SOURCE_DIR}/src/python)

# 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 CMAKE_CUDA_COMPILER AND CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(_DEBUG=1)
endif()

Expand All @@ -58,7 +60,7 @@ file(GLOB python_srcs CMAKE_CONFIGURE_DEPENDS
"${PYTHON_ROOT}/*.cpp"
)

if(USE_CUDA AND CUDA_FOUND)
if(USE_CUDA AND CMAKE_CUDA_COMPILER)
# 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 5824bf1

Please sign in to comment.