Skip to content

Commit 3871274

Browse files
[ORT 1.18.1 Release] Update ORT numpy dependency to >=1.21.6,<2.0 (#21141)
### Description Updates the version of numpy required by onnxruntime to >=1.21.6,<2.0 ### Motivation and Context Numpy released version 2.0. The onnxruntime 1.18.1 release is using numpy < 2.0, so we need to update requirement files to only install versions between 1.21.6 and 2.0 (non-inclusive).
1 parent d0aee20 commit 3871274

File tree

10 files changed

+17
-14
lines changed

10 files changed

+17
-14
lines changed

cmake/CMakeLists.txt

-8
Original file line numberDiff line numberDiff line change
@@ -1390,14 +1390,6 @@ string(APPEND ORT_BUILD_INFO "build type=${CMAKE_BUILD_TYPE}")
13901390
string(APPEND ORT_BUILD_INFO ", cmake cxx flags: ${CMAKE_CXX_FLAGS}")
13911391
configure_file(onnxruntime_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/onnxruntime_config.h)
13921392
get_property(onnxruntime_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
1393-
if (onnxruntime_GENERATOR_IS_MULTI_CONFIG)
1394-
configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/Debug/requirements.txt)
1395-
configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/Release/requirements.txt)
1396-
configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/requirements.txt)
1397-
configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/MinSizeRel/requirements.txt)
1398-
else()
1399-
configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/requirements.txt)
1400-
endif()
14011393

14021394
if (onnxruntime_USE_CUDA)
14031395
set(CMAKE_CUDA_RUNTIME_LIBRARY Shared)

cmake/onnxruntime_python.cmake

+3
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,9 @@ add_custom_command(
565565
COMMAND ${CMAKE_COMMAND} -E copy
566566
${ONNXRUNTIME_ROOT}/__init__.py
567567
$<TARGET_FILE_DIR:${build_output_target}>/onnxruntime/
568+
COMMAND ${CMAKE_COMMAND} -E copy
569+
${REPO_ROOT}/requirements.txt
570+
$<TARGET_FILE_DIR:${build_output_target}>
568571
COMMAND ${CMAKE_COMMAND} -E copy
569572
${REPO_ROOT}/ThirdPartyNotices.txt
570573
$<TARGET_FILE_DIR:${build_output_target}>/onnxruntime/
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
optimum>=1.14.1
22
transformers>=4.33.2,<= 4.37.2
33
torch>=2.2.0
4+
numpy>=1.21.6,<2.0
45
onnx==1.16.0
56
datasets>=2.8.0
67
protobuf==3.20.2
7-
psutil
8+
psutil
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
numpy>=1.21.6,<2.0
12
onnx==1.16.0
23
transformers>=4.36.2
34
onnxscript>=0.1.0.dev20240126
+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1+
numpy>=1.21.6,<2.0
12
onnx==1.16.0
23
pytest
+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
coloredlogs
22
flatbuffers
3-
numpy >= @Python_NumPy_VERSION@
3+
numpy>=1.21.6,<2.0
44
packaging
55
protobuf
66
sympy

tools/ci_build/github/azure-pipelines/templates/jobs/win-ci-prebuild-steps.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ steps:
7474
workingFolder: '$(Build.BinariesDirectory)'
7575

7676
- script: |
77-
python -m pip install --upgrade "setuptools>=68.2.2" wheel numpy flatbuffers
77+
python -m pip install --upgrade "setuptools>=68.2.2" wheel "numpy>=1.21.6,<2.0" flatbuffers
7878
workingDirectory: '$(Build.BinariesDirectory)'
7979
displayName: 'Install python modules'
8080

tools/ci_build/github/linux/docker/migraphx-ci-pipeline-env.Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -80,4 +80,4 @@ RUN ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ${CONDA_ENVIRONMENT_PATH}/bi
8080
# Install migraphx
8181
RUN apt update && apt install -y migraphx
8282

83-
RUN pip install numpy packaging ml_dtypes==0.3.0
83+
RUN pip install "numpy>=1.21.6,<2.0" packaging ml_dtypes==0.3.0

tools/ci_build/github/linux/test_custom_ops_pytorch_export.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
pip3 install --user --upgrade pip
44

5-
pip3 install --user numpy==1.19.0 torch pytest
5+
pip3 install --user "numpy>=1.21.6,<2.0" torch pytest
66
pip3 install --user /build/Release/dist/*.whl
77

88
export PYTHONPATH=/onnxruntime_src/tools:/usr/local/lib/python3.8/site-packages:$PYTHONPATH

tools/ci_build/github/windows/helpers.ps1

+6-1
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,12 @@ function Install-ONNX {
637637
}
638638

639639
Write-Host "Installing python packages..."
640-
[string[]]$pip_args = "-m", "pip", "install", "-qq", "--disable-pip-version-check", "setuptools>=68.2.2", "wheel", "numpy", "protobuf==$protobuf_version"
640+
641+
# Get the required numpy version from onnxruntime's requirements.txt (e.g., numpy>=1.21.6,<2.0)
642+
$numpy_req_match_info = Get-Content "$src_root\requirements.txt" | Select-String -pattern 'numpy'
643+
$numpy_to_install = $numpy_req_match_info.ToString()
644+
645+
[string[]]$pip_args = "-m", "pip", "install", "-qq", "--disable-pip-version-check", "setuptools>=68.2.2", "wheel", "$numpy_to_install", "protobuf==$protobuf_version"
641646
&"python.exe" $pip_args
642647
if ($lastExitCode -ne 0) {
643648
exit $lastExitCode

0 commit comments

Comments
 (0)