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

TypeError: expected sequence object with len >= 0 or a single integer #2842

Closed
lijain opened this issue May 29, 2020 · 20 comments
Closed

TypeError: expected sequence object with len >= 0 or a single integer #2842

lijain opened this issue May 29, 2020 · 20 comments
Labels
bug Something isn't working

Comments

@lijain
Copy link

lijain commented May 29, 2020

i run python tools/train.py --config example/dior/faster_rcnn_r101_fpn_1x.py --validate
I see the explanation, but I don't suggest that I think it can be used, so I added a test during the training. Would you like to ask the reason for the error??

_rpn_bbox: 0.0190, loss_cls: 0.1400, acc: 95.4509, loss_bbox: 0.0957, loss: 0.2879
[ ] 0/11738, elapsed: 0s, ETA:Traceback (most recent call last):
File "tools/train.py", line 154, in
main()
File "tools/train.py", line 150, in main
meta=meta)
File "/data/maq/PycharmProjects/TSD-master/mmdet/apis/train.py", line 169, in train_detector
runner.run(data_loaders, cfg.workflow, cfg.total_epochs)
File "/data/maq/anaconda3/envs/mmdetect/lib/python3.7/site-packages/mmcv/runner/runner.py", line 380, in run
epoch_runner(data_loaders[i], **kwargs)
File "/data/maq/anaconda3/envs/mmdetect/lib/python3.7/site-packages/mmcv/runner/runner.py", line 288, in train
self.call_hook('after_train_epoch')
File "/data/maq/anaconda3/envs/mmdetect/lib/python3.7/site-packages/mmcv/runner/runner.py", line 241, in call_hook
getattr(hook, fn_name)(self)
File "/data/maq/PycharmProjects/TSD-master/mmdet/core/evaluation/eval_hooks.py", line 28, in after_train_epoch
results = single_gpu_test(runner.model, self.dataloader, show=False)
File "/data/maq/PycharmProjects/TSD-master/mmdet/apis/test.py", line 19, in single_gpu_test
result = model(return_loss=False, rescale=not show, **data)
File "/data/maq/anaconda3/envs/mmdetect/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call
result = self.forward(*input, **kwargs)
File "/data/maq/anaconda3/envs/mmdetect/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 153, in forward
return self.gather(outputs, self.output_device)
File "/data/maq/anaconda3/envs/mmdetect/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 165, in gather
return gather(outputs, output_device, dim=self.dim)
File "/data/maq/anaconda3/envs/mmdetect/lib/python3.7/site-packages/torch/nn/parallel/scatter_gather.py", line 68, in gather
res = gather_map(outputs)
File "/data/maq/anaconda3/envs/mmdetect/lib/python3.7/site-packages/torch/nn/parallel/scatter_gather.py", line 63, in gather_map
return type(out)(map(gather_map, zip(*outputs)))
File "/data/maq/anaconda3/envs/mmdetect/lib/python3.7/site-packages/torch/nn/parallel/scatter_gather.py", line 63, in gather_map
return type(out)(map(gather_map, zip(*outputs)))
TypeError: expected sequence object with len >= 0 or a single integer

@MioChiu
Copy link

MioChiu commented May 29, 2020

I meet same error

@hellock
Copy link
Member

hellock commented May 29, 2020

There is no --validate argument, only --no-validate.

@lijain
Copy link
Author

lijain commented May 29, 2020 via email

@hellock
Copy link
Member

hellock commented May 29, 2020

Validation is enabled by default. If you want to skip the validation, you can add the --no-validate argument. I am afraid the version you were using is too old.

@lijain
Copy link
Author

lijain commented May 29, 2020 via email

@lijain
Copy link
Author

lijain commented May 29, 2020

python tools/train.py --config example/dior/faster_rcnn_r101_fpn_1x.py
evaluation = dict(interval=1, metric='mAP')

optimizer

optimizer = dict(type='SGD', lr=0.02, momentum=0.9, weight_decay=0.0001)
optimizer_config = dict(grad_clip=dict(max_norm=35, norm_type=2))

learning policy

