LaneSegNet icon indicating copy to clipboard operation
LaneSegNet copied to clipboard

Import Error "import_modules_from_strings(**cfg_dict['custom_imports'])"

Open CaffeeCat opened this issue 2 years ago • 5 comments

Hello, when I try to test model provided in the repo, I met some import error. And I have verified my "~/.bashrc" file like another issue mentioned (export PYTHONPATH in the bashrc file). After that, the code still reports error. I try to locate the error by my self, and I find "Segmentation fault (core dumped)" happened in "import projects.lanesegnet". So I wonder whether you guys can give me some suggestions or not.

CaffeeCat avatar Jan 23 '24 07:01 CaffeeCat

There might be a pesky bug lurking in either the mmcv series package or torch. This issue has haunted me at some points in my life, but now, I am unable to reproduce it now across multiple machines with different systems (CentOS 7 and Ubuntu 20.04).

I highly recommend exploring other combinations of these packages. If you'd like, I have an alternative compatible environment that you could give a shot:

torch==2.0
torchvision==0.15.0
mmcls==0.25.0
mmcv-full==1.6.0
mmdet==2.26.0
mmdet3d==1.0.0rc6
mmsegmentation==0.29.1
with CUDA 11.7/11.8

You might consider compiling mmcv/mmdet/mmdet3d on your own for compatiblity. Additionally, feel free to experiment with different versions of torch.

sephyli avatar Jan 25 '24 06:01 sephyli

I meet the same problem when import 'project.lansegnet' using the function import_module.

Zhutianyi7230 avatar Jan 25 '24 07:01 Zhutianyi7230

I meet the same problem when import 'project.lansegnet' using the function import_module.

If your error looks like: ModuleNotFoundError: No module named 'projects': Please add export PYTHONPATH="Path/to/LaneSegNet/":$PYTHONPATH in the dist_train.sh shell script or your .bashrc file.

If your error looks like: Segmentation fault (core dumped): Trying another environment may be helpful.

sephyli avatar Jan 25 '24 07:01 sephyli

you can try add

import sys
sys.path.append('./')

to tools/train.py I solved it by doing this

hello7623 avatar Feb 01 '24 04:02 hello7623

There might be a pesky bug lurking in either the mmcv series package or torch. This issue has haunted me at some points in my life, but now, I am unable to reproduce it now across multiple machines with different systems (CentOS 7 and Ubuntu 20.04).

I highly recommend exploring other combinations of these packages. If you'd like, I have an alternative compatible environment that you could give a shot:

torch==2.0
torchvision==0.15.0
mmcls==0.25.0
mmcv-full==1.6.0
mmdet==2.26.0
mmdet3d==1.0.0rc6
mmsegmentation==0.29.1
with CUDA 11.7/11.8

You might consider compiling mmcv/mmdet/mmdet3d on your own for compatiblity. Additionally, feel free to experiment with different versions of torch.

I have tried to install the envs following your recommend, but failed to build mmcv-full with error message

"ERROR: Could not build wheels for mmcv-full, which is required to install pyproject.toml-based projects"

It seems a very common issue to install mmcv, then I tried many suggests from other issues(such as replace pip by mim) but still not work. Coculd you please show your installation instructions as reference? Here is my full installtion instructions.

pip install torch==2.0+cu117 torchvision==0.15.0+cu117 -f https://download.pytorch.org/whl/torch_stable.html
pip install -U openmim
mim install mmcv-full==1.6.0     <-- failed
mim install mmcls==0.25.0 mmdet==2.26.0 mmdet3d==1.0.0rc6 mmsegmentation==0.29.1

xD-Jie avatar Mar 20 '24 07:03 xD-Jie