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 (최근 30일)
이전 댓글 표시
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
Takeshi Takahashi
2023년 7월 13일
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);
답변 (1개)
Walter Roberson
2023년 7월 13일
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
Emmanouil Tzorakoleftherakis
2023년 7월 13일
편집: Emmanouil Tzorakoleftherakis
2023년 7월 13일
@Bay Jay this answer explains why you see the error. Please give us some time to investigate if there is a workaround.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!