Skip to content

Solve PyTorch Ops compilation error in Windows #7140

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

Merged
merged 21 commits into from
Jun 24, 2025

Conversation

lumurillo
Copy link
Contributor

Fixed different compilation error for the PyTorch operations in Windows.

  • Bug fix (non-breaking change which fixes an issue): Fixes #
  • New feature (non-breaking change which adds functionality). Resolves #
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) Resolves #

Motivation and Context

We need these operations functional to be able to upgrade the OpenVINO support in the Open3D ML module.

Checklist:

  • I have run python util/check_style.py --apply to apply Open3D code style
    to my code.
  • This PR changes Open3D behavior or adds new functionality.
    • Both C++ (Doxygen) and Python (Sphinx / Google style) documentation is
      updated accordingly.
    • I have added or updated C++ and / or Python unit tests OR included test
      results
      (e.g. screenshots or numbers) here.
  • I will follow up and update the code if CI fails.
  • For fork PRs, I have selected Allow edits from maintainers.

Copy link

update-docs bot commented Jan 17, 2025

Thanks for submitting this pull request! The maintainers of this repository would appreciate if you could update the CHANGELOG.md based on your changes.

Copy link
Contributor

@benjaminum benjaminum left a comment

Choose a reason for hiding this comment

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

lgtm

@lumurillo lumurillo requested a review from benjaminum January 31, 2025 22:13
@lumurillo lumurillo force-pushed the lumurillo/fix-win-pytorch-ops branch 7 times, most recently from 437a627 to 7375798 Compare February 13, 2025 20:47
@lumurillo lumurillo force-pushed the lumurillo/fix-win-pytorch-ops branch from 7375798 to 59d77b8 Compare February 14, 2025 15:56
@lumurillo lumurillo force-pushed the lumurillo/fix-win-pytorch-ops branch 6 times, most recently from 54baac0 to 08142cb Compare February 20, 2025 17:14
@lumurillo lumurillo force-pushed the lumurillo/fix-win-pytorch-ops branch from 08142cb to c2e48a5 Compare February 24, 2025 16:38
@ssheorey
Copy link
Member

The CI in windows fails when CUDA is enabled:

-- Building PyTorch ops with CUDA
[297](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:298)-- Getting PyTorch properties ...
[298](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:299)-- Using top level CMAKE_CUDA_ARCHITECTURES for TORCH_CUDA_ARCH_LIST: 5.2+PTX
[299](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:300)-- Found Torch: C:/hostedtoolcache/windows/Python/3.8.10/x64/Lib/site-packages/torch/lib/torch.lib
[300](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:301)CMake Error at 3rdparty/cmake/FindPytorch.cmake:95 (set_target_properties):
[301](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:302)  set_target_properties Can not find target to add properties to: torch_cuda
[302](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:303)Call Stack (most recent call first):
[303](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:304)  cpp/open3d/ml/pytorch/CMakeLists.txt:7 (find_package)
[304](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:305)
[305](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:306)
[306](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:307)-- PyTorch         version: 2.2.2+cpu
[307](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:308)--                root dir: C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\torch
[308](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:309)--           compile flags:
[309](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:310)--            include dirs: C:/hostedtoolcache/windows/Python/3.8.10/x64/Lib/site-packages/torch/include
[310](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:311)--            include dirs: C:/hostedtoolcache/windows/Python/3.8.10/x64/Lib/site-packages/torch/include/torch/csrc/api/include
[311](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:312)--               libraries: torch
[312](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:313)--               libraries: torch_library
[313](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:314)--               libraries: C:/hostedtoolcache/windows/Python/3.8.10/x64/Lib/site-packages/torch/lib/c10.lib
[314](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:315)--               libraries: C:/hostedtoolcache/windows/Python/3.8.10/x64/Lib/site-packages/torch/lib/kineto.lib
[315](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:316)-- Pytorch_VERSION: 2.2.2+cpu, CUDAToolkit_VERSION: 12.4.99
[316](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726123886?pr=7140#step:9:317)-- Found Pytorch: 2.2.2+cpu

When the CI is in Debug mode, that provokes an issue when loading the libraries:

Traceback (most recent call last):
[1078](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726126632?pr=7140#step:20:1079)    File "generate_torch_ops_wrapper.py", line 211, in <module>
[1079](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726126632?pr=7140#step:20:1080)      sys.exit(main())
[1080](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726126632?pr=7140#step:20:1081)    File "generate_torch_ops_wrapper.py", line 144, in main
[1081](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726126632?pr=7140#step:20:1082)      torch.ops.load_library(args.lib)
[1082](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726126632?pr=7140#step:20:1083)    File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\site-packages\torch\_ops.py", line 933, in load_library
[1083](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726126632?pr=7140#step:20:1084)      ctypes.CDLL(path)
[1084](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726126632?pr=7140#step:20:1085)    File "C:\hostedtoolcache\windows\Python\3.8.10\x64\lib\ctypes\__init__.py", line 373, in __init__
[1085](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726126632?pr=7140#step:20:1086)      self._handle = _dlopen(self._name, mode)
[1086](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726126632?pr=7140#step:20:1087)  OSError: [WinError 1114] A dynamic link library (DLL) initialization routine failed
[1087](https://github.com/isl-org/Open3D/actions/runs/13503073040/job/37726126632?pr=7140#step:20:1088)C:\Program Files\Microsoft Visual Studio\2022\Enterprise\MSBuild\Microsoft\VC\v170\Microsoft.CppCommon.targets(254,5): error MSB8066: Custom build for 'C:\Open3D\build\CMakeFiles\f0a16331fe8b63fe1a7e844c2ab37cbc\ops.py.rule;C:\Open3D\build\CMakeFiles\2f2f954b582449dd6ddddc8f96ee3e5d\python-package.rule;D:\a\Open3D\Open3D\cpp\pybind\CMakeLists.txt' exited with code 1. [C:\Open3D\build\cpp\pybind\python-package.vcxproj]

@ssheorey ssheorey force-pushed the lumurillo/fix-win-pytorch-ops branch from ebf4b85 to 8cac52c Compare June 16, 2025 02:04
@ssheorey ssheorey merged commit 5b8b435 into isl-org:main Jun 24, 2025
22 of 32 checks passed
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.

3 participants