lucasjinreal / DCNv2_latest

DCNv2 supports decent pytorch such as torch 1.5+ (now 1.8+)
BSD 3-Clause "New" or "Revised" License
609 stars 125 forks source link

ModuleNotFoundError: No module named 'torch' #44

Closed Bavesh-B closed 2 years ago

Bavesh-B commented 2 years ago

Hi @jinfagang I am getting a ModuleNotFoundError when I try to run the ./make.sh command by coning this repository in my virtual machine. PyTorch:- version 1.8.1+cu102 Ubuntu:- 20.04 I do not have conda in my virtual machine. Could someone please take a look at this issue?

fabrizioschiano commented 2 years ago

I have the same problem. It is quite strange since if I run instead the repository https://github.com/lbin/DCNv2.git I don't have any problems doing the ./make.sh

I am using a virtualenvironment and if the environment is active and I do:

python -c "import torch; print(torch.__version__)"

I get (indeed)

1.9.1+cu102

@Bavesh-B , did you figure out how to solve this problem?

fabrizioschiano commented 2 years ago

I probably found a solution to the problem by looking into the make.sh file.

The make.sh of this repository looks like this:

#!/usr/bin/env bash
sudo rm *.so
sudo rm -r build/
sudo python3 setup.py build develop

while the make.sh of the other repo looks like this

#!/usr/bin/env bash
python setup.py build develop

What I just did is to remove the sudo from the make.sh file.

I think that this must be related to the fact that in the DCNv2_latest repo they assume you don't use a virtualenvironment maybe.

I hope this helps someone in the same situation. Let me know also if I did something wrong.

(also, I don't like doing sudo python3 ... to be honest)

Bavesh-B commented 2 years ago

Hey @fabrizioschiano , For me the problem was sudo because when I installed pytorch, I did not use sudo on the command. So in that case, there are 2 solutions. Either remove the sudo in the shell file and run or install pytorch again with sudo. Also, I have a question. Is the dcn_v2.git repository compatible for pytorch 1.9.1?

fabrizioschiano commented 2 years ago

Yes, exactly, the problem was the sudo for me too. I don't know if it is compatible, that's a good question actually!

What I assumed is that it is since before ending on this repository I was using the following: https://github.com/lbin/DCNv2.git

This repository has a branch dedicated to pytorch_1.9

@Bavesh-B , are you also using a virtualenvironment or conda or similar?

Bavesh-B commented 2 years ago

No I am not using any environment. I am just using a virtual instance.

lucasjinreal commented 2 years ago

@fabrizioschiano @Bavesh-B Be note don't messy with python or python3 which might be your virtual env or your system python. So please check if it is the right interporator you want build with.

fabrizioschiano commented 2 years ago

@jinfagang , thanks for your comment. is there a particular reason why you needed a sudo in the make.sh file?

lucasjinreal commented 2 years ago

@fabrizioschiano If you install to your system path, using sudo, if you using anaconda, then you needn't to do that.