AI4Finance-Foundation / FinRL

FinRL: Financial Reinforcement Learning. 🔥
https://ai4finance.org
MIT License
9.61k stars 2.33k forks source link

Using GPU #60

Closed amihos closed 3 years ago

amihos commented 3 years ago

I am following multi stock notebook. When about to train the first model I got this error message:

Model 1: A2C agent = DRLAgent(env = env_train) model_a2c = agent.get_model("a2c") {'n_steps': 5, 'ent_coef': 0.01, 'learning_rate': 0.0007} Using cpu device /opt/conda/lib/python3.6/site-packages/torch/cuda/init.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at /opt/conda/conda-bld/pytorch_1607370116979/work/c10/cuda/CUDAFunctions.cpp:100.) return torch._C._cuda_getDeviceCount() > 0

I have a RTX2060 graphic card and the latest driver. What else should I do to be able to use it with the algorithm?

amihos commented 3 years ago

Thank you for the help. I installed Cuda. Now I do not get that error message however the algorithm is still using the CPU. Do you have any idea how I can force it to use the GPU? |

On Mon, 11 Jan 2021 at 23:46, Carlo Grisetti notifications@github.com wrote:

Make sure you have PyTorch installed with the appropriate cuda version (latest supported is 11.0) You can get the install command here: https://pytorch.org/get-started/locally/ Also, you should install CUDA 11.0

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AI4Finance-LLC/FinRL-Library/issues/60#issuecomment-758272487, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIMPOFHZ4HFGZWLC5UF3KR3SZN5SXANCNFSM4V575LUQ .

amihos commented 3 years ago

I could mange to get the algorithm to use cuda device and it says actually that it is using cuda device however when I check task manager it shows that the cpu is being used! Any idea why?

carlogrisetti commented 3 years ago

It is also using the cpu :)

amihos commented 3 years ago

It also using the cpu :)

at 100%? while GPU is sitting at 0-1%?

amihos commented 3 years ago

I just tried CartPole training algorithm from https://stable-baselines3.readthedocs.io/en/master/guide/examples.html and it clearly uses my GPU constantly at 90% so there is something going on with the finrl algorithm

carlogrisetti commented 3 years ago

Yes, not all agents can use GPU. Some are more optimized than others, and it depends on the task to do. Other than that, I can't help you anymore :)

amihos commented 3 years ago

Thank you for the explanation. I know now :)

On Thu, 21 Jan 2021 at 21:35, Carlo Grisetti notifications@github.com wrote:

Yes, not all agents can use GPU. Some are more optimized than others, and it depends on the task to do. Other than that, I can't help you anymore :)

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AI4Finance-LLC/FinRL-Library/issues/60#issuecomment-764920583, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIMPOFAIATZDKRJ5FS6RT6LS3CF2VANCNFSM4V575LUQ .

YangletLiu commented 3 years ago

Our new version will fully support GPUs.

niceban commented 3 years ago

Our new version will fully support GPUs.

Has it released by now? And does it support for DQN and A2C?

ashmitsharma commented 1 year ago

@amihos can you please share the code. You modified to use CartPole algorithm. Thank You