FinRL icon indicating copy to clipboard operation
FinRL copied to clipboard

How to use GPU

Open avatarproject123 opened this issue 1 year ago • 3 comments

I have cuda installed. I have given "device": "cuda" in params but I am still getting using cpu device. A2C_PARAMS = {"n_steps": 5, "ent_coef": 0.01, "learning_rate": 0.0005, "device": "cuda"}

output: {'n_steps': 5, 'ent_coef': 0.01, 'learning_rate': 0.0005, 'device': 'cuda'} Using cpu device Logging to results/a2c

how to use gpu ?

avatarproject123 avatar Jun 01 '23 10:06 avatarproject123

https://github.com/AI4Finance-Foundation/FinRL/issues/1023 Did you check cuda availability of torch itself?

icsl-Jeon avatar Jun 01 '23 10:06 icsl-Jeon

@icsl-Jeon yes I have installed cuda import torch torch.cuda.is_available() Output : True

https://ibb.co/m9vdRpy

avatarproject123 avatar Jun 01 '23 16:06 avatarproject123

Hello,

I had a similar problem before, I'm not sure if it's the same exact underlying issue, though. Nevertheless, it might help you, so let me share my case. So, I also installed cuda but it didn't work. It turned out that I had multiple pytorch versions installed and it was using the one without GPU support. Maybe it's one thing you could check, if you haven't already. In my case that solved the problem.

Also, maybe running the below could indicate if your problem is similar. In my case it showed the CUDA version, but not the CUDNN. After using the Pythorch version with GPU support, the CUDNN version appeared, and also 'Using cuda device' when running the code for training the agent.

import torch print(f'PyTorch version: {torch.version}') print('*'10) print(f'_CUDA version: ') !nvcc --version print(''*10) print(f'CUDNN version: {torch.backends.cudnn.version()}') print(f'Available GPU devices: {torch.cuda.device_count()}') print(f'Device Name: {torch.cuda.get_device_name()}')

Hope it helps.

BalazsHi avatar Jun 03 '23 15:06 BalazsHi