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

RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int; but got #110

Open
zhanwenchen opened this issue Mar 26, 2023 · 1 comment · Fixed by #111
Assignees
Labels
bug Something isn't working

Comments

@zhanwenchen
Copy link
Owner

zhanwenchen commented Mar 26, 2023

Likely an issue from float16 => float32

Traceback (most recent call last):
  File "/localtmp/pct4et/relaug/tools/relation_train_net.py", line 394, in <module>
    main()
  File "/localtmp/pct4et/relaug/tools/relation_train_net.py", line 390, in main
    train(cfg, local_rank, args.distributed, logger)
  File "/localtmp/pct4et/relaug/tools/relation_train_net.py", line 197, in train
    loss_dict = model(images, targets)
  File "/localtmp/pct4et/conda_envs/relaug/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/localtmp/pct4et/conda_envs/relaug/lib/python3.8/site-packages/torch/nn/parallel/distributed.py", line 886, in forward
    output = self.module(*inputs[0], **kwargs[0])
  File "/localtmp/pct4et/conda_envs/relaug/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/localtmp/pct4et/conda_envs/relaug/lib/python3.8/site-packages/apex-0.1-py3.8-linux-x86_64.egg/apex/amp/_initialize.py", line 198, in new_fwd
    output = old_fwd(*applier(args, input_caster),
  File "/localtmp/pct4et/relaug/maskrcnn_benchmark/modeling/detector/generalized_rcnn.py", line 52, in forward
    x, result, detector_losses = self.roi_heads(features, proposals, targets, logger)
  File "/localtmp/pct4et/conda_envs/relaug/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/localtmp/pct4et/relaug/maskrcnn_benchmark/modeling/roi_heads/roi_heads.py", line 69, in forward
    x, detections, loss_relation = self.relation(features, detections, targets, logger)
  File "/localtmp/pct4et/conda_envs/relaug/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/localtmp/pct4et/relaug/maskrcnn_benchmark/modeling/roi_heads/relation_head/relation_head.py", line 80, in forward
    refine_logits, relation_logits, add_losses = self.predictor(proposals, rel_pair_idxs, rel_labels, rel_binarys, roi_features, union_features, logger)
  File "/localtmp/pct4et/conda_envs/relaug/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/localtmp/pct4et/relaug/maskrcnn_benchmark/modeling/roi_heads/relation_head/roi_relation_predictors.py", line 81, in forward
    obj_dists, obj_preds, edge_ctx = self.context_layer(roi_features, proposals, logger)
  File "/localtmp/pct4et/conda_envs/relaug/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/localtmp/pct4et/relaug/maskrcnn_benchmark/modeling/roi_heads/relation_head/model_transformer.py", line 250, in forward
    obj_embed = self.obj_embed1(obj_labels)
  File "/localtmp/pct4et/conda_envs/relaug/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
    return forward_call(*input, **kwargs)
  File "/localtmp/pct4et/conda_envs/relaug/lib/python3.8/site-packages/torch/nn/modules/sparse.py", line 158, in forward
    return F.embedding(
  File "/localtmp/pct4et/conda_envs/relaug/lib/python3.8/site-packages/torch/nn/functional.py", line 2044, in embedding
    return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected tensor for argument #1 'indices' to have one of the following scalar types: Long, Int; but got torch.cuda.FloatTensor instead (while checking arguments for embedding)
@zhanwenchen zhanwenchen self-assigned this Mar 26, 2023
@zhanwenchen zhanwenchen added the bug Something isn't working label Mar 26, 2023
@zhanwenchen zhanwenchen linked a pull request Mar 26, 2023 that will close this issue
zhanwenchen added a commit that referenced this issue Mar 26, 2023
…nsor-for-argument-1-indices-to-have-one-of-the-following-scalar-types-long-int-but-got

#110: load labels as int64 in dataset
@zhanwenchen zhanwenchen reopened this Mar 26, 2023
@zhanwenchen
Copy link
Owner Author

Only modifying visual_genome get_groundtruth did not solve the issue.

Also, this only affects predcls.

zhanwenchen added a commit that referenced this issue Mar 26, 2023
…nsor-for-argument-1-indices-to-have-one-of-the-following-scalar-types-long-int-but-got

#110: add obj_labels = obj_labels.long() as in gsc
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

Successfully merging a pull request may close this issue.

1 participant