Closed xuelongmu closed 9 months ago
Finding the right compiler has always been tricky, and it looks like it doesn't quite work in your setup. I think this is nvdiffrast somehow trying to use both versions, possibly disagreeing with what PyTorch thinks should be used.
I'm planning to change the compiler detection function as follows in the next maintenance release. If you have the time, you could try replacing this into the _get_plugin()
function in nvdiffrast\torch\ops.py
and see if it works better. It should be able to locate the latest revision of VS better than the current release version that has known pitfalls.
def find_cl_path():
import glob
def get_sort_key(x):
x = x.split('\\')[3:]
x[1] = {'BuildTools': '~0', 'Community': '~1', 'Pro': '~2', 'Professional': '~3', 'Enterprise': '~4'}.get(x[1], x[1])
return x
vs_relative_path = r"\Microsoft Visual Studio\*\*\VC\Tools\MSVC\*\bin\Hostx64\x64"
paths = glob.glob(r"C:\Program Files" + vs_relative_path)
paths += glob.glob(r"C:\Program Files (x86)" + vs_relative_path)
if paths:
return sorted(paths, key=get_sort_key)[-1]
I'm using nvdiffrast with nvdiffrec. I followed the one time setup using PyTorch version 1.10 and CUDA 11.6 on Windows 11, with no errors.
However I get a compilation error when running train.py. I have both VS 2017 and 2022 installed, and I believe the error is due to diffrec using VS 2022 and diffrast using 2017, or maybe diffrast is trying to use both.
I am seeing things in the logs like
and later on:
You can see the two different VS versions being referenced. I guess that binaries built with 2022 on diffrec are incompatible with diffrast using 2017. I have attached the full log: diffrast_error.txt
I solved the issue by explicitly specifying the 2022 cl.exe in my PATH. I tried running vcvarsall from the 2022 installation, but it didn't work, only setting it in the PATH.
I wanted to bring this to light as it was a niche error and I spent a while trying to figure it out, so logging it here could help others. I was actually led to believe from #81 that diffrast would have chosen 2022 due to the path order, but perhaps my assumption is incorrect. Is there a way to make the detection/selection of VS runtimes more consistent across nvdiffrec and nvdiffrast?