cuda编译错误
Compile error in cuda
我在 cuda 中有一个编译错误,我想知道为什么会出现这个错误?
我想知道我的 cuda 运行 在 2DArray 中是否用于将来的图像处理
我的密码是
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include<cuda.h>
#include<cuda_runtime.h>
#include "device_launch_parameters.h"
#include<iostream>
using namespace std ;
#define BLOCK_WIDTH 16
__global__ void kernel(int *d_A, size_t pitch, int rows, int cols){
//compute the row
int r = blockIdx.y*blockDim.y+threadIdx.y;
//compute the column
int c = blockIdx.x*blockDim.x+threadIdx.x;
if((r < rows) && (c < cols)){
// // update the pointer to point to the beginning of the row
//int *Row = (int*)((char*)d_A + r*pitch);
int *Row = (int*)((char*)d_A);
int elem = Row[c];
printf("%d ", elem);
}
}
void test(int **A, int rows, int cols){
int *d_A;
size_t pitch;
cudaMallocPitch((void**)&d_A, &pitch, sizeof(int)*cols, rows);
cudaMemcpy2D(d_A, pitch, A, sizeof(int)*cols, sizeof(int)*cols, rows, cudaMemcpyHostToDevice);
//Define grid and block size
int Yblocks = rows / BLOCK_WIDTH;
if(rows % BLOCK_WIDTH) Yblocks++;
int Xblocks = cols / BLOCK_WIDTH;
if(cols % BLOCK_WIDTH) Xblocks++;
// cout << Yblocks << "," << Xblocks << endl;
dim3 dimGrid(Yblocks, Xblocks, 1);
dim3 dimBlock(BLOCK_WIDTH, BLOCK_WIDTH, 1);
//Run kernel
kernel<<<dimGrid, dimBlock>>>(d_A, pitch, rows, cols);
cudaMemcpy2D(A, sizeof(int)*cols, d_A, pitch, sizeof(int)*cols, rows, cudaMemcpyDeviceToHost);
cudaFree(&d_A);
}
int main(){
int rows = 2;
int cols = 2;
int **A;
A = new int*[rows];
for(int i = 0; i < rows; ++i){
A[i] = new int[cols];
for(int j = 0; j < cols; ++j)
A[i][j] = i+2;
}
test(A, rows, cols);
for(int i = 0; i < rows; ++i){
for(int j = 0; j < cols; ++j)
cout << A[i][j] << " ";
cout << "\n";
}
for(int i = 0; i < rows; ++i) delete[] A[i];
delete[] A;
return 0;
}
我的笔记本电脑里有:
NVIDIA CUDA 示例 7.5,
NVIDIA CUDA 工具包 7.5,
NVIDIA CUDA 工具包 v5(64),
NVIDIA CUDA 工具 SDK v4.0 ,
NVIDIA GPU计算SDK 4,
NVIDIA 图形驱动程序 306.94,
NVIDIA Nsigth visual studio 版本 5.1.0.10602,
visual studio 2010 年,
NVIDIA GeForce 9300M GS ,
驱动模型:WDDM 1.1,
DDI版本:10,
windows 7
我有这个错误
1>------ Build started: Project: 2Dexample, Configuration: Debug Win32 --
1>Build started 8/10/2016 6:29:45 AM.
1>InitializeBuildStatus:
1> Touching "DebugDexample.unsuccessfulbuild".
1>AddCudaCompileDeps:
1>Skipping target "AddCudaCompileDeps" because all output files are up- to-date with respect to the input files.
1>AddCudaCompilePropsDeps:
1>Skipping target "AddCudaCompilePropsDeps" because all output files are up-to-date with respect to the input files.
1>CudaBuild:
1> Compiling CUDA source file kernel.cu...
1>
1> C:\Users\Amany\Documents\Visual Studio 2010\ProjectsDexampleDexample>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" - I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G -maxrregcount=0 --machine 32 --compile -1 -g -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o "Debug\kernel.cu.obj" "C:\Users\Amany\Documents\Visual Studio 2010\ProjectsDexampleDexample\kernel.cu"
1>nvcc : fatal error : Unknown option '1'
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.targets(592,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G -maxrregcount=0 --machine 32 --compile -1 -g -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o "Debug\kernel.cu.obj" "C:\Users\Amany\Documents\Visual Studio 2010\ProjectsDexampleDexample\kernel.cu"" exited with code -1.
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.29
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
我尝试了很多东西但没有用:
How to Compile CUDA App is Visual Studio 2010?
但没用
我觉得可能跟这个奇怪的数值有关
nvcc.exe ....... --compile -1 .......
nvcc : fatal error : Unknown option '1'
我在 cuda 中有一个编译错误,我想知道为什么会出现这个错误? 我想知道我的 cuda 运行 在 2DArray 中是否用于将来的图像处理
我的密码是
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include<cuda.h>
#include<cuda_runtime.h>
#include "device_launch_parameters.h"
#include<iostream>
using namespace std ;
#define BLOCK_WIDTH 16
__global__ void kernel(int *d_A, size_t pitch, int rows, int cols){
//compute the row
int r = blockIdx.y*blockDim.y+threadIdx.y;
//compute the column
int c = blockIdx.x*blockDim.x+threadIdx.x;
if((r < rows) && (c < cols)){
// // update the pointer to point to the beginning of the row
//int *Row = (int*)((char*)d_A + r*pitch);
int *Row = (int*)((char*)d_A);
int elem = Row[c];
printf("%d ", elem);
}
}
void test(int **A, int rows, int cols){
int *d_A;
size_t pitch;
cudaMallocPitch((void**)&d_A, &pitch, sizeof(int)*cols, rows);
cudaMemcpy2D(d_A, pitch, A, sizeof(int)*cols, sizeof(int)*cols, rows, cudaMemcpyHostToDevice);
//Define grid and block size
int Yblocks = rows / BLOCK_WIDTH;
if(rows % BLOCK_WIDTH) Yblocks++;
int Xblocks = cols / BLOCK_WIDTH;
if(cols % BLOCK_WIDTH) Xblocks++;
// cout << Yblocks << "," << Xblocks << endl;
dim3 dimGrid(Yblocks, Xblocks, 1);
dim3 dimBlock(BLOCK_WIDTH, BLOCK_WIDTH, 1);
//Run kernel
kernel<<<dimGrid, dimBlock>>>(d_A, pitch, rows, cols);
cudaMemcpy2D(A, sizeof(int)*cols, d_A, pitch, sizeof(int)*cols, rows, cudaMemcpyDeviceToHost);
cudaFree(&d_A);
}
int main(){
int rows = 2;
int cols = 2;
int **A;
A = new int*[rows];
for(int i = 0; i < rows; ++i){
A[i] = new int[cols];
for(int j = 0; j < cols; ++j)
A[i][j] = i+2;
}
test(A, rows, cols);
for(int i = 0; i < rows; ++i){
for(int j = 0; j < cols; ++j)
cout << A[i][j] << " ";
cout << "\n";
}
for(int i = 0; i < rows; ++i) delete[] A[i];
delete[] A;
return 0;
}
我的笔记本电脑里有: NVIDIA CUDA 示例 7.5, NVIDIA CUDA 工具包 7.5, NVIDIA CUDA 工具包 v5(64), NVIDIA CUDA 工具 SDK v4.0 , NVIDIA GPU计算SDK 4, NVIDIA 图形驱动程序 306.94, NVIDIA Nsigth visual studio 版本 5.1.0.10602, visual studio 2010 年, NVIDIA GeForce 9300M GS , 驱动模型:WDDM 1.1, DDI版本:10, windows 7
我有这个错误
1>------ Build started: Project: 2Dexample, Configuration: Debug Win32 --
1>Build started 8/10/2016 6:29:45 AM.
1>InitializeBuildStatus:
1> Touching "DebugDexample.unsuccessfulbuild".
1>AddCudaCompileDeps:
1>Skipping target "AddCudaCompileDeps" because all output files are up- to-date with respect to the input files.
1>AddCudaCompilePropsDeps:
1>Skipping target "AddCudaCompilePropsDeps" because all output files are up-to-date with respect to the input files.
1>CudaBuild:
1> Compiling CUDA source file kernel.cu...
1>
1> C:\Users\Amany\Documents\Visual Studio 2010\ProjectsDexampleDexample>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" - I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G -maxrregcount=0 --machine 32 --compile -1 -g -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o "Debug\kernel.cu.obj" "C:\Users\Amany\Documents\Visual Studio 2010\ProjectsDexampleDexample\kernel.cu"
1>nvcc : fatal error : Unknown option '1'
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 5.0.targets(592,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2010 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v5.0\include" -G -maxrregcount=0 --machine 32 --compile -1 -g -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /Zi /RTC1 /MDd " -o "Debug\kernel.cu.obj" "C:\Users\Amany\Documents\Visual Studio 2010\ProjectsDexampleDexample\kernel.cu"" exited with code -1.
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:00.29
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
我尝试了很多东西但没有用:
How to Compile CUDA App is Visual Studio 2010?
但没用
我觉得可能跟这个奇怪的数值有关
nvcc.exe ....... --compile -1 .......
nvcc : fatal error : Unknown option '1'