Skip to content

Commit 2f9595a

Browse files
authored
Fix the pipeline breaks dues to the MSVC 19.40 and numpy 2.0 release (#747)
* dd "-allow-unsupported-compiler" flags to Windows CUDA flags inspired by this PR: microsoft/onnxruntime#21004 * switch to cmake command line * handle the issues caused by the latest MSVC release * correct the typo * correct the parameter * try one dash again * use the installed cmake * use cmake standalone installation firstly * use the standalone cmake in win32 python too * fix it more * one more try * fix the MacOS pipeline issue * fix the pip command line
1 parent 3c22daa commit 2f9595a

File tree

6 files changed

+53
-16
lines changed

6 files changed

+53
-16
lines changed

.pipelines/ci.yml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ stages:
126126

127127
- script: |
128128
python -m pip install --upgrade setuptools pip
129-
python -m pip install numpy
129+
python -m pip install 'numpy < 2.0.0'
130130
export OCOS_NO_OPENCV=1
131131
export OCOS_SCB_DEBUG=1
132132
CPU_NUMBER=8 python -m pip install -e .
@@ -322,6 +322,7 @@ stages:
322322
python -m pip install --upgrade pip
323323
python -m pip install --upgrade setuptools
324324
python -m pip install --upgrade wheel
325+
python -m pip install 'numpy < 2.0.0'
325326
python -m pip install onnxruntime==$(ort.version)
326327
displayName: Install requirements
327328
@@ -513,7 +514,7 @@ stages:
513514

514515
- script: |
515516
python -m pip install --upgrade setuptools pip
516-
python -m pip install numpy
517+
python -m pip install "numpy < 2.0.0"
517518
set OCOS_NO_OPENCV=1
518519
set OCOS_SCB_DEBUG=1
519520
python -m pip install -v -e .
@@ -570,7 +571,9 @@ stages:
570571

571572
- script: |
572573
set CUDA_PATH=$(Agent.TempDirectory)\v11.8
573-
call .\build.bat -T cuda="%CUDA_PATH%" -DOCOS_ENABLE_CTEST=ON -DOCOS_USE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=70;86^
574+
call .\build.bat -T cuda="%CUDA_PATH%" -DOCOS_ENABLE_CTEST=ON^
575+
-DCMAKE_CUDA_FLAGS_INIT=-allow-unsupported-compiler^
576+
-DOCOS_USE_CUDA=ON -DCMAKE_CUDA_ARCHITECTURES=70;86^
574577
-DOCOS_ONNXRUNTIME_VERSION="$(ORT_VERSION)" -DONNXRUNTIME_PKG_DIR=.\onnxruntime-win-x64-gpu-$(ORT_VERSION)
575578
displayName: build the customop library with onnxruntime
576579
@@ -590,7 +593,7 @@ stages:
590593
- script: |
591594
set CUDA_PATH=$(Agent.TempDirectory)\v11.8
592595
python -m pip install --upgrade setuptools pip
593-
python -m pip install numpy coloredlogs flatbuffers packaging protobuf sympy
596+
python -m pip install "numpy < 2.0.0" coloredlogs flatbuffers packaging protobuf sympy
594597
python -m pip install onnxruntime-gpu==$(ORT_VERSION)
595598
python -m pip install -v --config-settings "ortx-user-option=use-cuda,cuda_archs=70;86" .
596599
displayName: Build and install onnxruntime-extensions CUDA package.

.pyproject/cmdclass.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ def build_cmake(self, extension):
226226
if sys.platform == "win32":
227227
cuda_path = os.environ.get("CUDA_PATH")
228228
cmake_args += [f'-T cuda={cuda_path}']
229+
# TODO: temporarily add a flag for MSVC 19.40
230+
cmake_args += ['-DCMAKE_CUDA_FLAGS_INIT=-allow-unsupported-compiler']
229231
f_ver = ext_fullpath.parent / "_version.py"
230232
with f_ver.open('a') as _f:
231233
_f.writelines(["\n", f"cuda = \"{cuda_ver}\"", "\n"])
@@ -235,7 +237,8 @@ def build_cmake(self, extension):
235237
else:
236238
smi = _load_nvidia_smi()
237239
if not smi:
238-
raise RuntimeError(f"Cannot detect the CUDA archs from your machine, please specify it by yourself.")
240+
raise RuntimeError(
241+
"Cannot detect the CUDA archs from your machine, please specify it manually.")
239242
cmake_args += ['-DCMAKE_CUDA_ARCHITECTURES=' + smi]
240243

241244
# CMake lets you override the generator - we need to check this.
@@ -274,7 +277,6 @@ def build_cmake(self, extension):
274277
cmake_args += [
275278
"-DCMAKE_OSX_ARCHITECTURES={}".format(";".join(archs))]
276279

277-
278280
# overwrite the Python module info if the auto-detection doesn't work.
279281
# export Python3_INCLUDE_DIRS=/opt/python/cp38-cp38
280282
# export Python3_LIBRARIES=/opt/python/cp38-cp38
@@ -292,14 +294,18 @@ def build_cmake(self, extension):
292294
'--parallel' + ('' if cpu_number is None else ' ' + cpu_number)
293295
]
294296
cmake_exe = 'cmake'
295-
# unlike Linux/macOS, cmake pip package on Windows fails to build some 3rd party dependencies.
296-
# so we have to use the cmake installed from Visual Studio.
297-
if os.environ.get(VSINSTALLDIR_NAME):
298-
cmake_exe = os.environ[VSINSTALLDIR_NAME] + \
299-
'Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin\\cmake.exe'
300-
# Add this cmake directory into PATH to make sure the child-process still find it.
301-
os.environ['PATH'] = os.path.dirname(
302-
cmake_exe) + os.pathsep + os.environ['PATH']
297+
# if sys.platform == "win32":
298+
# # unlike Linux/macOS, cmake pip package on Windows fails to build some 3rd party dependencies.
299+
# # so we have to use the cmake from a standalone installation or the one from Visual Studio.
300+
# standalone_cmake = os.path.join(os.environ.get("ProgramFiles"), "\\CMake\\bin\\cmake.exe")
301+
# if os.path.exists(standalone_cmake):
302+
# cmake_exe = standalone_cmake
303+
# elif os.environ.get(VSINSTALLDIR_NAME):
304+
# cmake_exe = os.environ[VSINSTALLDIR_NAME] + \
305+
# 'Common7\\IDE\\CommonExtensions\\Microsoft\\CMake\\CMake\\bin\\cmake.exe'
306+
# # Add this cmake directory into PATH to make sure the child-process still find it.
307+
# os.environ['PATH'] = os.path.dirname(
308+
# cmake_exe) + os.pathsep + os.environ['PATH']
303309

