Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Windows support #56

Merged
merged 5 commits into from
Jun 21, 2023
Merged

Add Windows support #56

merged 5 commits into from
Jun 21, 2023

Conversation

traversaro
Copy link
Contributor

@traversaro traversaro commented Apr 14, 2023

Based on #10 .

Main important things to know:

  • Due to the fact that a onnxruntime.dll is shipped by Windows in C:\Windows\system32\, we can't use that name in our package. To avoid this problem, we rename our dll to onnxruntime_conda.dll, see Add Windows support  #56 (comment) .
  • Even if we did not explicitly dependenced on protobuf, a conda-forge version of protobuf was used, even if we agreed to concentrated on using vendored dependencies for now (). So we pass CMAKE_DISABLE_FIND_PACKAGE_Protobuf=ON to make sure that the vendored Protobuf is used, see Add Windows support  #56 (comment) .

Checklist

  • Used a personal fork of the feedstock to propose changes
  • Bumped the build number (if the version is unchanged)
  • Reset the build number to 0 (if the version changed)
  • Re-rendered with the latest conda-smithy (Use the phrase @conda-forge-admin, please rerender in a comment in this PR for automated rerendering)
  • Ensured the license file is being packaged.

@conda-forge-webservices
Copy link
Contributor

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@traversaro
Copy link
Contributor Author

@conda-forge-admin, please rerender

Copy link
Contributor

@cbourjau cbourjau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have much experience packaging for Windows but maybe we can try to get things to build without the tests first?

recipe/bld.bat Outdated Show resolved Hide resolved
@traversaro
Copy link
Contributor Author

I don't have much experience packaging for Windows but maybe we can try to get things to build without the tests first?

Good point, I kind of left this in an incomplete state, as I think before going for Windows probably it could make sense to go for de-venderoing, that should simplify also the Windows build: #57 .

@traversaro
Copy link
Contributor Author

I don't have much experience packaging for Windows but maybe we can try to get things to build without the tests first?

Good point, I kind of left this in an incomplete state, as I think before going for Windows probably it could make sense to go for de-venderoing, that should simplify also the Windows build: #57 .

Ahs sorry, I did not see your comment there.

@cbourjau
Copy link
Contributor

cbourjau commented May 3, 2023

@traversaro are there any updates or do you have open questions? I think supporting Windows would be very nice!

@traversaro
Copy link
Contributor Author

@traversaro are there any updates or do you have open questions? I think supporting Windows would be very nice!

Sorry for the radio silence, see #57 (comment) for more context. I plan to work on this in the near future.

@traversaro
Copy link
Contributor Author

@conda-forge-admin, please rerender

@traversaro
Copy link
Contributor Author

Cool, Windows fails with:

2023-06-09T16:46:05.6721585Z %SRC_DIR%\onnxruntime\test\contrib_ops\longformer_attention_op_test.cc : fatal error C1085: Cannot write compiler generated file: '%SRC_DIR%\build-ci\Release\CMakeFiles\onnxruntime_test_all.dir\D_\bld\onnxruntime_1686326253701\work\onnxruntime\test\contrib_ops\longformer_attention_op_test.cc.obj': No space left on device

While I could disable tests to save some space, let me check if there is some other way.

@traversaro
Copy link
Contributor Author

Cool, Windows fails with:

2023-06-09T16:46:05.6721585Z %SRC_DIR%\onnxruntime\test\contrib_ops\longformer_attention_op_test.cc : fatal error C1085: Cannot write compiler generated file: '%SRC_DIR%\build-ci\Release\CMakeFiles\onnxruntime_test_all.dir\D_\bld\onnxruntime_1686326253701\work\onnxruntime\test\contrib_ops\longformer_attention_op_test.cc.obj': No space left on device

While I could disable tests to save some space, let me check if there is some other way.

I tried with b4a85b3 .

@traversaro
Copy link
Contributor Author

@conda-forge-admin, please rerender

@conda-forge-webservices
Copy link
Contributor

Hi! This is the friendly automated conda-forge-linting service.

I wanted to let you know that I linted all conda-recipes in your PR (recipe) and found some lint.

Here's what I've got...

For recipe:

  • Failed to even lint the recipe, probably because of a conda-smithy bug 😢. This likely indicates a problem in your meta.yaml, though. To get a traceback to help figure out what's going on, install conda-smithy and run conda smithy recipe-lint . from the recipe directory.

@traversaro
Copy link
Contributor Author

While debugging locally, I found quite a tricky problem. By default the onnxruntime build a onnxruntime.dll file. If I try to compile the test against it, I get the error:

(onnxtest) C:\src\onnxruntime-feedstock\recipe>.\test.exe
The given version [15] is not supported, only version 1 to 7 is supported in this build.

Why this happens? Basically because apparently Windows ships a onnxruntime.dll file in C:\Windows\system32\onnxruntime.dll, and according to .dll search order in Windows ( https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order ) anything that is found in C:\Windows\system32 has a higher priority w.r.t. to anything found in the PATH . See microsoft/onnxruntime#11230 for more details.

