GPU enabled functions react slow on first call

Dear community, I want to utilize the GPU of my system to accelerate matrix multiplication. From the list of GPU-enabled functions, I can see that "mtimes" is available, therefore it should be accessible using gpuArrays.
My system is:
Matlab R2016b
Visual Studio 2013
CUDA 9.0
GTX 1070
I start by defining two matrices as gpuArrays:
>>gDexMat=gpuArray(DexMat);
>> gx_PD=gpuArray(x_PD);
>> whos gDexMat gx_PD
Name Size Bytes Class Attributes
gDexMat 200000x1000 4 gpuArray
gx_PD 1000x200000 4 gpuArray
I then perform the multiplication, gather the data and stop the time how long it took:
>> tic;gIQMat=gx_PD*gDexMat;IQMat=gather(gIQMat);toc %doing the demodulation
Elapsed time is 0.528126 seconds.
>> tic;gIQMat=gx_PD*gDexMat;IQMat=gather(gIQMat);toc
Elapsed time is 0.414626 seconds.
>> tic;gIQMat=gx_PD*gDexMat;IQMat=gather(gIQMat);toc
Elapsed time is 0.405255 seconds.
In this example, the time it took is pretty constant. However, when I start Matlab the first time, the execution may take extremely long, up to 45 seconds. Even the first call:
>>gDexMat=gpuArray(DexMat);
Can sometimes take up to a minute.
Does any body have any ideas why this is happening? Best, Ludwig

 採用された回答

Joss Knight
Joss Knight 2017 年 10 月 27 日

1 投票

MATLAB R2016b is built with CUDA 7.5. The first time you load the GPU libs they have to be just-in-time compiled to match your Pascal-architecture GPU. See the answer here for an explanation and some steps to prevent this compilation happening every time.

その他の回答 (1 件)

scanner
scanner 2017 年 11 月 5 日

0 投票

Thanks for your help. Installing Matlab R2017b solved this problem.

カテゴリ

ヘルプ センター および File ExchangeGPU Computing についてさらに検索

質問済み:

2017 年 10 月 27 日

回答済み:

2017 年 11 月 5 日

Community Treasure Hunt

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

Start Hunting!

Translated by