I get error when I try to test an agent trained on a PC( with GPU) on a second computer which has no GPU (Reinforcement Learning)
3 views (last 30 days)
Show older comments
Hello,
I trained a DDPG agent on PC where I placed the critic and actor network on a GPU. After training, I am able to run and test the agent performance on that PC. However, when I copy the trained agent to another PC, I am not able to run it. I get a warning related to GPU. This second PC has no GPU, so I am using the CPU as the device. The first PC uses MATLAB 2023a and the second PC is 2022b, which I donot think should be a problem. Please see image of the error attached. Thanks
6 Comments
Takeshi Takahashi
on 13 Jul 2023
Can you re-save the agent on the PC with GPU?
Before saving the agent, please follow these steps:
actor = getActor(agent);
actor.UseDevice = "cpu";
setActor(agent, actor);
critic = getCritic(agent);
critic.UseDevice = "cpu";
setCritic(agent, critic);
Answers (1)
Walter Roberson
on 13 Jul 2023
Your Training_Script1 is trying to load() a .mat file that has a gpuArray() object stored in it, but you are trying to do that on a machine that has no attached GPU. MATLAB is trying to create the gpuArray() object, but is failing to do so.
If you need to load something with an embedded gpuArray object on a system without GPU, then that is not going to be possible.
Sometimes this problem can show up if you have multiple variables saved in a .mat file, some of which have gpuArray objects stored in them, but for you work on the non-GPU system, you do not happen to need the variables that have gpuArray objects. In such a case, the trick is to be selective about which variables you load, such as
datastruct = load('MySavedFile.mat', 'trainedobject'); %only load the items you need
trainedobject = datastruct.trainedobject;
instead of
load('MySavedFile.mat'); %loads everything in the file
1 Comment
Emmanouil Tzorakoleftherakis
on 13 Jul 2023
Edited: Emmanouil Tzorakoleftherakis
on 13 Jul 2023
@Bay Jay this answer explains why you see the error. Please give us some time to investigate if there is a workaround.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!