To avoid this issue, probably we should rename onnxruntime.dll to onnxruntime_conda.dll, as done in the past for other packages such as qt-main. The main problem of this approach is that at the moment onnxruntime does not ship any .pc pkg-config file or onnxruntime-config.cmake CMake config files, so basically this name difference needs to be accounted for in downstream build systems.

@traversaro
Copy link
Contributor Author

@conda-forge-admin, please rerender

@github-actions
Copy link
Contributor

Hi! This is the friendly automated conda-forge-webservice.

I tried to rerender for you but ran into some issues. Please check the output logs of the latest rerendering GitHub actions workflow run for errors. You can also ping conda-forge/core for further assistance or try re-rendering locally.

This message was generated by GitHub actions workflow run https://github.com/conda-forge/onnxruntime-feedstock/actions/runs/5234695625.

@conda-forge-webservices
Copy link
Contributor

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@traversaro
Copy link
Contributor Author

@conda-forge-admin, please rerender

@github-actions
Copy link
Contributor

Hi! This is the friendly automated conda-forge-webservice.

I tried to rerender for you but ran into some issues. Please check the output logs of the latest rerendering GitHub actions workflow run for errors. You can also ping conda-forge/core for further assistance or try re-rendering locally.

This message was generated by GitHub actions workflow run https://github.com/conda-forge/onnxruntime-feedstock/actions/runs/5234710097.

@traversaro
Copy link
Contributor Author

We are almost there:

2023-06-11T10:39:23.5680489Z [1133/1142] Linking CXX executable onnxruntime_test_all.exe
2023-06-11T10:39:23.5680829Z FAILED: onnxruntime_test_all.exe 
2023-06-11T10:39:23.5694971Z cmd.exe /C "cmd.exe /C "cd /D %SRC_DIR%\build-ci\Release && %BUILD_PREFIX%\Library\bin\cmake.exe -E copy_directory C:/bld/onnxruntime-novec_1686477126258/work/onnxruntime/test/testdata C:/bld/onnxruntime-novec_1686477126258/work/build-ci/Release/testdata && cd /D %SRC_DIR%\build-ci\Release && %BUILD_PREFIX%\Library\bin\cmake.exe -E copy_directory C:/bld/onnxruntime-novec_1686477126258/work/samples C:/bld/onnxruntime-novec_1686477126258/work/build-ci/Release/samples && cd %SRC_DIR%\build-ci\Release" && %BUILD_PREFIX%\Library\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\onnxruntime_test_all.dir --rc=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\rc.exe --mt=C:\PROGRA~2\WI3CF2~1\10\bin\100226~1.0\x64\mt.exe --manifests  -- C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\HostX64\x64\link.exe /nologo @CMakeFiles\onnxruntime_test_all.rsp  /out:onnxruntime_test_all.exe /implib:onnxruntime_test_all.lib /pdb:onnxruntime_test_all.pdb /version:0.0 /machine:x64 /DYNAMICBASE /guard:cf /INCREMENTAL:NO /OPT:REF,ICF,LBR /INCREMENTAL:NO /LTCG /subsystem:console  /CETCOMPAT /INCREMENTAL:NO /LTCG  && cd ."
2023-06-11T10:39:23.7336562Z LINK: command "C:\PROGRA~1\MICROS~2\2022\ENTERP~1\VC\Tools\MSVC\1429~1.301\bin\HostX64\x64\link.exe /nologo @CMakeFiles\onnxruntime_test_all.rsp /out:onnxruntime_test_all.exe /implib:onnxruntime_test_all.lib /pdb:onnxruntime_test_all.pdb /version:0.0 /machine:x64 /DYNAMICBASE /guard:cf /INCREMENTAL:NO /OPT:REF,ICF,LBR /INCREMENTAL:NO /LTCG /subsystem:console /CETCOMPAT /INCREMENTAL:NO /LTCG /MANIFEST /MANIFESTFILE:onnxruntime_test_all.exe.manifest" failed (exit code 1257) with the following output:
2023-06-11T10:39:23.7338635Z LINK : warning LNK4044: unrecognized option '/lpthreads'; ignored
2023-06-11T10:39:23.7339557Z 
2023-06-11T10:39:23.7339557Z 
2023-06-11T10:39:23.7340056Z fatal error C1002: compiler is out of heap space in pass 2
2023-06-11T10:39:23.7340408Z 
2023-06-11T10:39:23.7341366Z LINK : fatal error LNK1257: code generation failed
2023-06-11T10:39:23.7341752Z 

The compiler is out of heap space, so probably we need to reduce the number of concurrent threads.

@traversaro
Copy link
Contributor Author

To avoid this issue, probably we should rename onnxruntime.dll to onnxruntime_conda.dll, as done in the past for other packages such as qt-main. The main problem of this approach is that at the moment onnxruntime does not ship any .pc pkg-config file or onnxruntime-config.cmake CMake config files, so basically this name difference needs to be accounted for in downstream build systems.

