RuntimeError: CUDA error: invalid device ordinal
yinzhiqiangluvlzx opened this issue · 3 comments
作者,您好。我在使用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
你好,配置文件中默认的gpu_id设置为1, 如果机器只有一个显卡的话,需要设置为0.
谢谢您的解答!问题已经解决了,十分感谢!期待您后续把其他算法完善!
争取年前可以完成,欢迎提PR