NVlabs / nvdiffrast

Nvdiffrast - Modular Primitives for High-Performance Differentiable Rendering
Other
1.31k stars 139 forks source link

PyTorch build fails for Visual Studio 2022 #81

Closed mworchel closed 1 year ago

mworchel commented 2 years ago

First of all, thanks for the awesome work!

I noticed that building the PyTorch extension fails for Visual Studio 2022 with

"Could not locate a supported Microsoft Visual C++ installation"

It seems like the default install path for Visual Studio has been changed from C:\Program Files (x86) to C:\Program Files, which results in cl.exe not being properly detected.

Since you don't merge pull requests in the GitHub repository, I propose a solution here: Replace this line (https://github.com/NVlabs/nvdiffrast/blob/main/nvdiffrast/torch/ops.py#L32):

...
paths = sorted(glob.glob(r"C:\Program Files (x86)\Microsoft Visual Studio\*\%s\VC\Tools\MSVC\*\bin\Hostx64\x64" % edition), reverse=True)
...

with

...
vs_relative_path = r"\Microsoft Visual Studio\*\%s\VC\Tools\MSVC\*\bin\Hostx64\x64" % edition
paths = sorted(glob.glob(r"C:\Program Files" + vs_relative_path), reverse=True) + sorted(glob.glob(r"C:\Program Files (x86)" + vs_relative_path), reverse=True)
...

A similar fix should be applied to the TensorFlow bindings (https://github.com/NVlabs/nvdiffrast/blob/main/nvdiffrast/tensorflow/plugin_loader.py#L58-L74).

Thanks!

s-laine commented 2 years ago

Thank you for the report and the suggested solution! I'll fix this in the next release -- keeping this issue open until then.

s-laine commented 1 year ago

Fix included in v0.3.0, closing. Thanks again!