taoxugit / AttnGAN

MIT License
1.33k stars 415 forks source link

Add CPU option (fix issue #23) #24

Open kheimpel opened 5 years ago

kheimpel commented 5 years ago

Added "if CUDA" to all cuda() calls in trainer.py Makes it possible to evaluate & train on CPU

bjente commented 5 years ago

This fix still doesn't enable me to evaluate and train on CPU... I keep on getting this error: AttributeError: module 'torch._C' has no attribute '_cuda_getDevice Do you know how to fix it?

kheimpel commented 5 years ago

This fix still doesn't enable me to evaluate and train on CPU... I keep on getting this error: AttributeError: module 'torch._C' has no attribute '_cuda_getDevice Do you know how to fix it?

Could you please provide filename and line number?

bjente commented 5 years ago

Traceback (most recent call last): File "main.py", line 136, in algo = trainer(output_dir, dataloader, dataset.n_words, dataset.ixtoword) File "/Users/bentedebruin/Documents/AttnGAN/code/trainer.py", line 36, in init torch.cuda.set_device(cfg.GPU_ID) File "/Users/bentedebruin/miniconda3/lib/python3.7/site-packages/torch/cuda/init.py", line 264, in set_device torch._C._cuda_setDevice(device) AttributeError: module 'torch._C' has no attribute '_cuda_setDevice'

This is the error I'm getting when I put this in command line: python main.py --cfg cfg/eval_coco.yml

kheimpel commented 5 years ago

Did you set GPU_ID = 0 in your config file (eval_coco.yml)?

bjente commented 5 years ago

I just did, but I get the exact same error. Same filenames and line numbers...

kheimpel commented 5 years ago

Ok. Please try GPU_ID = -1 in your yml file.

Sorry - has been a while...

bjente commented 5 years ago

Thank you so much! I don't get that error anymore!!! :)