Skip to content

Commit

Permalink
[ORT 1.18.1 Release] Update ORT numpy dependency to >=1.21.6,<2.0 (#2…
Browse files Browse the repository at this point in the history
…1141)

### 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).
  • Loading branch information
adrianlizarraga committed Jun 24, 2024
1 parent d0aee20 commit 3871274
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 14 deletions.
8 changes: 0 additions & 8 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1390,14 +1390,6 @@ string(APPEND ORT_BUILD_INFO "build type=${CMAKE_BUILD_TYPE}")
string(APPEND ORT_BUILD_INFO ", cmake cxx flags: ${CMAKE_CXX_FLAGS}")
configure_file(onnxruntime_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/onnxruntime_config.h)
get_property(onnxruntime_GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if (onnxruntime_GENERATOR_IS_MULTI_CONFIG)
configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/Debug/requirements.txt)
configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/Release/requirements.txt)
configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/RelWithDebInfo/requirements.txt)
configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/MinSizeRel/requirements.txt)
else()
configure_file(../requirements.txt.in ${CMAKE_CURRENT_BINARY_DIR}/requirements.txt)
endif()

if (onnxruntime_USE_CUDA)
set(CMAKE_CUDA_RUNTIME_LIBRARY Shared)
Expand Down
3 changes: 3 additions & 0 deletions cmake/onnxruntime_python.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,9 @@ add_custom_command(
COMMAND ${CMAKE_COMMAND} -E copy
${ONNXRUNTIME_ROOT}/__init__.py
$<TARGET_FILE_DIR:${build_output_target}>/onnxruntime/
COMMAND ${CMAKE_COMMAND} -E copy
${REPO_ROOT}/requirements.txt
$<TARGET_FILE_DIR:${build_output_target}>
COMMAND ${CMAKE_COMMAND} -E copy
${REPO_ROOT}/ThirdPartyNotices.txt
$<TARGET_FILE_DIR:${build_output_target}>/onnxruntime/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
optimum>=1.14.1
transformers>=4.33.2,<= 4.37.2
torch>=2.2.0
numpy>=1.21.6,<2.0
onnx==1.16.0
datasets>=2.8.0
protobuf==3.20.2
psutil
psutil
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
numpy>=1.21.6,<2.0
onnx==1.16.0
transformers>=4.36.2
onnxscript>=0.1.0.dev20240126
1 change: 1 addition & 0 deletions onnxruntime/test/python/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
numpy>=1.21.6,<2.0
onnx==1.16.0
pytest
2 changes: 1 addition & 1 deletion requirements.txt.in → requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
coloredlogs
flatbuffers
numpy >= @Python_NumPy_VERSION@
numpy>=1.21.6,<2.0
packaging
protobuf
sympy
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ steps:
workingFolder: '$(Build.BinariesDirectory)'

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,4 @@ RUN ln -sf /usr/lib/x86_64-linux-gnu/libstdc++.so.6 ${CONDA_ENVIRONMENT_PATH}/bi
# Install migraphx
RUN apt update && apt install -y migraphx

RUN pip install numpy packaging ml_dtypes==0.3.0
RUN pip install "numpy>=1.21.6,<2.0" packaging ml_dtypes==0.3.0
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

pip3 install --user --upgrade pip

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

export PYTHONPATH=/onnxruntime_src/tools:/usr/local/lib/python3.8/site-packages:$PYTHONPATH
Expand Down
7 changes: 6 additions & 1 deletion tools/ci_build/github/windows/helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,12 @@ function Install-ONNX {
}

Write-Host "Installing python packages..."
[string[]]$pip_args = "-m", "pip", "install", "-qq", "--disable-pip-version-check", "setuptools>=68.2.2", "wheel", "numpy", "protobuf==$protobuf_version"

# Get the required numpy version from onnxruntime's requirements.txt (e.g., numpy>=1.21.6,<2.0)
$numpy_req_match_info = Get-Content "$src_root\requirements.txt" | Select-String -pattern 'numpy'
$numpy_to_install = $numpy_req_match_info.ToString()

[string[]]$pip_args = "-m", "pip", "install", "-qq", "--disable-pip-version-check", "setuptools>=68.2.2", "wheel", "$numpy_to_install", "protobuf==$protobuf_version"
&"python.exe" $pip_args
if ($lastExitCode -ne 0) {
exit $lastExitCode
Expand Down

0 comments on commit 3871274

Please sign in to comment.