在Netbeans中编译简单的新CUDA项目 [英] compile simple new CUDA project in Netbeans
问题描述
我在Netbeans中创建了新的C ++应用程序,并希望编译简单的CUDA,如:
I have created new C++Application in Netbeans and want to compile simple CUDA like:
#include <cstdlib>
// includes, system
#include <stdio.h>
// includes CUDA Runtime
#include <cuda_runtime.h>
// includes help
#include <helper_cuda.h>
#include <helper_functions.h> // helper utility functions
/*
*
*/
__global__ void add(int* a , int* b, int* c){
*c=*a+*b;
}
int main(int argc, char** argv) {
int a,b,c; //host copies of a,b,c
int* d_a,*d_b,*d_c; //device copies of a,b,c
int size=sizeof(int);
//allocate space for device copies of a,b,c
cudaMalloc((void**)&d_a,size);
cudaMalloc((void**)&d_b,size);
cudaMalloc((void**)&d_c,size);
//setup input
a=2;
b=7;
//copy inputs to device
cudaMemcpy(d_a,&a,size,cudaMemcpyHostToDevice);
cudaMemcpy(d_b,&b,size,cudaMemcpyHostToDevice);
//launch add() kernel on GPU device
add<<<1,1>>>(d_a,d_b,d_c);
return 0;
}
当我通过IDE构建它是它正在做什么:
when I do build by IDE it is what it is doing:
/ usr / bin / make-f nbproject / Makefile-Debug.mk QMAKE = SUBPROJECTS =
.build-conf make [ 1]:输入目录
/ root / NetBeansProjects / my_CUDA_1'/ usr / bin / make-f
/ root / NetBeansProjects / my_CUDA_1'mkdir
nbproject / Makefile-Debug.mk dist / Debug / GNU-Linux -x86 / libmy_cuda_1.a
make [2]:输入目录
-p build / Debug / GNU-Linux-x86 rm -f build / Debug / GNU-Linux-x86 / cudaMain.od /usr/local/cuda-5.0/bin/nvcc
-c -g -I / usr / local / cuda-5.0 / include -I /usr/local/cuda-5.0/samples/common/inc-MMD -MP -MF build / Debug / GNU-Linux-x86 / cudaMain.od -o
build / Debug / GNU-Linux-x86 / cudaMain .o cudaMain.cu nvcc fatal:
未知选项'MMD'
"/usr/bin/make" -f nbproject/Makefile-Debug.mk QMAKE= SUBPROJECTS= .build-conf make[1]: Entering directory
/root/NetBeansProjects/my_CUDA_1' "/usr/bin/make" -f nbproject/Makefile-Debug.mk dist/Debug/GNU-Linux-x86/libmy_cuda_1.a make[2]: Entering directory
/root/NetBeansProjects/my_CUDA_1' mkdir -p build/Debug/GNU-Linux-x86 rm -f build/Debug/GNU-Linux-x86/cudaMain.o.d /usr/local/cuda-5.0/bin/nvcc
-c -g -I/usr/local/cuda-5.0/include -I/usr/local/cuda-5.0/samples/common/inc -MMD -MP -MF build/Debug/GNU-Linux-x86/cudaMain.o.d -o build/Debug/GNU-Linux-x86/cudaMain.o cudaMain.cu nvcc fatal : Unknown option 'MMD'
所以我可以通过手动编译来避免这个错误没有这些选项的命令行:
so I can avoid this error by compiling manually from commandline without these options:
me @ comp:/ root / NetBeansProjects / my_CUDA_1#
/usr/local/cuda-5.0 / bin / nvcc -m64 -c -g -I / usr / local / cuda-5.0 / include
-I / us r / local / cuda-5.0 / samples / common / inc -o build / Debug / GNU -Linux-x86 / cudaMain.o cudaMain.cu cudaMain.cu(28):
警告:变量c已声明但从未引用
me@comp:/root/NetBeansProjects/my_CUDA_1# /usr/local/cuda-5.0/bin/nvcc -m64 -c -g -I/usr/local/cuda-5.0/include -I/us r/local/cuda-5.0/samples/common/inc -o build/Debug/GNU-Linux-x86/cudaMain.o cudaMain.cu cudaMain.cu(28): warning: variable "c" was declared but never referenced
cudaMain。 cu(28):warning:声明变量c,但从不
引用
cudaMain.cu(28): warning: variable "c" was declared but never referenced
me @ comp:/ root / NetBeansProjects / my_CUDA_1#ls
me@comp:/root/NetBeansProjects/my_CUDA_1# ls
如何在Netbeans中配置以在IDE中获取这样的设置?
how, what to configure in Netbeans to get such settings in IDE?
推荐答案
项目 - >属性 - >在选项卡上创建
专家:启用依赖关系检查 - >取消选中此
Project->Properties->Build on tab Expert: Enable make Dependency Checking -> uncheck this
这篇关于在Netbeans中编译简单的新CUDA项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!