0
我想在matlab中用gpuArray做一個簡單的矩陣乘法。我正在使用帶有4GB專用內存的NVIDIA GForce 960M GPU。代碼如下。GPU在大陣中在gpuArray矩陣上崩潰
function gpuExample(A, B)
tic
C = A*B; % matrix product on Client
tC = toc;
% copy A and B from Client to GPU
a = gpuArray(A); b = gpuArray(B);
tic
c = a*b; % matrix product on GPU
tgpu = toc;
tic
CC = gather(c); % copy data from GPU to Client
tg = toc;
disp(['Matrix multiply time on Client is ' num2str(tC)])
disp(['Matrix multiply time on GPU is ' num2str(tgpu)])
disp(['Time for gathering data from GPU back to Client is '
num2str(tg)])
% Verify that GPU and Client computations agree
tol = 1e-5;
if any(abs(CC-C) > tol)
disp('Matrix product on Client and GPU disagree')
else
disp('Matrix product on Client and GPU agree')
end
end %
N=4000;
A=rand(N);
B=rand(N);
gpuExample(A,B)
代碼工作好小矩陣,但是當我嘗試用矩陣尺寸4000X4000兩個矩陣,GPU崩潰,所以做了Matlab執行。
GPU的輸出如下所示:
gpuDevice
ANS =
CUDADevice與屬性:
Name: 'GeForce GTX 960M'
Index: 1
ComputeCapability: '5.0'
SupportsDouble: 1
DriverVersion: 7.5000
ToolkitVersion: 7.5000
MaxThreadsPerBlock: 1024
MaxShmemPerBlock: 49152
MaxThreadBlockSize: [1024 1024 64]
MaxGridSize: [2.1475e+09 65535 65535]
SIMDWidth: 32
TotalMemory: 4.2950e+09
MultiprocessorCount: 5
ClockRateKHz: 1176000
ComputeMode: 'Default'
GPUOverlapsTransfers: 1
KernelExecutionTimeout: 1
CanMapHostMemory: 1
DeviceSupported: 1
DeviceSelected: 1
下面是崩潰報告:
警告:CUDA執行期間發生意外錯誤。 CUDA的錯誤是: CUDA_ERROR_LAUNCH_FAILED
對我來說,GPU應該是足夠好,乘大小4000X4000的兩個矩陣。它爲什麼會崩潰。
並且較小的'N'值不會崩潰? – mpaskov
是的,它工作的數量較少。我測試了N = 3500,它工作正常 –