How to Compile CUDA App is Visual Studio 2010 ?
如何编译CUDA App是Visual Studio 2010 ?
Here are my steps: 1. Create Empty C++ project without precompiled headers 2. Add main.cpp
以下是我的步骤:1。创建空的c++项目,而不需要预编译头文件。添加main.cpp
int main()
{
return 0;
}
-
Add kernels.cu
添加kernels.cu
I referred to sample project MAtrixMul and copied its settings step by step. it can be complied now
我引用了sample project MAtrixMul,并一步一步地复制了它的设置。现在可以照办了。
#include "cuda.h"
# include“cuda.h”
__global__ void VecAdd(float* A, float* B, float* C) { int i = threadId.x; C[i] = A[i] + B[i]; }
- Right-Click on project -> Build customizations -> Check cuda 3.2
- 右击项目->构建自定义->检查cuda 3.2。
- kernels.cu -> properties ->Compile with CUDA C/C++
- 内核。cu ->属性->用CUDA C/ c++编译。
- 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
错误37错误:CUDA工具包的这个版本不支持v100编译器。请验证平台工具集属性在项目属性的一般节点下设置为v90。C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \ BuildCustomizations \ CUDA 3.1。目标157个4 dfdfs
- Change Platform ToolSet to v90
- 将平台工具设置为v90。
- 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
错误38错误MSB3721:命令“”C:\程序文件\NVIDIA GPU计算工具包\CUDA\v3.1\ nvcc。-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --obj”“E:\项目!探测\ dfdfs \内核。用代码2退出。C:\Program Files (x86)\MSBuild\ Microsoft.Cpp \ v4.0 \ BuildCustomizations \ CUDA 3.1。目标272个4 dfdfs
Error 37 error : identifier "threadId" is undefined E:\Projects!Probing\dfdfs\kernels.cu 5 1 dfdfs
错误37错误:标识符“threadId”是未定义的E:\项目!探测\dfdfs\内核。铜5 1 dfdfs
Please healp me out.
请healp我出去。
Thanks, Ilya
谢谢,Ilya
4 个解决方案
#1
5
Yes i did, and it IS working.
是的,我做了,而且它正在工作。
-
Create C++ project
创建c++项目
-
Project(right click)->build customisation Check "Cuda 3.2 compiler"*
项目(右击)->构建定制检查“Cuda 3.2编译器”*。
-
Add
cudart.lib
to properties->linker->input->additional dependencies添加cudart。*输入- >属性- >链接器- >附加依赖项
-
Add
main.cu
-> properties Item type = CUDA C/C++*添加主。cu ->属性项类型= CUDA C/ c++ *。
-
Project -> properties ->configuration Properties -> general -> v90 toolset**
项目->属性->配置属性->通用-> v90工具集**。
*) will appear after you install Nvidia Parallel Nsight. Be careful, you need special drivers for that, more on NSight homepage)
*)安装Nvidia并行Nsight后将出现。要小心,你需要特别的驱动程序,更多的在NSight主页上
**) you need to instal visual c++ 2008 express.
**)您需要安装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.
无论如何,示例项目仍然应该在我的nvidia论坛发布。我抱怨的问题只是过时的司机。
#2
1
I found this post on the cuda forums at nVidia. One of the moderators says (Nov 09: We don't support VS2010 yet).
我在英伟达的cuda论坛上找到了这篇文章。一位版主说(11月09日:我们还不支持VS2010)。
This may not be the case any longer, but that your error message states that the CUDA toolkit version you're using doesn't support the V100 compiler, would suggest that you may need to upgrade your CUDA toolkit.
这可能不再是这种情况,但是您的错误消息指出,您使用的CUDA工具包版本不支持V100编译器,这意味着您可能需要升级CUDA工具包。
If you've got the latest version, check and see if the CUDA toolkit supports VS2010 yet.
如果您有最新版本,请查看CUDA工具包是否支持VS2010。
v90 is a way of referring to the compiler that comes with VS2008, so I'd assume that VS2010 is compiler v100.
v90是一种引用VS2008的编译器的方法,所以我假定VS2010是编译器v100。
Maybe you've got an MSDN subscription and can fall back to VS2008.
也许您已经订阅了MSDN,可以退回到VS2008。
This SO post would also seem to suggest that CUDA doesn't support VS2010 compiler (yet!)
这篇文章似乎也暗示CUDA不支持VS2010的编译器(然而!)
#3
0
Visual Studio 2010 is definitely supported -- be sure to use the recently released nSight 1.5 (not the beta). I haven't updated the question I asked, but @portland, you've followed all of the correct steps. You simply have a typo in your kernel.
Visual Studio 2010绝对支持——一定要使用最近发布的nSight 1.5(不是beta版)。我没有更新我问的问题,但是@portland,您已经遵循了所有正确的步骤。您只是在内核中有一个输入错误。
You've referenced threadId.x
instead of threadIdx.x
-- note the x.
你threadId引用。代替threadIdx x。x,注意x。
#4
0
i referred to sample project MAtrixMul and copied its settings step by step. it can be complied now, but doesnt process any calculations. The problem is described here at SO in details
我引用了sample project MAtrixMul,并一步一步地复制了它的设置。它现在可以执行,但不处理任何计算。这里详细描述了这个问题。
You can view my project with all it needs from my post at nvidia forums (2.7 kb)
您可以从我在nvidia论坛的帖子(2.7 kb)中查看我的项目。
Thanks, Ilya
谢谢,Ilya
#1
5
Yes i did, and it IS working.
是的,我做了,而且它正在工作。
-
Create C++ project
创建c++项目
-
Project(right click)->build customisation Check "Cuda 3.2 compiler"*
项目(右击)->构建定制检查“Cuda 3.2编译器”*。
-
Add
cudart.lib
to properties->linker->input->additional dependencies添加cudart。*输入- >属性- >链接器- >附加依赖项
-
Add
main.cu
-> properties Item type = CUDA C/C++*添加主。cu ->属性项类型= CUDA C/ c++ *。
-
Project -> properties ->configuration Properties -> general -> v90 toolset**
项目->属性->配置属性->通用-> v90工具集**。
*) will appear after you install Nvidia Parallel Nsight. Be careful, you need special drivers for that, more on NSight homepage)
*)安装Nvidia并行Nsight后将出现。要小心,你需要特别的驱动程序,更多的在NSight主页上
**) you need to instal visual c++ 2008 express.
**)您需要安装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.
无论如何,示例项目仍然应该在我的nvidia论坛发布。我抱怨的问题只是过时的司机。
#2
1
I found this post on the cuda forums at nVidia. One of the moderators says (Nov 09: We don't support VS2010 yet).
我在英伟达的cuda论坛上找到了这篇文章。一位版主说(11月09日:我们还不支持VS2010)。
This may not be the case any longer, but that your error message states that the CUDA toolkit version you're using doesn't support the V100 compiler, would suggest that you may need to upgrade your CUDA toolkit.
这可能不再是这种情况,但是您的错误消息指出,您使用的CUDA工具包版本不支持V100编译器,这意味着您可能需要升级CUDA工具包。
If you've got the latest version, check and see if the CUDA toolkit supports VS2010 yet.
如果您有最新版本,请查看CUDA工具包是否支持VS2010。
v90 is a way of referring to the compiler that comes with VS2008, so I'd assume that VS2010 is compiler v100.
v90是一种引用VS2008的编译器的方法,所以我假定VS2010是编译器v100。
Maybe you've got an MSDN subscription and can fall back to VS2008.
也许您已经订阅了MSDN,可以退回到VS2008。
This SO post would also seem to suggest that CUDA doesn't support VS2010 compiler (yet!)
这篇文章似乎也暗示CUDA不支持VS2010的编译器(然而!)
#3
0
Visual Studio 2010 is definitely supported -- be sure to use the recently released nSight 1.5 (not the beta). I haven't updated the question I asked, but @portland, you've followed all of the correct steps. You simply have a typo in your kernel.
Visual Studio 2010绝对支持——一定要使用最近发布的nSight 1.5(不是beta版)。我没有更新我问的问题,但是@portland,您已经遵循了所有正确的步骤。您只是在内核中有一个输入错误。
You've referenced threadId.x
instead of threadIdx.x
-- note the x.
你threadId引用。代替threadIdx x。x,注意x。
#4
0
i referred to sample project MAtrixMul and copied its settings step by step. it can be complied now, but doesnt process any calculations. The problem is described here at SO in details
我引用了sample project MAtrixMul,并一步一步地复制了它的设置。它现在可以执行,但不处理任何计算。这里详细描述了这个问题。
You can view my project with all it needs from my post at nvidia forums (2.7 kb)
您可以从我在nvidia论坛的帖子(2.7 kb)中查看我的项目。
Thanks, Ilya
谢谢,Ilya