필터 지우기
필터 지우기

predict fucntion in deep learning toolbox does not use gpu

조회 수: 2 (최근 30일)
yongbo chen
yongbo chen 2021년 7월 27일
답변: Joss Knight 2021년 8월 14일
I use a pre-trained network from tensorflow 2.0 to predict a depth image from an RGB image. The code is:
dlX = dlarray(double(I)./255,'SSCB');
dlY = predict(dlnet,dlX);
The code works fine, but it is very slow. I find that it seems that the code only use the cpu core instead of gpu.
From the online help document, I find the following explanation:
It seems that the default way to run predict is to use a gpu. I find my gpu seems to be avaliable in MATLAB by running the gpu test function like:
gpuDevice;
A = gpuArray([1 0 1; -1 -2 0; 0 1 -1]);
e = eig(A);
It works fine with my gpu:
Name: 'GeForce RTX 2060'
Index: 1
ComputeCapability: '7.5'
SupportsDouble: 1
DriverVersion: 11.2000
ToolkitVersion: 11
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 6.4425e+09
AvailableMemory: 4.9872e+09
MultiprocessorCount: 30
ClockRateKHz: 1200000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceAvailable: 1
DeviceSelected: 1
Any way to deal with this problem? Thank you very much.
  댓글 수: 2
KSSV
KSSV 2021년 7월 27일
편집: KSSV 2021년 7월 27일
You can try:
I = gpuArray(I) ;
dlX = dlarray(I./255,'SSCB');
dlY = predict(dlnet,dlX);
Not sure, but it might throw some errors. Also note that the weights needs to be taken to gpu, not sure whether it works completely on GPU or not.
yongbo chen
yongbo chen 2021년 7월 27일
Thank you for your answer. Do you know how to take the weights to gpu in MATLAB. Any function?

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

답변 (1개)

Joss Knight
Joss Knight 2021년 8월 14일
That is the documentation for DAGNetwork, not dlnetwork. dlnetwork does not have an ExecutionEnvironment, it chooses its environment in the same way that other GPU operations do, by reacting to the incoming data. As KSSV points out, converting to a gpuArray is the correct solution in this case.

카테고리

Help CenterFile Exchange에서 Parallel and Cloud에 대해 자세히 알아보기

태그

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by