I implement this solution with patch 4a08914 . Linking with onnxruntime on Windows requires using (or searching for in the CMake case, see for example ami-iit/bipedal-locomotion-framework#686) the name onnxruntime_conda. This problem will be mitigated once onnxruntime provides .pc pkg-config files or CMake's onnxruntime-config.cmake file, see for example microsoft/onnxruntime#8919, as in that case downstream projects would simply link onnxruntime::onnxruntime.

@traversaro
Copy link
Contributor Author

Once/if the CI is happy/green, the PR is ready for review.

@traversaro
Copy link
Contributor Author

traversaro commented Jun 12, 2023

Even with parallel 1, the win win_64_python3.10.____cpythonsuffix build takes the same time and still fails with compiler is out of heap space in pass 2, so I suspect the parallel option is not correctly transmitted. I just tried locally and that seems the case.

@traversaro
Copy link
Contributor Author

@traversaro
Copy link
Contributor Author

As actually also Linux uses gtest/gmock from conda-forge, to be less invasive but just force the use of the vendored protobuf I pass the CMAKE_DISABLE_FIND_PACKAGE_Protobuf=ON to just avoid the finding and using the conda-forge's protobuf.

@traversaro
Copy link
Contributor Author

@conda-forge-admin, please rerender

1 similar comment
@traversaro
Copy link
Contributor Author

@conda-forge-admin, please rerender

@traversaro
Copy link
Contributor Author

For some reason the import onnxruntime test is failing with error:

2023-06-14T17:58:49.2006709Z import: 'onnxruntime'
2023-06-14T17:58:49.5311539Z import: 'onnxruntime'
2023-06-14T17:58:49.5696475Z The system cannot find the path specified.
2023-06-14T17:58:49.5727221Z The filename, directory name, or volume label syntax is incorrect.
2023-06-14T17:58:50.2280836Z Tests failed for onnxruntime-1.15.0-py310h0b3afb7_1.conda - moving package to D:\bld\broken

However, I tested locally the package onnxruntime-1.15.0-py310h0b3afb7_1.conda and import onnxruntime is working fine.

@traversaro
Copy link
Contributor Author

For some reason the import onnxruntime test is failing with error:

2023-06-14T17:58:49.2006709Z import: 'onnxruntime'
2023-06-14T17:58:49.5311539Z import: 'onnxruntime'
2023-06-14T17:58:49.5696475Z The system cannot find the path specified.
2023-06-14T17:58:49.5727221Z The filename, directory name, or volume label syntax is incorrect.
2023-06-14T17:58:50.2280836Z Tests failed for onnxruntime-1.15.0-py310h0b3afb7_1.conda - moving package to D:\bld\broken

However, I tested locally the package onnxruntime-1.15.0-py310h0b3afb7_1.conda and import onnxruntime is working fine.

I tested this locally, and I think I was barking at the wrong tree, the problem were in the run_test.bat, I fixed some errors in ce3edc3, let's see if this fix the errors.

@conda-forge-webservices
Copy link
Contributor

Hi! This is the friendly automated conda-forge-linting service.

I was trying to look for recipes to lint for you, but it appears we have a merge conflict.
Please try to merge or rebase with the base branch to resolve this conflict.

Please ping the 'conda-forge/core' team (using the @ notation in a comment) if you believe this is a bug.

@conda-forge-webservices
Copy link
Contributor

Hi! This is the friendly automated conda-forge-linting service.

I just wanted to let you know that I linted all conda-recipes in your PR (recipe) and found it was in an excellent condition.

@traversaro
Copy link
Contributor Author

@conda-forge-admin, please rerender

@github-actions
Copy link
Contributor

Hi! This is the friendly automated conda-forge-webservice.

I tried to rerender for you but ran into some issues. Please check the output logs of the latest rerendering GitHub actions workflow run for errors. You can also ping conda-forge/core for further assistance or try re-rendering locally.

This message was generated by GitHub actions workflow run https://github.com/conda-forge/onnxruntime-feedstock/actions/runs/5313547709.

Copy link
Contributor

@cbourjau cbourjau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks so much for all your effort! Congratulations on finally getting to that ✅ -state! As I said earlier, I don't have experience in packaging for Windows. Maybe @xhochy or @janjagusch are in a better position in this regard?

recipe/meta.yaml Show resolved Hide resolved
recipe/16337.patch Show resolved Hide resolved
@traversaro
Copy link
Contributor Author

Congratulations on finally getting to that ✅ -state!

I am afraid that the CI checks are actually not running due to a re-rendering problem.

@traversaro
Copy link
Contributor Author

@conda-forge-admin, please rerender

conda-forge-webservices[bot] and others added 2 commits June 19, 2023 19:21
@traversaro
Copy link
Contributor Author

traversaro commented Jun 20, 2023

@conda-forge/onnxruntime the PR is now ready for review, I summarized the main things to know in the original PR message.

recipe/meta.yaml Outdated Show resolved Hide resolved
Co-authored-by: Jan Tilly <jantilly@gmail.com>
@jtilly jtilly merged commit 8365d36 into conda-forge:main Jun 21, 2023
@jtilly
Copy link
Contributor

jtilly commented Jun 21, 2023

Thank you, @traversaro!

@traversaro
Copy link
Contributor Author

Thanks to everyone that provided feedback and for merging the PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants