Skip to content

Resume get RuntimeError: expected type torch.FloatTensor but got torch.cuda.FloatTensor #522

Closed
@LinSHP

Description

@LinSHP

When I resume training, I encountered a Runtime error

Traceback (most recent call last): File "trainval_net.py", line 339, in <module> optimizer.step() File "/pytorch/lib/python3.6/site-packages/torch/optim/sgd.py", line 101, in step buf.mul_(momentum).add_(1 - dampening, d_p) RuntimeError: expected type torch.FloatTensor but got torch.cuda.FloatTensor

I search through the issues and find issue #475 has the same error. But it seems the problem has been solved and merged.
So I add the lines that the merge request removed and problem is solved.

add lines

if args.cuda:
    fasterRCNN.cuda()

  if args.optimizer == "adam":
    lr = lr * 0.1
    optimizer = torch.optim.Adam(params)

So I think there are still some problems with the RuntimeError.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions