필터 지우기
필터 지우기

GPU Training RL Toolbox on R2022a

조회 수: 35 (최근 30일)
Berk Agin
Berk Agin 2022년 3월 28일
답변: Valerio 2024년 7월 26일 14:52
Hello everyone,
I am trying to train my agent with using Reinforcement Learning Toolbox Matlab2022a. Unfortunately, I couldn't run the training due to some packages were updated. rlRepresentationOptions was contain 'UseDevice','gpu' option, but the package has been changed to rlOptimizerOptions without any 'UseDevice' option. How can I run my training with using gpu? Thank you in advance.
  댓글 수: 3
Berk Agin
Berk Agin 2022년 3월 31일
Hi Kaustubh,
Thank you for your answer. I'll be looking forward to the solution. Have a nice day.
Stefan
Stefan 2023년 12월 13일
This is still broken...

댓글을 달려면 로그인하십시오.

답변 (2개)

Aashita Dutta
Aashita Dutta 2022년 3월 31일
Hello Berk,
According to my understanding, you are trying to train agent using Reinforcement Learning Toolbox MATLAB 2022a. Due to package upgrades, rlRepresentationOptions is not recommended, instead rlOptimizerOptions is used to train agent.
Could you please try the following workaround to train using GPU:
criticOptions = rlOptimizerOptions('LearnRate',1e-03,'GradientThreshold',1);
criticOptions.UseDevice = 'gpu';
Please follow the instructions given in this documentation- How to training agent using GPU example to get more information.
  댓글 수: 4
Abolfazl Nejatian
Abolfazl Nejatian 2022년 7월 27일
but as i check there is no property 'UseDevice' for the rlOptimizerOptions!
could you please help me on this matter.
Bradley Fourie
Bradley Fourie 2022년 8월 17일
편집: Bradley Fourie 2022년 8월 17일
Hi everyone,
I would like to add my 2 cents since the Matlab R2022a reinforcement learning toolbox documentation is a complete mess.
I think I have figured it out:
  • Step 1: figure out if you have a supported GPU with
availableGPUs = gpuDeviceCount("available")
gpuDevice(1)
  • Step 2: When creating your actor and critic use the following to select the GPU (yours might differ but the UseDevice is what is important here)
actor = rlDiscreteCategoricalActor(actorNetWork,oinfo,ainfo,'UseDevice','gpu');
critic = rlValueFunction(criticNetwork,oinfo,'UseDevice','gpu');
  • Step 3: Create your optimizer as usual
actorOpts = rlOptimizerOptions('LearnRate',3e-4,'GradientThreshold',1);
criticOpts = rlOptimizerOptions('LearnRate',3e-4,'GradientThreshold',1);
From what I can gather (with my last two braincells), the function call to use a GPU has moved to the newer actor and critic constructors. However, some staff guidance would be HIGHLY appreciated.

댓글을 달려면 로그인하십시오.


Valerio
Valerio 2024년 7월 26일 14:52
Hi guys, I solved in this way:
% define the agent
myagent = rlPPOAgent(obsInfo, actInfo, initopts, agent_opt);
% try to change it into gpu
myactor = getActor(myagent);
mycritic = getCritic(myagent);
myactor.UseDevice = 'gpu';
mycritic.UseDevice = 'gpu';
in this way I could use the rlOptimizerOptions function.
hoping this might be useful, have a good day.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by