ShomyLiu / Neu-Review-Rec

A Toolkit for Neural Review-based Recommendation models with Pytorch.
http://shomy.top/2019/12/31/neu-review-rec/
169 stars 54 forks source link

RuntimeError: CUDA error: invalid device ordinal #17

Open yinzhiqiangluvlzx opened 4 years ago

yinzhiqiangluvlzx commented 4 years ago

作者,您好。我在使用DeepCoNN训练模型的时候需要RuntimeError: CUDA error: invalid device ordinal问题,搜索了一圈没有有效的方法,想请教您帮我看看,十分感谢! (pytorch) D:\workspace\pycharm\Neu-Review-Rec>python main.py train --model=DeepCoNN --num_fea=1 --output=fm load npy from dist...


user config: vocab_size => 50002 word_dim => 300 r_max_len => 202 u_max_r => 13 i_max_r => 24 train_data_size => 51764 test_data_size => 6471 val_data_size => 6471 user_num => 5543 item_num => 3570 batch_size => 128 print_step => 100


Traceback (most recent call last): File "main.py", line 212, in fire.Fire() File "C:\Users\yinzhiqiang\anaconda3\envs\pytorch\lib\site-packages\fire\core.py", line 138, in Fire component_trace = _Fire(component, args, parsed_flag_args, context, name) File "C:\Users\yinzhiqiang\anaconda3\envs\pytorch\lib\site-packages\fire\core.py", line 468, in _Fire target=component.name) File "C:\Users\yinzhiqiang\anaconda3\envs\pytorch\lib\site-packages\fire\core.py", line 672, in _CallAndUpdateTrace component = fn(*varargs, **kwargs) File "main.py", line 43, in train torch.cuda.set_device(opt.gpu_id) File "C:\Users\yinzhiqiang\anaconda3\envs\pytorch\lib\site-packages\torch\cuda__init__.py", line 263, in set_device torch._C._cuda_setDevice(device) RuntimeError: CUDA error: invalid device ordinal

ShomyLiu commented 4 years ago

你好,配置文件中默认的gpu_id设置为1, 如果机器只有一个显卡的话,需要设置为0.

yinzhiqiangluvlzx commented 4 years ago

谢谢您的解答!问题已经解决了,十分感谢!期待您后续把其他算法完善!

ShomyLiu commented 4 years ago

争取年前可以完成,欢迎提PR