查看有关CUDA问题的答案和评论,以及CUDA标记维基,我发现通常建议每个API调用的返回状态都应该检查错误.API文档包括像功能cudaGetLastError,cudaPeekAtLastError以及cudaGetErrorString,但什么是把这些结合在一起,以可靠地捕捉和无需大量额外的代码报告错误的最好方法?
我正在测试svd,Matlab R2014a似乎没有CPUvs GPU加速.我正在使用一张GTX 460卡片和一张卡片Core 2 duo E8500.
这是我的代码:
%test SVD
n=10000;
%host
Mh= rand(n,1000);
tic
%[Uh,Sh,Vh]= svd(Mh);
svd(Mh);
toc
%device
Md = gpuArray.rand(n,1000);
tic
%[Ud,Sd,Vd]= svd(Md);
svd(Md);
toc
Run Code Online (Sandbox Code Playgroud)
此外,运行时间与运行不同,但CPU和GPU版本大致相同.为什么没有加速?
这是一些测试
for i=1:10
clear;
m= 10000;
n= 100;
%host
Mh= rand(m,n);
tic
[Uh,Sh,Vh]= svd(Mh);
toc
%device
Md = gpuArray.rand(m,n);
tic
[Ud,Sd,Vd]= svd(Md);
toc
end
>> test_gpu_svd
Elapsed time is 43.124130 seconds.
Elapsed time is 43.842277 seconds. …Run Code Online (Sandbox Code Playgroud) 我正在尝试运行 cuda 7.0 中提供的 cuSolver 库。我在使用 cuSolver 库时遇到问题,解决起来一定非常简单,但我在这里寻求一些帮助。
我看了很多张贴的例子,我特别选择了 JackOLantern 中的这个:
我刚刚将其缩减为 kernel_0.cu:
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include<iostream>
#include<iomanip>
#include<stdlib.h>
#include<stdio.h>
#include<assert.h>
#include<math.h>
#include <cusolverDn.h>
#include <cuda_runtime_api.h>
#include "Utilities.cuh"
/********/
/* MAIN */
/********/
int main(){
// --- gesvd only supports Nrows >= Ncols
// --- column major memory ordering
// --- cuSOLVE input/output parameters/arrays
int *devInfo; gpuErrchk(cudaMalloc(&devInfo, sizeof(int)));
// --- CUDA solver initialization
cusolverDnHandle_t solver_handle;
cusolverDnCreate(&solver_handle);
cusolverDnDestroy(solver_handle);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我使用与 JackOlantern 相同的 Utilities.cuh 和 …