Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

load_checkpoint(model, checkpoint, map_location='cpu') NameError: name 'load_checkpoint' is not defined #2

Closed
monacv opened this issue Apr 8, 2021 · 27 comments

Comments

@monacv
Copy link

monacv commented Apr 8, 2021

thanks a lot for great documentation. got an error in this step
Screenshot from 2021-04-08 03-19-35

(consnet) mona@goku:~/research/code/ConsNet$ python tools/build_dataset.py --checkpoint checkpoints/
Traceback (most recent call last):
  File "tools/build_dataset.py", line 280, in <module>
    main()
  File "tools/build_dataset.py", line 259, in main
    model = build_detector(cfg.model, args.checkpoint)
  File "/home/mona/venv/consnet/lib/python3.8/site-packages/consnet/models/builder.py", line 50, in build_detector
    load_checkpoint(model, checkpoint, map_location='cpu')
NameError: name 'load_checkpoint' is not defined

@yeliudev
Copy link
Owner

yeliudev commented Apr 8, 2021

It seems that the dependencies of full version are not installed correctly. Did you install consnet from PyPI? If so, please uninstall it and re-install it from source following this part. The PyPI version is only designed for HICO-DET APIs but not for training or testing the models.

@yeliudev
Copy link
Owner

yeliudev commented Apr 8, 2021

Also, <path-to-checkpoint> should be a complete path to the object detetor's .pth file, e.g. checkpoints/faster_rcnn_r50_fpn_3x_coco-26df6f6b.pth.

@yeliudev
Copy link
Owner

Closing this issue due to lack of activity. Please feel free to re-open it if you have any further questions.

@hannajiang
Copy link

Hi, I also meet this problem, and I install consnet from source. When I move code from nncore.engine import load_checkpoint, set_random_seed in models/builder.py from try except module, this problem will be solved; but I meet another problem,
image

@yeliudev
Copy link
Owner

May I ask that which pytorch, mmdet and nncore version are you using?

@hannajiang
Copy link

consnet 1.0.5 /home/jh/code/CosNet
torch 1.8.1
mmdet 2.11.0
nncore 0.2.6

@yeliudev
Copy link
Owner

nncore 0.2.6 is not tested for this repo, the version we used is 0.2.4. Also, if you meet some problem when from nncore.engine import load_checkpoint, set_random_seed is in the try except module, it seems that there's something wrong in your mmcv/mmdet.

@PradKalkar
Copy link

Hi. Thanks for the docs. I am getting the same error as faced by two others - NameError: name 'load_checkpoint' is not defined. I did install consnet from the source and didn't do pip install consnet. Also, I checked the versions of pytorch, mmdet and nncore - they are 1.8.1+cu102, 2.11.0 and 0.2.4 respectively. Could you please help?

@yeliudev
Copy link
Owner

Hi. Thanks for the docs. I am getting the same error as faced by two others - NameError: name 'load_checkpoint' is not defined. I did install consnet from the source and didn't do pip install consnet. Also, I checked the versions of pytorch, mmdet and nncore - they are 1.8.1+cu102, 2.11.0 and 0.2.4 respectively. Could you please help?

Thanks for your feedback. May I ask that did you install consnet from source using pip install -e .[full] ranther than pip install -e .? You may also try to modify the code here by moving the imports out of try...except to see which line raises the error.

@PradKalkar
Copy link

Hi. Thank you @yeliudev for the reply.
I installed consnet from the source using the first command you mentioned - pip install -e .[full]
I tried removing the try-except block, but I was facing another error. I will send here the screenshot of the error in some time, as currently I am not having access to that computer.

@PradKalkar
Copy link

PradKalkar commented Dec 19, 2022

ModuleNotFoundError: No module named 'mmcv._ext'
This is the error which I am facing after removing the try except block.
PFA the traceback below.

image
image

@PradKalkar
Copy link

Also @yeliudev may I ask that what is the object detection mAP (not the HOI mAP using the complete model) on the HICO-DET test set of the two object detectors which you used - first one pretrained on COCO and the other one finetuned on HICO-DET?

@yeliudev
Copy link
Owner

ModuleNotFoundError: No module named 'mmcv._ext' This is the error which I am facing after removing the try except block. PFA the traceback below.