lr_config = dict(
policy='step',
warmup='linear',

Operation is just training, and there is no Val data calculation map? Please advise

@mathmanu
Copy link

mathmanu commented Jun 4, 2020

Hi, I face this issue too. It is happening in gather_map() called in DataParallel. I have attached a screen shot of the debug window here:
mmdet_validation_issue_dataparallel_gather_map

@zhiwenfan
Copy link

Hi, I face this issue too. It is happening in gather_map() called in DataParallel. I have attached a screen shot of the debug window here:
mmdet_validation_issue_dataparallel_gather_map

Hi, I also face the "TypeError: expected sequence object with len >= 0 or a single integer" when one epoch is finished.
What caused this problem and could you please provide some advices about how to solve this problem?
Many thanks.

@zhiwenfan
Copy link

I downloaded the latest. If validation is enabled by default, why is there no map of Val data in my training process? Is there something wrong with my setup? Please advise. Thank you

------------------ 原始邮件 ------------------ 发件人: "Kai Chen"<notifications@github.com>; 发送时间: 2020年5月29日(星期五) 中午1:18 收件人: "open-mmlab/mmdetection"<mmdetection@noreply.github.com>; 抄送: "利剑"<1632401541@qq.com>;"Author"<author@noreply.github.com>; 主题: Re: [open-mmlab/mmdetection] TypeError: expected sequence object with len >= 0 or a single integer (#2842) Validation is enabled by default. If you want to skip the validation, you can add the --no-validate argument. I am afraid the version you were using is too old. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Hi, I also face the "TypeError: expected sequence object with len >= 0 or a single integer" when one epoch is finished.
Have you solved this problem?
What caused this problem and could you please provide some advices about how to solve this problem?
Many thanks.

@zhiwenfan
Copy link

Validation is enabled by default. If you want to skip the validation, you can add the --no-validate argument. I am afraid the version you were using is too old.

Hi, the problem of "TypeError: expected sequence object with len >= 0 or a single integer" seems not relevant with the argument setting.
When one epoch is finished, and start do validation, the problem will arise.
Is it caused by the sample of validation number can not be divided with the (num_gpu * samples_per_gpu)?
Looking forward for your advises.

@FreyWang
Copy link

Validation is enabled by default. If you want to skip the validation, you can add the --no-validate argument. I am afraid the version you were using is too old.

Hi, the problem of "TypeError: expected sequence object with len >= 0 or a single integer" seems not relevant with the argument setting.
When one epoch is finished, and start do validation, the problem will arise.
Is it caused by the sample of validation number can not be divided with the (num_gpu * samples_per_gpu)?
Looking forward for your advises.

add the code

            if isinstance(model, torch.nn.DataParallel):
                model.device_ids = [0]

below

with torch.no_grad():

1 similar comment
@FreyWang
Copy link

Validation is enabled by default. If you want to skip the validation, you can add the --no-validate argument. I am afraid the version you were using is too old.

Hi, the problem of "TypeError: expected sequence object with len >= 0 or a single integer" seems not relevant with the argument setting.
When one epoch is finished, and start do validation, the problem will arise.
Is it caused by the sample of validation number can not be divided with the (num_gpu * samples_per_gpu)?
Looking forward for your advises.

add the code

            if isinstance(model, torch.nn.DataParallel):
                model.device_ids = [0]

below

with torch.no_grad():

@handong1587
Copy link

Validation is enabled by default. If you want to skip the validation, you can add the --no-validate argument. I am afraid the version you were using is too old.

Hi, the problem of "TypeError: expected sequence object with len >= 0 or a single integer" seems not relevant with the argument setting.
When one epoch is finished, and start do validation, the problem will arise.
Is it caused by the sample of validation number can not be divided with the (num_gpu * samples_per_gpu)?
Looking forward for your advises.

add the code

            if isinstance(model, torch.nn.DataParallel):
                model.device_ids = [0]

below

with torch.no_grad():

Hi, do you know why this error occured?
How these 2 lines can solve the error?
Thanks!

@FreyWang
Copy link

Validation is enabled by default. If you want to skip the validation, you can add the --no-validate argument. I am afraid the version you were using is too old.

Hi, the problem of "TypeError: expected sequence object with len >= 0 or a single integer" seems not relevant with the argument setting.
When one epoch is finished, and start do validation, the problem will arise.
Is it caused by the sample of validation number can not be divided with the (num_gpu * samples_per_gpu)?
Looking forward for your advises.

add the code

            if isinstance(model, torch.nn.DataParallel):
                model.device_ids = [0]

below

with torch.no_grad():

Hi, do you know why this error occured?
How these 2 lines can solve the error?
Thanks!

just debug

@Nafees-060
Copy link

Hi folks

When I run the file it is correctly working, however, when I debug the code, it do not work. Following Errors are showing:

Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2020.2.1\plugins\python\helpers\pydev\pydevd.py", line 1448, in _exec
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "C:\Program Files\JetBrains\PyCharm 2020.2.1\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "C:/Users/Nafees Ahmed/PycharmProjects/pythonProject/DeepConvLSTM-master/DeepConvLSTM-master/DeepConvLSTM.py", line 14, in <module>
    get_ipython().system('wget https://archive.ics.uci.edu/ml/machine-learning-databases/00226/OpportunityUCIDataset.zip')
AttributeError: 'NoneType' object has no attribute 'system'

I could not understand, why it happens and how can I solve it out? Please help me to sort out this problem

@dxyzx0
Copy link

dxyzx0 commented Sep 22, 2020

Validation is enabled by default. If you want to skip the validation, you can add the --no-validate argument. I am afraid the version you were using is too old.

Hi, the problem of "TypeError: expected sequence object with len >= 0 or a single integer" seems not relevant with the argument setting.
When one epoch is finished, and start do validation, the problem will arise.
Is it caused by the sample of validation number can not be divided with the (num_gpu * samples_per_gpu)?
Looking forward for your advises.

add the code

            if isinstance(model, torch.nn.DataParallel):
                model.device_ids = [0]

below

with torch.no_grad():

That's not a good solution. You only train with nn.DataParallel but when you validate and test your model doesn't utilize nn.DataParallel and that may cause CUDA out of memory error when you try to test/validate with the same batch size of training.

@hhaAndroid
Copy link
Collaborator

Is there still a problem with the latest version now?

liuhuiCNN pushed a commit to liuhuiCNN/mmdetection that referenced this issue May 21, 2021
* fix save_inference_model cannot find feed vars

* remove comment

* fix format

* add comment for pruned var

* add log for prune
@tall-josh
Copy link
Contributor

I have this issue when my config gpus is variable is >1. Setting it to 1 stopped the problem

@Sairam13001
Copy link

Is this problem solved? Someone please let me know.

FANGAreNotGnu pushed a commit to FANGAreNotGnu/mmdetection that referenced this issue Oct 23, 2023
@GenMoat
Copy link

GenMoat commented Dec 14, 2023

I had the same problem, and it was solved by setting gpu_ids = [0] in the config file (obviously when you use 1 single GPU to test).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests