NVlabs / nvdiffrast

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

ImportError: generic_type: type "RasterizeGLStateWrapper" is already registered! #79

Closed jiaxiangshang closed 2 years ago

jiaxiangshang commented 2 years ago

Hi, groupers

I meet this error when I try to sample a texture map by the uv. out = dr.texture(self.data, texc, texc_deriv, filter_mode=filter_mode)

The error is ImportError: generic_type: type "RasterizeGLStateWrapper" is already registered!

Best

s-laine commented 2 years ago

Hi, does this happen when running one of our examples without modifications? Which one?

The error sounds like you're somehow importing nvdiffrast twice into the same namespace. Do you have it installed using pip and also have it in your current directory? Maybe some imported code imports the pip package and your main function imports it from the current directory, or something similar, and this could perhaps cause a clash.

jiaxiangshang commented 2 years ago

No, it happens when I build my project.

And I use two version nvdiffrast, I guess this is the reason?

s-laine commented 2 years ago

Yes, most probably. I haven’t ever had to import multiple versions of nvdiffrast simultaneously, so I don’t know what the cleanest way to support that would be. One way is to modify the exported function names in torch_bindings.cpp (inside PYBIND11_MODULE macro) and make the same changes in ops.py, assuming it’s these names that clash between the versions.

jiaxiangshang commented 2 years ago

Oh, yes, it is super clear for me, and the problem is solved.

Thank you very much.