qlib icon indicating copy to clipboard operation
qlib copied to clipboard

ADARNN torch CPU only

Open kurucan opened this issue 4 years ago • 4 comments

How can I set to use CPU only If GPU is not available? The error stems from the line 150 in pytorch_adarnn.py

/usr/local/lib/python3.7/site-packages/pyqlib-0.7.2.99-py3.7-linux-x86_64.egg/qlib/contrib/model/pytorch_adarnn.py in init(self, d_feat, hidden_size, num_layers, dropout, n_epochs, pre_epoch, dw, loss_type, len_seq, len_win, lr, metric, batch_size, early_stop, loss, optimizer, n_splits, GPU, seed, **kwargs) 148 149 self.fitted = False --> 150 self.model.cuda() 151 152 @property

RuntimeError: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from

https://github.com/microsoft/qlib/blob/main/qlib/contrib/model/pytorch_adarnn.py self.device = torch.device("cuda:%d" % (GPU) if torch.cuda.is_available() and GPU >= 0 else "cpu")

kurucan avatar Nov 24 '21 00:11 kurucan

Thanks for reporting the bug :) I think replacing all the .cuda() with .to(self.device) will solve this issue. You can follow this example. https://github.com/microsoft/qlib/blob/main/qlib/contrib/model/pytorch_nn.py#L157

Would you mind sending a PR to fix this issue and become one of the contributors of Qlib!

Thanks

you-n-g avatar Nov 28 '21 05:11 you-n-g

This issue is stale because it has been open for three months with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

github-actions[bot] avatar Feb 26 '22 06:02 github-actions[bot]

@SunsetWolf will help to solve this issue

you-n-g avatar Mar 11 '22 03:03 you-n-g

I think this issue already fixed&merged in #1070 . Can I ask why @you-n-g reopened this?

HyeongminMoon avatar Jun 15 '22 09:06 HyeongminMoon

This issue is stale because it has been open for three months with no activity. Remove the stale label or comment on the issue otherwise this will be closed in 5 days

github-actions[bot] avatar Sep 13 '22 12:09 github-actions[bot]