krrish94 / chamferdist

Pytorch package to compute Chamfer distance between point sets (pointclouds).
Other
290 stars 50 forks source link

ImportError: cannot import name '_C' #8

Closed brian3021 closed 3 years ago

brian3021 commented 3 years ago

Hi, I just update my chamferdist package from 0.3.0 into 1.0.0. I use Pycharm to install the chamferdist package and my environment is: torch => 1.4.0 torchvision => 0.5.0

And when I run the Example.py file I got an error: ImportError: cannot import name '_C' which locate that in chamfer.py file line 12 "from chamferdist import _C"

How can I solve it ?

p.s. I have tried to reinstall the package, but no use.

krrish94 commented 3 years ago

Hi @brian3021,

Unfortunately, the pypi package has been compiled with pytorch 1.6.0. I think that might be causing the error.

If you'd like to use this within another pytorch version, we'd strongly recommend building from source.

I remember testing this with pytorch 1.5.0, but not really with 1.4.0.

Hope this helps!

brian3021 commented 3 years ago

Thanks for your reply!

I have tried to use torch 1.5.0 and torchvision 0.6.0

and then reinstall the package, also got the error.

So, I have to try torch 1.6.0 and torchvision 0.7.0 and then reinstall?

krrish94 commented 3 years ago

Are you attempting to do a pip install? I suspect that wouldn't work for other torch versions.

It'd be easier if you were to build from source, as shown here

krrish94 commented 3 years ago

As an aside, we are trying to figure how we can support multiple torch-cuda versions on pypi so this process becomes smoother

brian3021 commented 3 years ago

Yes, I build from source in the bigining. Got this error.

And I also try download form pypi.org wobsite, then extract it, then use python setup.py install command to install in my venv.

Then I got this error, so I use the pycharm to install again.

I still got the same error.

krrish94 commented 3 years ago

Could this be because you're running from the same directory as chamferdist? You might want to try stepping outside the directory

(also, remind me again - you're using torch 1.6.0 is that correct?)

brian3021 commented 3 years ago

Could this be because you're running from the same directory as chamferdist? You might want to try stepping outside the directory

(also, remind me again - you're using torch 1.6.0 is that correct?)

OH!! I think it's work!!! In the begining, my Example.py file is at the same directory with chamferdist.

So I cut Example.py file to another directory then it can run correctly. So, the main question is that, don't put the file at the same directory with chamferdist?

Oh, and I still using torch 1.4.0 and torchvision 0.5.0.

Thank you very much!!!

krrish94 commented 3 years ago

Ah good to know :)

Thanks for following up with the resolution

brian3021 commented 3 years ago

Ah good to know :)

Thanks for following up with the resolution

Sorry about that asking question after you closed the issue.

So, the main question is that, don't put the run file at the same directory with chamferdist?

krrish94 commented 3 years ago

Yes - some python editors seem to take issue when you do this

Hope this helps

brian3021 commented 3 years ago

Yes - some python editors seem to take issue when you do this

Hope this helps

OK! Thank you very much!!!

LiJiaqi96 commented 2 years ago

Could this be because you're running from the same directory as chamferdist? You might want to try stepping outside the directory

(also, remind me again - you're using torch 1.6.0 is that correct?)

Thanks for pointing this out! It really helps me with the issue :)