如何编译CUDA应用程序是Visual Studio 2010? [英] How to Compile CUDA App is Visual Studio 2010?

查看:481
本文介绍了如何编译CUDA应用程序是Visual Studio 2010?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何编译CUDA应用程序是Visual Studio 2010?



这是我的步骤:
1.创建没有预编译头的空C ++项目
2.添加main.cpp

  int main()
{
return 0;
}




  1. Add kernels.cu

    我引用示例项目MAtrixMul并逐步复制其设置。



  2.   __ global__ void VecAdd(float * A,float * B,float * C)
    {
    int i = threadId。 X;
    C [i] = A [i] + B [i];
    }





    1. 右 - 点击项目 - >生成自定义 - >检查cuda 3.2

    2. kernels.cu - >属性 - >使用CUDA C / C ++编译

    3. TRY编译:我收到错误:




    错误37错误:此版本的
    CUDA工具包不支持v100
    编译器。
    请验证
    Platform Toolset属性在
    项目属性的常规节点下设置为
    v90。 C:\Program Files
    (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA
    3.1.targets 157 4 dfdfs





    1. 将平台工具集更改为v90

    2. TRY编译:我收到错误:




    错误38错误MSB3721:命令
    C:\Program Files \NVIDIA GPU
    Computing
    Toolkit\CUDA\v3.1\bin\\\
    vcc.exe
    -gencode = arch = compute_10,code = \sm_10,compute_10\
    --use-local-env --cl-version 2008 -ccbinC:\Program Files(x86)\ Microsoft Visual Studio
    9.0 \VC\bin-IC:\程序文件\NVIDIA GPU计算
    Toolkit \CUDA \v3.1 \include-G0
    --keep-dirDebug \-maxrregcount = 32 --machine 32 - 编译-D_NEXUS_DEBUG -g -Xcompiler/ EHsc / nologo / Od / Zi / MDd-oDebug \kernels.obj
    E:\Projects!Probing \dfdfs\kernels.cu
    使用代码2退出。 C:\Program Files
    (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA
    3.1.targets 272 4 dfdfs



    错误37错误:标识符threadId

    未定义E:\Projects!Probing\dfdfs\kernels.cu 5 1 dfdfs


    请帮我。



    感谢,Ilya

    解决方案

    是的,它是工作。


    1. 创建C ++项目


    2. ) - >构建自定义检查Cuda 3.2编译器*


    3. 添加 cudart.lib > linker-> input-> additional dependencies


    4. 添加 main.cu - > CUDA C / C ++ *


    5. 项目 - >属性 - >配置属性 - > general - > v90工具集**

      $ b

    *)会在安装Nvidia Parallel Nsight后出现。要小心,你需要特殊的驱动程序,更多在NSight主页)



    **)你需要instal visual c ++ 2008 express。



    无论如何,示例项目仍然应该在我的nvidia论坛帖子。我抱怨的问题是,只是过时的驱动程序。


    How to Compile CUDA App is Visual Studio 2010 ?

    Here are my steps: 1. Create Empty C++ project without precompiled headers 2. Add main.cpp

    int main()
    {
     return 0;
    }
    

    1. Add kernels.cu

      I referred to sample project MAtrixMul and copied its settings step by step. it can be complied now

    #include "cuda.h"

    __global__ void VecAdd(float* A, float* B, float* C)
    {
     int i = threadId.x;
     C[i] = A[i] + B[i];
    }
    

    1. Right-Click on project -> Build customizations -> Check cuda 3.2
    2. kernels.cu -> properties ->Compile with CUDA C/C++
    3. TRY Compiling: I get error:

    Error 37 error : This version of the CUDA Toolkit does not support the v100 compiler. Please verify that the Platform Toolset property is set to v90 under the General node of the project properties. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 3.1.targets 157 4 dfdfs

    1. Change Platform ToolSet to v90
    2. TRY Compiling: I get errors:

    Error 38 error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.1\bin\nvcc.exe" -gencode=arch=compute_10,code=\"sm_10,compute_10\" --use-local-env --cl-version 2008 -ccbin "C:\Program Files (x86)\Microsoft Visual Studio 9.0\VC\bin" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v3.1\include" -G0 --keep-dir "Debug\" -maxrregcount=32 --machine 32 --compile -D_NEXUS_DEBUG -g -Xcompiler "/EHsc /nologo /Od /Zi /MDd " -o "Debug\kernels.obj" "E:\Projects!Probing\dfdfs\kernels.cu"" exited with code 2. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\CUDA 3.1.targets 272 4 dfdfs

    Error 37 error : identifier "threadId" is undefined E:\Projects!Probing\dfdfs\kernels.cu 5 1 dfdfs

    Please healp me out.

    Thanks, Ilya

    解决方案

    Yes i did, and it IS working.

    1. Create C++ project

    2. Project(right click)->build customisation Check "Cuda 3.2 compiler"*

    3. Add cudart.lib to properties->linker->input->additional dependencies

    4. Add main.cu -> properties Item type = CUDA C/C++*

    5. Project -> properties ->configuration Properties -> general -> v90 toolset**

    *) will appear after you install Nvidia Parallel Nsight. Be careful, you need special drivers for that, more on NSight homepage)

    **) you need to instal visual c++ 2008 express.

    Anyway, example project still should be available at my nvidia forum post. The problem i'm complaining there about is just out-of-date drivers.

    这篇关于如何编译CUDA应用程序是Visual Studio 2010?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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