在执行cuda程序时遇到cudaerror_enum问题
.exe中的***处最可能的异常Microsoft C++异常:内存位置*****处的cudaerror_enum
想问问有可能是什么原因,本电脑用vs2010 cudav5.0 显卡是gt9600
但问题是同样的代码在vs2010 cudav5.0 显卡是gt640上跑是没问题的。
而且出错的很不确定,就是我是循环使用一个函数,里面有cuda的代码,但有时循环了40多次然后出错了,有时循环了50多次然后出错,每次都不太确定。
下面贴一些出错的代码
void reconstruction::X_image_display::iterative_project_point()
{
//这里部分代码省略
for(int i=0;i<5;i++)
{
output_node->find_corresponding(data_inf->vertex_dev,data_inf->normal_dev,data_inf->
corresponding_vertex_dev,data_inf->corresponding_normal_dev,data_inf->cor_juedge_dev);
data_inf->get_rotation_transfer(900,0.7,data_inf->cor_juedge_dev);//这一句出错了
data_inf->transf();
}
//下面部分代码省略
}
void reconstruction::save_output_image::find_corresponding(zuobiao *vertex,zuobiao *normal,zuobiao *corresponding_vertex,zuobiao *corresponding_normal,bool *cor_judge)
{
find_corresponding_dev(vertex,normal,corresponding_vertex,corresponding_normal,cor_judge,
this->volumn_,this->edgetable_dev,this->tritable_dev);
}
void reconstruction::find_corresponding_dev(zuobiao *vertex,zuobiao *normal,zuobiao *corresponding_vertex,zuobiao *corresponding_normal,bool *cor_judge,
float *volumn ,int *edgetable_dev,int *tritable_dev)
{
dim3 dimblock(256);
dim3 dimgrid(1200);
find_corresponding_dev_global<<<dimgrid,dimblock>>>(vertex,normal,corresponding_vertex,corresponding_normal,cor_judge,
volumn,edgetable_dev,tritable_dev);
//关键是这里如果用cudamemcpy把cor_judge分配到主机上没错
}
void reconstruction::data_information::get_rotation_transfer(float thr1,float thr2,bool *corjudge)
{
get_r_t_dev(this->vertex_dev,this->corresponding_vertex_dev,this->corresponding_normal_dev,this->
cor_juedge_dev,this->rotation,this->transfer,thr1,thr2);
}
void reconstruction::get_r_t_dev(zuobiao vertex,zuobiao corresponding_vertex,zuobiao corresponding_normal,bool cor_judge,float rotation,float transfer,float thr1,float thr2)
{
//但这里如果用cudamemcpy把cor_judge分配到主机上也出错了,cor_judge原本是存储在显卡里的
float a_,t_;
a_=new float[120066];
t_=new float[12006];
for(int i=0;i<1200;i++)
{
for(int j=0;j<6;j++)
{
t_[i*6+j]=0;
for(int k=0;k<6;k++)
{
a_[i*6*6+j*6+k]=0;
}
}
}
float a_dev,t_dev;
cudaMalloc(&a_dev,120066sizeof(float));
cudaMalloc(&t_dev,12006sizeof(float));
cudaMemcpy(a_dev,a_,120066sizeof(float),cudaMemcpyHostToDevice);
cudaMemcpy(t_dev,t_,12006sizeof(float),cudaMemcpyHostToDevice);
dim3 dimblock(256);
dim3 dimgrid(1200);
get_r_t_dev_global<<<dimgrid,dimblock,2000sizeof(float)>>>(vertex,corresponding_vertex,corresponding_normal,
cor_judge,a_dev,t_dev,thr1,thr2);//这一句出错了
cudaMemcpy(a_,a_dev,120066sizeof(float),cudaMemcpyDeviceToHost);
cudaMemcpy(t_,t_dev,12006*sizeof(float),cudaMemcpyDeviceToHost);
cudaFree(a_dev);
cudaFree(t_dev);
//一下代码省略
}
想请问一下知道是什么原因吗???