如何向现有项目添加CUDA 7.0加速? [英] How to add CUDA 7.0 acceleration to existing project?

查看:373
本文介绍了如何向现有项目添加CUDA 7.0加速?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据 http://docs.nvidia.com/ ,您必须将cuda包含在您的项目是:

According to http://docs.nvidia.com/ all you have to do to include cuda in your project is to:


打开Visual Studio项目,右键单击项目名称,然后选择构建自定义...,

Open the Visual Studio project, right click on the project name, and select Build Customizations..., then select the CUDA Toolkit version you would like to target.

我正在关注CUDACast的您的第一个CUDA C程序视频,VisualStudio仍然标记红色CUDA的所有说明,所以我认为这是很好,当我在我的项目写。但是当我构建它,我已经看到每行使用他们的说明的错误。
我需要自己链接一些其他库吗?

I am following "Your First CUDA C Program" from CUDACast and I see in the video that VisualStudio still marks red all the instructions from CUDA, so I thought it was fine when I was writing in my project. But when I've built it I've seen errors in every line using their instructions. Do I need to link some other libraries myself?

当我打开项目的属性时,我注意到了两个新的部分:
CUDA C / C ++和CUDA链接器

I've noticed two new sections when I open project's properties: "CUDA C/C++" and "CUDA Linker"

推荐答案

是的,如果你正在构建一个cuda运行时项目,链接在 cudart.lib cuda运行时库中。这包括指定该库的路径以及在其他依赖关系中标识库本身。如果不这样做,但使用CUDA API函数如 cudaMalloc ,您将在链接阶段收到错误。 (如果您在链接阶段之前遇到错误,还有其他问题。)

Yes, if you are building a cuda runtime project, at a minimum you will need to link in cudart.lib the cuda runtime library. This involves specifying the path to that library as well as identify the library itself in "Additional Dependencies". If you don't do this, but use CUDA API functions such as cudaMalloc, you will get errors at link phase. (If you are getting errors prior to link phase, there is some other issue.)

我建议您查看 cuda示例代码(如vectorAdd),以了解cuda Visual Studio项目的结构。

I suggest you review a cuda sample code such as vectorAdd, to learn how a cuda Visual Studio project is structured.

您也可能想要确保您已遵循 windows入门指南,其中包括构建和运行示例代码。

You will also probably want to be sure you have followed all steps in the windows getting started guide properly, which includes building and running sample codes.

在视频序列中没有显示(需要)库步骤的原因是,在Visual Studio中启动项目的方法(启动任意项目,然后选择CUDA构建自定义)与视频中显示的不同(启动项目通过选择CUDA运行时自定义工具链)。

The reason that the library step is not shown (needed) in the video sequence is that your method of starting the project in Visual Studio (start an arbitrary project, then select CUDA build customizations) is different than that shown in the video (start a project by selecting the CUDA Runtime custom toolchain).

这篇关于如何向现有项目添加CUDA 7.0加速?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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