Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RuntimeError: Device index must not be negative #12

Closed
1eunght opened this issue Feb 17, 2022 · 3 comments
Closed

RuntimeError: Device index must not be negative #12

1eunght opened this issue Feb 17, 2022 · 3 comments

Comments

@1eunght
Copy link

1eunght commented Feb 17, 2022

Dear author @Wentao-Xu ,

I can reproduce the Baselines without error, however RuntimeError appeared when I ran the HIST model. I have set all the package to the according version as mentioned in the requirements.txt. But error keeps appearing when it starts training.

我可以复现Baselines的模型,但是在跑HIST的时候会出现RuntimeError报错。我已经把要求的库都降级到相应的版本,但是仍然出现如下报错。

[2022-02-17 11:43:15] - Running 0 Epoch: 0
[2022-02-17 11:43:15] - training...
0%|
[2364:MainThread](2022-02-17 11:43:15,750) ERROR - qlib.workflow - [utils.py:38] - An exception has been raised[RuntimeError: Device index must not be negative].
File "learn.py", line 450, in
main(args)
File "learn.py", line 288, in main
train_epoch(epoch, model, optimizer, train_loader, writer, args, stock2concept_matrix)
File "learn.py", line 116, in train_epoch
pred = model(feature, stock2concept_matrix[stock_index], market_value)
File "D:\anaconda3\envs\qlib\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl
result = self.forward(*input, **kwargs)
File "D:\Codes\HIST\model.py", line 79, in forward
device = torch.device(torch.get_device(x+1))
RuntimeError: Device index must not be negative

I wonder why it is the case and how can I fix it? Thank you for your time!

请问应该怎么解决这一问题呢?谢谢!

@Wentao-Xu
Copy link
Owner

你好,看你的报错,似乎是你没有在gpu上使用pytorch.

@bell99431
Copy link

how to run this project without cuda?

@Hoilap
Copy link

Hoilap commented May 9, 2024

我遇到和你一样的问题。如果使用CPU运算,将line 79改为device = torch.device('cpu',0)即可运行。仅供参考。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants