9 个解决方案
#1
你用的是Visual Studio什么版本?
#2
vs2010+cuda6.0
#3
看来是和__synthreads()一样的问题?你可是打开SDK中的例子看看,能不能正常显示?
#4
我打开SDK中的例子看了,也显示未定义标识符,里面的例子虽然有atomicAdd(例子:C:\ProgramData\NVIDIA Corporation\CUDA Samples\v6.0\0_Simple\simplePrintf),但我把这个函数注释掉,程序也是能正常运行的
#5
生成解决方案时提示:
1> GHistoGramEqualizion.cu(108).cu(108): error : [b]a host function call cannot be configured和
1> 1 error detected in the compilationof "C:/Users/ADMINI~1/AppData/Local/Temp/tmpxft_000090c8_000000005_GHistoGramEqualizion.cpp1.ii".
1> GHistoGramEqualizion.cu
1> error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_50,code=\"sm_50,compute_50\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_UNICODE -DUNICODE -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\GHistoGramEqualizion.cu.obj "F:\cuda\GHistoGramEqualizion\GHistoGramEqualizion\GHistoGramEqualizion.cu"”已退出,返回代码为 2。
1> GHistoGramEqualizion.cu(108).cu(108): error : [b]a host function call cannot be configured和
1> 1 error detected in the compilationof "C:/Users/ADMINI~1/AppData/Local/Temp/tmpxft_000090c8_000000005_GHistoGramEqualizion.cpp1.ii".
1> GHistoGramEqualizion.cu
1> error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_50,code=\"sm_50,compute_50\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_UNICODE -DUNICODE -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\GHistoGramEqualizion.cu.obj "F:\cuda\GHistoGramEqualizion\GHistoGramEqualizion\GHistoGramEqualizion.cu"”已退出,返回代码为 2。
#6
下面是一个直方图有关的函数,我用来测试的,生成解决方案时出现上述的错误
__global__ void HistoGramEqualkernel(unsigned char* input_data,unsigned char* output_data,int width,int height)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int tid=y*width+x;
int histOrg[256]={0};
if(x<width && y<height)
{
int value=input_data[tid];
atomicAdd(&(histOrg[value]),1);
}
float histAdd[256] = {0};//累计直方图
int grayVal[256] = {0};//变换后的灰度值
int ntotal = width*height;
for (int i=0; i<256; i++)
{
if (i == 0)
{
histAdd[i] = histOrg[i];
}
else
{
histAdd[i] = (histAdd[i-1] + histOrg[i]);
}
}
//计算新灰度值
for (int i=0; i<256; i++)
{
grayVal[i] = (int)(histAdd[i]/ntotal*255+0.5);
}
if(x<width && y<height)
{
output_data[x*width+y] = grayVal[input_data[x*width+y]];
}
__host__ void HistoGramEqual(unsigned char* input_data,unsigned char* output_data,int width,int height)
{
unsigned char *Md, *Nd;
int size = width * height * sizeof(unsigned char);
//int*Or,*Eq;
//int dsize =256 * sizeof(int);
double timeStart,timeEnd,time;
cudaSetDevice(0);
cudaMalloc((void**)&Md, size);
cudaMalloc((void**)&Nd, size);
cudaMemcpy(Md, input_data, size, cudaMemcpyHostToDevice);
dim3 dimBlock( TILE_WIDTH, TILE_WIDTH);
dim3 dimGrid((width+TILE_WIDTH-1)/ TILE_WIDTH, (height+TILE_WIDTH-1)/ TILE_WIDTH); HistoGramEqual<<< dimGrid, dimBlock >>>(Md, Nd, width, height); //调用内核函数
cudaMemcpy(output_data,Nd,size, cudaMemcpyDeviceToHost);
//cudaMemcpy(histEqual,Eq,dsize, cudaMemcpyDeviceToHost);
//cudaMemcpy(histOrg,Or,dsize, cudaMemcpyDeviceToHost);
cudaFree(Md);
cudaFree(Nd);
__global__ void HistoGramEqualkernel(unsigned char* input_data,unsigned char* output_data,int width,int height)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int tid=y*width+x;
int histOrg[256]={0};
if(x<width && y<height)
{
int value=input_data[tid];
atomicAdd(&(histOrg[value]),1);
}
float histAdd[256] = {0};//累计直方图
int grayVal[256] = {0};//变换后的灰度值
int ntotal = width*height;
for (int i=0; i<256; i++)
{
if (i == 0)
{
histAdd[i] = histOrg[i];
}
else
{
histAdd[i] = (histAdd[i-1] + histOrg[i]);
}
}
//计算新灰度值
for (int i=0; i<256; i++)
{
grayVal[i] = (int)(histAdd[i]/ntotal*255+0.5);
}
if(x<width && y<height)
{
output_data[x*width+y] = grayVal[input_data[x*width+y]];
}
__host__ void HistoGramEqual(unsigned char* input_data,unsigned char* output_data,int width,int height)
{
unsigned char *Md, *Nd;
int size = width * height * sizeof(unsigned char);
//int*Or,*Eq;
//int dsize =256 * sizeof(int);
double timeStart,timeEnd,time;
cudaSetDevice(0);
cudaMalloc((void**)&Md, size);
cudaMalloc((void**)&Nd, size);
cudaMemcpy(Md, input_data, size, cudaMemcpyHostToDevice);
dim3 dimBlock( TILE_WIDTH, TILE_WIDTH);
dim3 dimGrid((width+TILE_WIDTH-1)/ TILE_WIDTH, (height+TILE_WIDTH-1)/ TILE_WIDTH); HistoGramEqual<<< dimGrid, dimBlock >>>(Md, Nd, width, height); //调用内核函数
cudaMemcpy(output_data,Nd,size, cudaMemcpyDeviceToHost);
//cudaMemcpy(histEqual,Eq,dsize, cudaMemcpyDeviceToHost);
//cudaMemcpy(histOrg,Or,dsize, cudaMemcpyDeviceToHost);
cudaFree(Md);
cudaFree(Nd);
#7
楼主,我和你遇到一样的问题了,前两天才遇到的,具体如下:
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 5.5.targets(592,9): error MSB3721:
命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\bin\nvcc.exe"
-gencode=arch=compute_10,code=\"sm_10,compute_10\"
--use-local-env --cl-version 2012 -ccbin "G:\Program Files\Mircosoft\Visual Studio2012\VC\bin"
-I"G:\Program Files\C ++ extension\ViennaCL-1.5.2\tests\src"
-I"G:\Program Files\C ++ extension\ViennaCL-1.5.2"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-G --keep-dir Debug -maxrregcount=0
--machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd "
-o Debug\wrap-cuda-buffer.cu.obj "G:\2014.8.16\cudadada4\cuda4\cuda4\wrap-cuda-buffer.cu"”已退出,返回代码为 2。
这个问题你解决了吗?就是5楼那个问题。
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 5.5.targets(592,9): error MSB3721:
命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\bin\nvcc.exe"
-gencode=arch=compute_10,code=\"sm_10,compute_10\"
--use-local-env --cl-version 2012 -ccbin "G:\Program Files\Mircosoft\Visual Studio2012\VC\bin"
-I"G:\Program Files\C ++ extension\ViennaCL-1.5.2\tests\src"
-I"G:\Program Files\C ++ extension\ViennaCL-1.5.2"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-G --keep-dir Debug -maxrregcount=0
--machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd "
-o Debug\wrap-cuda-buffer.cu.obj "G:\2014.8.16\cudadada4\cuda4\cuda4\wrap-cuda-buffer.cu"”已退出,返回代码为 2。
这个问题你解决了吗?就是5楼那个问题。
#8
解决了,其实是我的函数调用出错了。你按照右键解决方案属性-》配置属性-》CUDA C/C++-》Device-》Code Generation,加入compute_20,sm_20,并且把下面的“从父级或项目属性默认设置继承”的勾选去掉,还有你的.cu文件属性中的Device做同样的修改,首先搞清楚你的显卡计算能力,对“compute_20,sm_20”做相应的修改
#9
我也碰到了这样的问题,按照如上的设置进行了修改,结果还是错的!
显卡计算能力 3.0 应该支持的。
显卡计算能力 3.0 应该支持的。
#1
你用的是Visual Studio什么版本?
#2
vs2010+cuda6.0
#3
看来是和__synthreads()一样的问题?你可是打开SDK中的例子看看,能不能正常显示?
#4
我打开SDK中的例子看了,也显示未定义标识符,里面的例子虽然有atomicAdd(例子:C:\ProgramData\NVIDIA Corporation\CUDA Samples\v6.0\0_Simple\simplePrintf),但我把这个函数注释掉,程序也是能正常运行的
#5
生成解决方案时提示:
1> GHistoGramEqualizion.cu(108).cu(108): error : [b]a host function call cannot be configured和
1> 1 error detected in the compilationof "C:/Users/ADMINI~1/AppData/Local/Temp/tmpxft_000090c8_000000005_GHistoGramEqualizion.cpp1.ii".
1> GHistoGramEqualizion.cu
1> error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_50,code=\"sm_50,compute_50\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_UNICODE -DUNICODE -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\GHistoGramEqualizion.cu.obj "F:\cuda\GHistoGramEqualizion\GHistoGramEqualizion\GHistoGramEqualizion.cu"”已退出,返回代码为 2。
1> GHistoGramEqualizion.cu(108).cu(108): error : [b]a host function call cannot be configured和
1> 1 error detected in the compilationof "C:/Users/ADMINI~1/AppData/Local/Temp/tmpxft_000090c8_000000005_GHistoGramEqualizion.cpp1.ii".
1> GHistoGramEqualizion.cu
1> error MSB3721: 命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\bin\nvcc.exe" -gencode=arch=compute_20,code=\"sm_20,compute_20\" -gencode=arch=compute_30,code=\"sm_30,compute_30\" -gencode=arch=compute_35,code=\"sm_35,compute_35\" -gencode=arch=compute_50,code=\"sm_50,compute_50\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files\Microsoft Visual Studio 10.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v6.0\include" -G --keep-dir Debug -maxrregcount=0 --machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_UNICODE -DUNICODE -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o Debug\GHistoGramEqualizion.cu.obj "F:\cuda\GHistoGramEqualizion\GHistoGramEqualizion\GHistoGramEqualizion.cu"”已退出,返回代码为 2。
#6
下面是一个直方图有关的函数,我用来测试的,生成解决方案时出现上述的错误
__global__ void HistoGramEqualkernel(unsigned char* input_data,unsigned char* output_data,int width,int height)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int tid=y*width+x;
int histOrg[256]={0};
if(x<width && y<height)
{
int value=input_data[tid];
atomicAdd(&(histOrg[value]),1);
}
float histAdd[256] = {0};//累计直方图
int grayVal[256] = {0};//变换后的灰度值
int ntotal = width*height;
for (int i=0; i<256; i++)
{
if (i == 0)
{
histAdd[i] = histOrg[i];
}
else
{
histAdd[i] = (histAdd[i-1] + histOrg[i]);
}
}
//计算新灰度值
for (int i=0; i<256; i++)
{
grayVal[i] = (int)(histAdd[i]/ntotal*255+0.5);
}
if(x<width && y<height)
{
output_data[x*width+y] = grayVal[input_data[x*width+y]];
}
__host__ void HistoGramEqual(unsigned char* input_data,unsigned char* output_data,int width,int height)
{
unsigned char *Md, *Nd;
int size = width * height * sizeof(unsigned char);
//int*Or,*Eq;
//int dsize =256 * sizeof(int);
double timeStart,timeEnd,time;
cudaSetDevice(0);
cudaMalloc((void**)&Md, size);
cudaMalloc((void**)&Nd, size);
cudaMemcpy(Md, input_data, size, cudaMemcpyHostToDevice);
dim3 dimBlock( TILE_WIDTH, TILE_WIDTH);
dim3 dimGrid((width+TILE_WIDTH-1)/ TILE_WIDTH, (height+TILE_WIDTH-1)/ TILE_WIDTH); HistoGramEqual<<< dimGrid, dimBlock >>>(Md, Nd, width, height); //调用内核函数
cudaMemcpy(output_data,Nd,size, cudaMemcpyDeviceToHost);
//cudaMemcpy(histEqual,Eq,dsize, cudaMemcpyDeviceToHost);
//cudaMemcpy(histOrg,Or,dsize, cudaMemcpyDeviceToHost);
cudaFree(Md);
cudaFree(Nd);
__global__ void HistoGramEqualkernel(unsigned char* input_data,unsigned char* output_data,int width,int height)
{
int x = blockIdx.x * blockDim.x + threadIdx.x;
int y = blockIdx.y * blockDim.y + threadIdx.y;
int tid=y*width+x;
int histOrg[256]={0};
if(x<width && y<height)
{
int value=input_data[tid];
atomicAdd(&(histOrg[value]),1);
}
float histAdd[256] = {0};//累计直方图
int grayVal[256] = {0};//变换后的灰度值
int ntotal = width*height;
for (int i=0; i<256; i++)
{
if (i == 0)
{
histAdd[i] = histOrg[i];
}
else
{
histAdd[i] = (histAdd[i-1] + histOrg[i]);
}
}
//计算新灰度值
for (int i=0; i<256; i++)
{
grayVal[i] = (int)(histAdd[i]/ntotal*255+0.5);
}
if(x<width && y<height)
{
output_data[x*width+y] = grayVal[input_data[x*width+y]];
}
__host__ void HistoGramEqual(unsigned char* input_data,unsigned char* output_data,int width,int height)
{
unsigned char *Md, *Nd;
int size = width * height * sizeof(unsigned char);
//int*Or,*Eq;
//int dsize =256 * sizeof(int);
double timeStart,timeEnd,time;
cudaSetDevice(0);
cudaMalloc((void**)&Md, size);
cudaMalloc((void**)&Nd, size);
cudaMemcpy(Md, input_data, size, cudaMemcpyHostToDevice);
dim3 dimBlock( TILE_WIDTH, TILE_WIDTH);
dim3 dimGrid((width+TILE_WIDTH-1)/ TILE_WIDTH, (height+TILE_WIDTH-1)/ TILE_WIDTH); HistoGramEqual<<< dimGrid, dimBlock >>>(Md, Nd, width, height); //调用内核函数
cudaMemcpy(output_data,Nd,size, cudaMemcpyDeviceToHost);
//cudaMemcpy(histEqual,Eq,dsize, cudaMemcpyDeviceToHost);
//cudaMemcpy(histOrg,Or,dsize, cudaMemcpyDeviceToHost);
cudaFree(Md);
cudaFree(Nd);
#7
楼主,我和你遇到一样的问题了,前两天才遇到的,具体如下:
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 5.5.targets(592,9): error MSB3721:
命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\bin\nvcc.exe"
-gencode=arch=compute_10,code=\"sm_10,compute_10\"
--use-local-env --cl-version 2012 -ccbin "G:\Program Files\Mircosoft\Visual Studio2012\VC\bin"
-I"G:\Program Files\C ++ extension\ViennaCL-1.5.2\tests\src"
-I"G:\Program Files\C ++ extension\ViennaCL-1.5.2"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-G --keep-dir Debug -maxrregcount=0
--machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd "
-o Debug\wrap-cuda-buffer.cu.obj "G:\2014.8.16\cudadada4\cuda4\cuda4\wrap-cuda-buffer.cu"”已退出,返回代码为 2。
这个问题你解决了吗?就是5楼那个问题。
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\BuildCustomizations\CUDA 5.5.targets(592,9): error MSB3721:
命令“"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\bin\nvcc.exe"
-gencode=arch=compute_10,code=\"sm_10,compute_10\"
--use-local-env --cl-version 2012 -ccbin "G:\Program Files\Mircosoft\Visual Studio2012\VC\bin"
-I"G:\Program Files\C ++ extension\ViennaCL-1.5.2\tests\src"
-I"G:\Program Files\C ++ extension\ViennaCL-1.5.2"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.5\include"
-G --keep-dir Debug -maxrregcount=0
--machine 32 --compile -cudart static -g -DWIN32 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd "
-o Debug\wrap-cuda-buffer.cu.obj "G:\2014.8.16\cudadada4\cuda4\cuda4\wrap-cuda-buffer.cu"”已退出,返回代码为 2。
这个问题你解决了吗?就是5楼那个问题。
#8
解决了,其实是我的函数调用出错了。你按照右键解决方案属性-》配置属性-》CUDA C/C++-》Device-》Code Generation,加入compute_20,sm_20,并且把下面的“从父级或项目属性默认设置继承”的勾选去掉,还有你的.cu文件属性中的Device做同样的修改,首先搞清楚你的显卡计算能力,对“compute_20,sm_20”做相应的修改
#9
我也碰到了这样的问题,按照如上的设置进行了修改,结果还是错的!
显卡计算能力 3.0 应该支持的。
显卡计算能力 3.0 应该支持的。