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: train() takes 2 positional arguments but 3 were given #3

Open
aswa123 opened this issue Feb 24, 2021 · 15 comments
Open

TypeError: train() takes 2 positional arguments but 3 were given #3

aswa123 opened this issue Feb 24, 2021 · 15 comments

Comments

@aswa123
Copy link

aswa123 commented Feb 24, 2021

Hello Sir,
Can you please help me with this problem.
I tried many ways but I cannot success in that.
Error shows in line 160.
Thank you.

@gasvn
Copy link
Member

gasvn commented Feb 24, 2021

Please show me your error message so I can help you.

@aswa123
Copy link
Author

aswa123 commented Feb 24, 2021

Traceback (most recent call last):
File "/home/swap/miniconda3/envs/Res2Net-maskrcnn-master/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3427, in run_code
exec(code_obj, self.user_global_ns, self.user_ns)
File "", line 1, in
runfile('/home/swap/Downloads/Res2Net-maskrcnn-master/tools/train_net.py', args=['--config-file', 'configs/pytorch_mask_rcnn_R2_50_s4_FPN_2x.yaml', 'SOLVER.IMS_PER_BATCH', '2', 'SOLVER.BASE_LR', '0.0025', 'SOLVER.MAX_ITER', '7200', 'SOLVER.STEPS', '(480000, 640000)', 'TEST.IMS_PER_BATCH', '1'], wdir='/home/swap/Downloads/Res2Net-maskrcnn-master')
File "/home/swap/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/202.7660.27/plugins/python-ce/helpers/pydev/_pydev_bundle/pydev_umd.py", line 197, in runfile
pydev_imports.execfile(filename, global_vars, local_vars) # execute the script
File "/home/swap/.local/share/JetBrains/Toolbox/apps/PyCharm-C/ch-0/202.7660.27/plugins/python-ce/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
exec(compile(contents+"\n", file, 'exec'), glob, loc)
File "/home/swap/Downloads/Res2Net-maskrcnn-master/tools/train_net.py", line 167, in
main()
File "/home/swap/Downloads/Res2Net-maskrcnn-master/tools/train_net.py", line 160, in main
model = train(cfg, args.local_rank, args.distributed)
TypeError: train() takes 2 positional arguments but 3 were given

@gasvn
Copy link
Member

gasvn commented Feb 24, 2021

Do you use the following command to train the model?
export NGPUS=8
python -m torch.distributed.launch --nproc_per_node=$NGPUS /path_to_maskrcnn_benchmark/tools/train_net.py --config-file "configs/pytorch_mask_rcnn_R2_50_s4_FPN_2x.yaml"

@gasvn
Copy link
Member

gasvn commented Feb 24, 2021

The train function is def train(cfg, local_rank, distributed): And it should receive 3 arguments instead of 2. I didn't find this bug when running this repo.

@gasvn
Copy link
Member

gasvn commented Feb 24, 2021

How you install this repo first following https://github.com/Res2Net/Res2Net-maskrcnn/blob/master/INSTALL.md ?

@gasvn
Copy link
Member

gasvn commented Feb 24, 2021

image

@aswa123
Copy link
Author

aswa123 commented Feb 24, 2021

python tools/train_net.py --config-file "configs/pytorch_mask_rcnn_R2_50_s4_FPN_2x.yaml" SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.0025 SOLVER.MAX_ITER 720000 SOLVER.STEPS "(480000, 640000)" TEST.IMS_PER_BATCH 1

Do you use the following command to train the model?
export NGPUS=8
python -m torch.distributed.launch --nproc_per_node=$NGPUS /path_to_maskrcnn_benchmark/tools/train_net.py --config-file "configs/pytorch_mask_rcnn_R2_50_s4_FPN_2x.yaml"

@aswa123
Copy link
Author

aswa123 commented Feb 24, 2021

How you install this repo first following https://github.com/Res2Net/Res2Net-maskrcnn/blob/master/INSTALL.md ?

yes.

@gasvn
Copy link
Member

gasvn commented Feb 24, 2021

You can try the distributed training mode. I didn't use the python tools/train_net.py --config-file "configs/pytorch_mask_rcnn_R2_50_s4_FPN_2x.yaml" SOLVER.IMS_PER_BATCH 2 SOLVER.BASE_LR 0.0025 SOLVER.MAX_ITER 720000 SOLVER.STEPS "(480000, 640000)" TEST.IMS_PER_BATCH 1 to train the model as it cannot reproduce the performance of the model zoo in maskrcnn-benchmark.

@gasvn
Copy link
Member

gasvn commented Feb 24, 2021

Actually the maskrcnn-benchmark is deprecated now. We also have the res2net+mmdetection and res2net+detectron2. You can use this two repos to achieve much better performance.

@aswa123
Copy link
Author

aswa123 commented Feb 24, 2021

So, now I cannot use single GPU?

@gasvn
Copy link
Member

gasvn commented Feb 24, 2021

So, now I cannot use single GPU?

You cannot reproduce the result with one GPU.

@aswa123
Copy link
Author

aswa123 commented Feb 25, 2021

So we cannot train with one GPU you mean?

@gasvn
Copy link
Member

gasvn commented Feb 25, 2021

So we cannot train with one GPU you mean?
yes

@aswa123
Copy link
Author

aswa123 commented Mar 2, 2021

What should I change if I want to use single GPU?
thank you.

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

2 participants