304310
self.spawn([cmake_exe, '-S', str(project_dir),
305311
'-B', str(build_temp)] + cmake_args)

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
3636
cmake_policy(SET CMP0077 NEW)
3737
endif()
3838

39+
# Avoid warning of Calling FetchContent_Populate(GSL) is deprecated
40+
if(CMAKE_VERSION VERSION_GREATER_EQUAL "3.30.0")
41+
cmake_policy(CMP0169 OLD)
42+
endif()
43+
3944
# Needed for Java
4045
set(CMAKE_C_STANDARD 99)
4146

build.bat

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
11
@ECHO OFF
22
SETLOCAL ENABLEDELAYEDEXPANSION
3+
4+
IF NOT EXIST "%ProgramFiles%\CMake\bin\cmake.exe" GOTO :FIND_VS
5+
set cmake_exe="%ProgramFiles%\CMake\bin\cmake.exe"
6+
7+
:FIND_VS
38
IF DEFINED VSINSTALLDIR GOTO :VSDEV_CMD
49
set _VSFINDER=%~dp0tools\get_vsdevcmd.ps1
510
for /f "tokens=* USEBACKQ" %%i in (
611
`powershell -NoProfile -ExecutionPolicy Bypass -File "%_VSFINDER%"`) do call "%%i"
712

813
IF NOT DEFINED VSINSTALLDIR GOTO :NOT_FOUND
914

15+
IF DEFINED cmake_exe GOTO :CMAKE_DEF
16+
set cmake_exe="%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
17+
18+
:CMAKE_DEF
1019
IF "%1" == "-A" GOTO :VSDEV_CMD
1120
set GEN_PLATFORM=-A x64
1221

@@ -16,8 +25,8 @@ IF "%VisualStudioVersion:~0,2%" == "16" GOTO :START_BUILD
1625
set GENERATOR="Visual Studio 17 2022"
1726

1827
:START_BUILD
19-
set cmake_exe="%VSINSTALLDIR%Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake.exe"
2028
mkdir .\out\Windows\ 2>NUL
29+
ECHO %cmake_exe% -G %GENERATOR% %GEN_PLATFORM% %* -B out\Windows -S .
2130
%cmake_exe% -G %GENERATOR% %GEN_PLATFORM% %* -B out\Windows -S .
2231
IF %ERRORLEVEL% NEQ 0 EXIT /B %ERRORLEVEL%
2332
%cmake_exe% --build out\Windows --config RelWithDebInfo

cmake/externals/opencv-no-rtti.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,19 @@ index d95e5db163..db185453df 100644
3939
include(cmake/OpenCVCompilerOptions.cmake)
4040

4141
ocv_cmake_hook(POST_COMPILER_OPTIONS)
42+
diff --git a/cmake/OpenCVDetectCXXCompiler.cmake b/cmake/OpenCVDetectCXXCompiler.cmake
43+
index 7f229cde96..92e204a5b9 100644
44+
--- a/cmake/OpenCVDetectCXXCompiler.cmake
45+
+++ b/cmake/OpenCVDetectCXXCompiler.cmake
46+
@@ -171,7 +171,7 @@ elseif(MSVC)
47+
set(OpenCV_RUNTIME vc15)
48+
elseif(MSVC_VERSION MATCHES "^192[0-9]$")
49+
set(OpenCV_RUNTIME vc16)
50+
- elseif(MSVC_VERSION MATCHES "^193[0-9]$")
51+
+ elseif(MSVC_VERSION MATCHES "^19[34][0-9]$")
52+
set(OpenCV_RUNTIME vc17)
53+
else()
54+
message(WARNING "OpenCV does not recognize MSVC_VERSION \"${MSVC_VERSION}\". Cannot set OpenCV_RUNTIME")
4255
diff --git a/modules/core/include/opencv2/core/ocl.hpp b/modules/core/include/opencv2/core/ocl.hpp
4356
index 4503fa00dd..642b0508d0 100644
4457
--- a/modules/core/include/opencv2/core/ocl.hpp

requirements-dev.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
pytest
2-
onnx >= 1.9.0
2+
numpy < 2.0.0
3+
onnx >=1.9.0
34
protobuf < 4.0.0
45
# multiple versions of onnxruntime are supported, but only one can be installed at a time
56
onnxruntime >=1.12.0

0 commit comments

Comments
 (0)