[英]Matlab Convolution using gpu
我用gpuArray嘗試了matlab的卷積函數conv2 convn。 例如convn(gpuArray.rand(100,100,10,'single'),gpuArray.rand(5,'single')並將其與cpu版本convn(rand(100,100,10),rand(5))進行了比較。 gpu版本比cpu版本慢很多,尤其是當我將函數放入循環(這對我來說很重要)時,尤其值得注意。有人知道使用matlab和gpu進行快速卷積的替代方案嗎?從5x5到14x14?
在測試案例中,GPU性能受數據數組大小[100x100x10]和[5x5]限制。
實際性能還取決於GPU和CPU模塊類型。 對於您的數據大小(以下代碼的測試案例2),我可以在GPU Tesla M2090和CPU Xeon E5-2609上獲得性能提升(2.75倍)。
對於以下matlab測試代碼
m=1000;
n=100;
k=5;
gc=convn(gpuArray.rand(m,m,10,'single'),gpuArray.rand(k,'single'));
tic;
for i=1:n
gc=convn(gpuArray.rand(m,m,10,'single'),gpuArray.rand(k,'single'));
end
toc
c=convn(rand(m,m,10,'single'),rand(k,'single'));
tic;
for i=1:n
c=convn(rand(m,m,10,'single'),rand(k,'single'));
end
toc
當m=1000; n=100; k=5;
m=1000; n=100; k=5;
我在GPU上獲得了非常出色的性能提升(11.6倍)。
Elapsed time is 2.367453 seconds.
Elapsed time is 27.502952 seconds.
但是當m=100; n=1000; k=5;
m=100; n=1000; k=5;
我只有2.75倍
Elapsed time is 1.206053 seconds.
Elapsed time is 3.330559 seconds.
當m=100; n=1000; k=14;
m=100; n=1000; k=14;
,效果會更好(4.84倍)。
Elapsed time is 2.804957 seconds.
Elapsed time is 13.585698 seconds.
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.