ImageCaptioning.pytorch icon indicating copy to clipboard operation
ImageCaptioning.pytorch copied to clipboard

Cpu issue

Open soheylsa opened this issue 6 years ago • 10 comments

I changed the eval.py to run it on cpu but I was encountered to some error. Can you provide the cpu version of it? Thanks in advance

soheylsa avatar Mar 08 '18 20:03 soheylsa

I don't have that. What error did you meet?

ruotianluo avatar Mar 08 '18 20:03 ruotianluo

The error is: module object has no attribute cuda_getdevice That it is relate to this line of code: model.load_state_dict(torch.load(opt.model))

soheylsa avatar Mar 08 '18 20:03 soheylsa

model.load_state_dict(torch.load(opt.model, map_location=lambda storage, loc: storage))

try this

ruotianluo avatar Mar 08 '18 20:03 ruotianluo

I tried this but the error was not solved.

soheylsa avatar Mar 08 '18 20:03 soheylsa

I can load it properly on a no-gpu machine in this way.

ruotianluo avatar Mar 08 '18 20:03 ruotianluo

I was encountered the same error. Can you provide the change in code in detail?

MaloneGod avatar Mar 10 '18 02:03 MaloneGod

Loading the model succeeds, but running any eval code fails because there's .cuda() calls all over the place. You'll have to remove all of them. I made a quick fork to demonstrate: https://github.com/kcarnold/ImageCaptioning.pytorch

The "right" solution is to use type_as within the models, but that's more work.

kcarnold avatar Apr 02 '18 19:04 kcarnold

@kcarnold I run your code it gives this error. Do you have any idea?

Traceback (most recent call last): File "eval.py", line 122, in vars(opt)) File "/ImageCaptioning.pytorch/eval_utils.py", line 105, in eval_split sents = utils.decode_sequence(loader.get_vocab(), seq) File "/ImageCaptioning.pytorch/misc/utils.py", line 27, in decode_sequence txt = txt + ix_to_word[str(ix)] KeyError: 'tensor(7961)'

erkams avatar Jul 25 '18 18:07 erkams

This is because you are using pytorch 0.4.

ruotianluo avatar Jul 25 '18 18:07 ruotianluo

@kcarnold I run your code it gives this error. Do you have any idea?

Traceback (most recent call last): File "eval.py", line 122, in vars(opt)) File "/ImageCaptioning.pytorch/eval_utils.py", line 105, in eval_split sents = utils.decode_sequence(loader.get_vocab(), seq) File "/ImageCaptioning.pytorch/misc/utils.py", line 27, in decode_sequence txt = txt + ix_to_word[str(ix)] KeyError: 'tensor(7961)'

just change this line: txt = txt + ix_to_word[str(ix)] to: txt = txt + ix_to_word[str(int(ix))]

javadpeyman avatar Apr 16 '19 07:04 javadpeyman