CUDA似乎没有编译 [英] CUDA does not seem to compile

查看:754
本文介绍了CUDA似乎没有编译的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前在Visual Studio 2012 Express上运行CUDA 5.0工具包。

I am currently running the CUDA 5.0 Toolkit on my Visual Studio 2012 Express.

我试图运行以下代码

我已经在Visual Studio中编译.cu的方法搜索了高和低。

I have searched high and low for methods of compiling .cu on Visual Studio but to no avail

代码我试图编译:

    //CUDA.cu
    #include <iostream>
    #include <cuda.h>
    #include <cuda_runtime.h>
    #include <device_launch_parameters.h>

    using namespace std;

    __global__ void Add(int* a, int* b)
    {
    a[0] += b[0];
    }

int main()
{
    int a = 5, b = 9;
    int *d_a, *d_b;

    cudaMalloc(&d_a, sizeof(int));
    cudaMalloc(&d_b, sizeof(int));

    cudaMemcpy(d_a, &a, sizeof(int), cudaMemcpyHostToDevice);
    cudaMemcpy(d_b, &b, sizeof(int), cudaMemcpyHostToDevice);

    Add<<< 1 , 1 >>>(d_a, d_b);

    cudaMemcpy(&a, d_a, sizeof(int) , cudaMemcpyDeviceToHost);

    cout << a << endl;

    return 0;
}

编译器在行中显示错误

Add<<< 1 , 1 >>>(d_a, d_b);

说明错误:期望表达式

任何编译此代码的尝试都会成功。但没有.exe被找到,因此我不能调试任何。

Any attempts to compile this code results in a success. but no .exe is to be found hence I cannot debug whatsoever.

Unable to start program 'C:\Users\...\CUDATest3.exe'
The system cannot find the file specified

任何帮助,非常感谢。感谢

Any help whatsoever is VERY MUCH appreciated. Thanks

CK

推荐答案

虽然我很想了解为什么在我的电脑CUDA决定VS是一个可悲的程序结婚,我已通过手铐两个方法通过复制从CUDA安装工具包提供的模板的快捷方式。 (CUDA示例。)

Although I would love to understand as to WHY in my computer CUDA decided that VS is a deplorable program to be married to, I have taken a shortcut by handcuffing both of said program by means of copying from the templates provided by the CUDA installation toolkit. (The CUDA samples.)

显然,这些示例已经设置好了并准备好了;所有你需要做的是从解决方案内部编辑代码。因为某种原因,如果我已经写了所有的代码从方形一。代码不会工作。

Apparently those samples have everything already set up and ready to go; all you need to do is edit the code from inside the solution itself. For some reason the code would not work if I had written all of the code from square one.

我还是不知道为什么我无法得到它从头开始运行,但我猜

I still have no idea as to why I am unable to get it to run from scratch but I guess

编辑示例模板会得到令人满意的结果。

editing the sample templates would give a much satisfactory result

如果没有时间。

这篇关于CUDA似乎没有编译的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