Kamino666 / Video-Captioning-Transformer

这是一个基于Pytorch平台、Transformer框架实现的视频描述生成 (Video Captioning) 深度学习模型。 视频描述生成任务指的是:输入一个视频,输出一句描述整个视频内容的文字(前提是视频较短且可以用一句话来描述)。本repo主要目的是帮助视力障碍者欣赏网络视频、感知周围环境,促进“无障碍视频”的发展。
Apache License 2.0
79 stars 17 forks source link

大佬,单卡训练的时候有一个问题 #12

Closed End1ezs closed 2 years ago

End1ezs commented 2 years ago

AttributeError: 'MMT4Caption' object has no attribute 'module' 不知道哪里的问题

Kamino666 commented 2 years ago

把更详细一点的报错放出来吧

End1ezs commented 2 years ago

Traceback (most recent call last): File "train.py", line 315, in mmt4captiontrain(cfg.data, args_) File "train.py", line 245, in mmt4caption_train val_loss = val_epoch(model, val_dataloader, mode=cfg['train']['task'], local_args=local_args) File "/home/endless/anaconda3/envs/pytorchtest/lib/python3.8/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context return func(*args, **kwargs) File "train.py", line 161, in val_epoch loss = model.module(v_feats, v_masks, captions) File "/home/endless/anaconda3/envs/pytorchtest/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1185, in getattr raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'MMT4Caption' object has no attribute 'module'

问题是在一轮结束后出现的。

Kamino666 commented 2 years ago

哦哦,单卡训练参数有没有设置成--gpu呢,--gpu是单卡训练,--multi_gpu是多卡的

Kamino666 commented 2 years ago

尝试一下使用--multi_gpu,然后把显卡数设置为1

End1ezs commented 2 years ago

哦哦,单卡训练参数有没有设置成--gpu呢,--gpu是单卡训练,--multi_gpu是多卡的 感谢大佬的回复, python train.py -c ./configs/caption-task_baseline_modal_clip4clip_config.json --gpu 大佬,我之前用的参数是这个 然后刚才用多卡试了一下, python train.py -c ./configs/caption-task_baseline_modal_clip4clip_config.json -ws 1 --multigpu 现在这样报错 Traceback (most recent call last): File "train.py", line 305, in args = configurehardware(args) File "/home/endless/pythonProject/Video-Captioning-Transformer-master/utils.py", line 138, in configure_hardware local_rank = int(os.environ["LOCAL_RANK"]) File "/home/endless/anaconda3/envs/pytorchtest/lib/python3.8/os.py", line 675, in getitem raise KeyError(key) from None KeyError: 'LOCAL_RANK'

Kamino666 commented 2 years ago

用这个命令试一下 python -m torch.distributed.run --nproc_per_node 1 train.py -c ./configs/caption-task_baseline_modal_clip4clip_config.json --multi_gpu -ws 1

End1ezs commented 2 years ago

感谢大佬。