predict fucntion in deep learning toolbox does not use gpu
13 views (last 30 days)
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:
A = gpuArray([1 0 1; -1 -2 0; 0 1 -1]);
e = eig(A);
It works fine with my gpu:
Name: 'GeForce RTX 2060'
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
Any way to deal with this problem? Thank you very much.
Joss Knight on 14 Aug 2021
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.
For details see dlnetwork/predict Extended Capabilities.