image image

This means that you are using mmcv instead of mmcv-full. So that the CUDA extensions are not compiled. You may try to re-install this package.

@yeliudev
Copy link
Owner

Also @yeliudev may I ask that what is the object detection mAP (not the HOI mAP using the complete model) on the HICO-DET test set of the two object detectors which you used - first one pretrained on COCO and the other one finetuned on HICO-DET?

I'm not pretty sure since this project was finished years ago. I remember that the mAP of COCO detector was about 13, and the HICO-DET finetuned one shall be about 20.

@PradKalkar
Copy link

Also @yeliudev may I ask that what is the object detection mAP (not the HOI mAP using the complete model) on the HICO-DET test set of the two object detectors which you used - first one pretrained on COCO and the other one finetuned on HICO-DET?

I'm not pretty sure since this project was finished years ago. I remember that the mAP of COCO detector was about 13, and the HICO-DET finetuned one shall be about 20.

Thanks for your response @yeliudev.

@PradKalkar
Copy link

ModuleNotFoundError: No module named 'mmcv._ext' This is the error which I am facing after removing the try except block. PFA the traceback below.
image image

This means that you are using mmcv instead of mmcv-full. So that the CUDA extensions are not compiled. You may try to re-install this package.

But, I installed it using the pip install command given in your docs. Also, I tried to uninstall mmcv but upon doing that it says mmcv not found, which means that mmcv-full was installed. Would you please help?
Also, what version of cudatoolkit-dev did you use in your conda environment? Here https://anaconda.org/conda-forge/cudatoolkit-dev/files?page=2 it shows that cudatoolkit-dev version 10.2 doesn't exists.

@yeliudev
Copy link
Owner

There are two versions of mmcv, one is called mmcv and the other shall be mmcv-full. You may try to manually install it by using pip install mmcv-full and see if the CUDA extensions are compiled correctly. We did not use cudatoolkit-dev in our env. We installed CUDA from scratch in our system.

@PradKalkar
Copy link

Thanks for the reply. Would you please check and share the exact version of your mmcv-full?

@yeliudev
Copy link
Owner

1.3.8

@PradKalkar
Copy link

Thanks for sharing the version. I will check by installing this version on the system. Also, will the CUDA version matter? I don't have 10.2 in my system. Is the issue coming because of that?

@yeliudev
Copy link
Owner

I don't think the CUDA version matters. Compiling mmcv-full using your own CUDA shall be fine. Please feel free to leave a message here if you meet any other problems.

@PradKalkar
Copy link

PradKalkar commented Dec 20, 2022

Would you please clarify the meaning of "compiling" mmcv-full using your own CUDA? Is compiling a separate step to be done after installing mmcv-full? If yes, would you please share the command for doing so.

@yeliudev
Copy link
Owner

Simply running pip install mmcv-full==1.3.8 should compile it automatically. Please be check that if there is any error during the installation.

@PradKalkar
Copy link

Thanks for your quick responses @yeliudev.

@PradKalkar
Copy link

Hi. I was able to resolve the mmcv error. But, now I am encountering another error. I installed the packages as follows -

  1. pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html
  2. pip install -U openmim
    mim install mmcv-full==1.3.8
    pip install mmdet==2.11.0
  3. pip install nncore==0.2.4

With the above 3 steps, the command of python tools/build_dataset.py started executing correctly and the hdf5 files were making up (i.e. the detection step and extraction of features). But allennlp wasn't installed. So, once I understood that mmcv is working fine, I interrupted the above execution. Then, I installed allenlp using -

  1. pip install allennlp==2.2.0

After this, I again ran the same command (python tools/build_dataset.py), but it errored out. Attaching the traceback below.
Will the above command (python tools/build_dataset.py) work even without installing allennlp? Or will it require allennlp to be installed? I assume that build_graph function in the file won't work without allennlp. Is it right?

image
image

@yeliudev
Copy link
Owner

It seems that the version of package transformers is not correct. Could you install transformers==0.11 and try it again?

@PradKalkar
Copy link

It seems that the version of package transformers is not correct. Could you install transformers==0.11 and try it again?

Getting this when trying to install it. :(
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants