microsoft/onnxruntime

[Feature Request] Python 3.12 support

tonybaloney opened this issue · 11 comments

Describe the feature request

this package cannot be installed using Python 3.12 and is only publishing wheels, so cannot be compiled from source/

Describe scenario use case

Please publish Python 3.12 wheels

Side note, if the maintainers haven't already checked out cibuildwheel, I think this project could use it and remove a lot of the scripts that have been written to accomplish the same thing (building lots of wheels and doing manylinux linking from a CMake project) https://github.com/pypa/cibuildwheel

snnn commented

Yeah, it is a great choice. onnxruntime-extensions packages are built with that tool.

I tried to enable it for this repo too:
a0af414

However, I didn't have enough time to finish the work. We need to let setup.py invoking tools/ci_build/build.py, not the reverse. And once we have that, we could also easily publish a sdist.

However, cibuildwheel tool has cons too. It needs to download a lot of things from the public internet. So I have reliability and security concerns on that.

[...] so cannot be compiled from source

Until ORT 1.17 is released, you can compile from source by following the build instructions.

To build for my arm-based Mac, I added a --build_wheel argument to the ./build.sh call, to build python wheels directly.
Afterwards you can find the .whl file under build/[...]/dist/.

Commands I used inside my 3.12 conda env on M3 Pro Mac:

./build.sh --config Release --build_shared_lib --parallel --enable_pybind --skip_tests --build_wheel  --update --build --cmake_extra_defines CMAKE_OSX_ARCHITECTURES=arm64
pip3 install --upgrade /Users/tim.bodeit/repos/onnxruntime/build/MacOS/Release/dist/onnxruntime-1.17.0-cp312-cp312-macosx_14_0_arm64.whl

Thanks @timbodeit. Took me a while to get the build environment working under windows and had to build with --skip_tests (like you did) but in the end I could build 1.17 wheels.

I had to add the windows 10 SDK to the VS 2022 build tools. The build was still looking for the wrong version in C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC which I "solved" by copying the version I had to the one build was looking for.

I tried to build for windows but it was building only onnxruntime-1.17.0-cp312-cp312-win32.whl until I added call "%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" amd64 just before the python call in build.bat. Then it generated onnxruntime-1.17.0-cp312-cp312-win_amd64.whl

snnn commented

I tried to build for windows but it was building only onnxruntime-1.17.0-cp312-cp312-win32.whl until I added call "%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" amd64 just before the python call in build.bat. Then it generated onnxruntime-1.17.0-cp312-cp312-win_amd64.whl

You might have two Pythons in your system. If you run the build with a 32-bit python, you will have a 32-bit wheel. If you run the build with a 64-bit python, you will have a 64-bit wheel.

I only have one 64-bit python in my path (the Microsoft app one, which states "Architecture: x64")

vcvarsall.bat amd64 performs a lot of environment setup, some of which probably did the trick. Here's a diff of environment variable changes that occur after running it:
image

[...] so cannot be compiled from source

Until ORT 1.17 is released, you can compile from source by following the build instructions.

To build for my arm-based Mac, I added a --build_wheel argument to the ./build.sh call, to build python wheels directly. Afterwards you can find the .whl file under build/[...]/dist/.

Commands I used inside my 3.12 conda env on M3 Pro Mac:

./build.sh --config Release --build_shared_lib --parallel --enable_pybind --skip_tests --build_wheel  --update --build --cmake_extra_defines CMAKE_OSX_ARCHITECTURES=arm64
pip3 install --upgrade /Users/tim.bodeit/repos/onnxruntime/build/MacOS/Release/dist/onnxruntime-1.17.0-cp312-cp312-macosx_14_0_arm64.whl

Is there a way of building onnxruntime-gpu with this? I cannot find any reference to this in the build docs

snnn commented

No. MacOS doesn't support CUDA.

No. MacOS doesn't support CUDA.

I am building for windows

snnn commented

ONNX Runtime 1.17.0 is released with this new feature.