MCG-NJU / MeMOTR

[ICCV 2023] MeMOTR: Long-Term Memory-Augmented Transformer for Multi-Object Tracking
https://arxiv.org/abs/2307.15700
MIT License
157 stars 11 forks source link

在运行 sh make.sh时出现 ImportError: No module named torch问题 #3

Closed fish0426 closed 11 months ago

fish0426 commented 1 year ago

在根据下载模块的代码创建好了虚拟环境并安装相应的组件之后,我cd到相应目录下执行sh make.sh时,出现的这个问题,完整的报错是: Traceback (most recent call last): File "setup.py", line 11, in import torch ImportError: No module named torch 我在尝试pip install torch后再次运行还是得到一样的结果

HELLORPG commented 1 year ago

这个看起来还是个 python 环境导致的问题,首先确定你已经激活了对应的虚拟环境,例如在我机器上是conda activate MeMOTR,之后可以考虑一下用如下代码在命令行中执行验证:

# from the object root
>>> cd ./models/ops/
>>> python
Python 3.10.12 (main, Jul  5 2023, 18:54:27) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
'1.13.1' # should output your torch version
>>> torch.cuda.is_available()
True     # must be True

如果不能得到上述的合法输出,或是依旧No module named torch,则考虑是环境安装的问题,可以通过conda list或者pip list查看一下确切的安装列表。


This seems to be a problem caused by the python (virtual) environment. First, make sure you have activated the corresponding environment. For example, we use conda activate MeMOTR if you follow our installation scripts. Then, you can consider using the above code to verify the environment. If you cannot get the legal output, like still get No module named torch, it may be an environment installation error. You can check the python package list by conda list or pip list.

fish0426 commented 1 year ago

在成功激活相应的虚拟环境前提下,未使用pip install torch时,使用您提供的代码验证是不能得到合法输出的,我也尝试过在此时使用conda list确实没有名为torch文件,但是在使用了pip install torch后,能够得到合法输出,并且conda list能够找到torch,但是使用sh make.sh仍然出现报错No module named torch

HELLORPG commented 1 year ago

听您的描述,我确实也有点不明白这是为什么。 您确定根据 anaconda 的输出 pytorch 已经提示被正确安装?或者可以选择采用 pip 进行安装。此外,您也可以尝试一下直接执行python setup.py以代替sh make.sh

另外,您也可以尝试一下是否可以成功编译 Deformable DETR 中的相同算子。如果仍然不能,可以看看是否可以从他们更完善的 issue 中找到类似的情况。


From your description, I really don't understand why. Are you sure that pytorch has been installed correctly according to the output of anaconda? OR you can choose to install it using pip rather than conda.

Alternatively, you can try to see if you can successfully compile the same DeformableAttn operator in Deformable DETR. Otherwise, see if you can find a similar situation from their issue.

HELLORPG commented 11 months ago

由于长时间没有收到您的回复,我将暂时关闭这个 issue。如果后续有需要,您可以随时重新打开这个 issue。


As I haven't received your reply for a long time, I am closing this issue temporarily. You can re-open this issue as you like~