如何创建NVIDIA OpenCL项目 [英] How to create NVIDIA OpenCL project

查看:73
本文介绍了如何创建NVIDIA OpenCL项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Visual Studio 2017中的NVIDIA OpenCL中编写应用程序,但不知道如何为此目的创建项目.

I want to write application in NVIDIA OpenCL in Visual Studio 2017 but don't know how to create project for this purpose.

我有NVIDIA(GeForce 940M)和Intel(HD Graphics 5500)的GPU,并且已经设法为OpenCL打开和运行Intel示例程序,但是它们有将近一千行代码,所以我决定尝试NVIDIA OpenCL,但没有不知道如何.在一些论坛上,他们说我应该下载CUDA工具包并安装OpenCL,而另一些人则说我应该下载支持OpenCL的驱动程序,但我不知道哪种驱动程序合适.我已经从 https://www.nvidia.pl/安装了CUDA和驱动程序.下载/index.aspx?lang=pl ,但是我仍然无法在Visual Studio的OpenCL中创建NVIDIA项目.

I have GPU from NVIDIA (GeForce 940M) and Intel (HD Graphics 5500) and already managed to open and run Intel example programs for OpenCL but they have almost one thousand lines of code, so I decided to try NVIDIA OpenCL but don't know how. On some forums they say that I should download CUDA toolkit and it install OpenCL, others say that I should download driver that supports OpenCL but I don't know which driver will be proper. I have already installed CUDA and driver from https://www.nvidia.pl/Download/index.aspx?lang=pl but still I have not possibility to create NVIDIA project in OpenCL in Visual Studio.

推荐答案

Nvidia图形驱动程序中已包含OpenCL运行时.您只需要OpenCL C ++头文件, OpenCL.lib 文件,在Linux上也需要 libOpenCL.so 文件.这些随CUDA工具包一起提供,但是无需安装它即可仅获取9个必需的文件.

The OpenCL Runtime is already included in the Nvidia graphics drivers. You only need the OpenCL C++ header files, the OpenCL.lib file and on Linux also the libOpenCL.so file. These come with the CUDA toolkit, but there is no need to install it only to get the 9 necessary files.

这是CUDA工具包10.1中的OpenCL C ++头文件和lib文件: https://drive.google.com/file/d/1-yHaWWG7XfOarWPD817_ugeLCVLBtSCr/view?usp = sharing

Here are the OpenCL C++ header files and the lib file from CUDA toolkit 10.1: https://drive.google.com/file/d/1-yHaWWG7XfOarWPD817_ugeLCVLBtSCr/view?usp=sharing

解压缩 OpenCL 文件夹并将其复制到您的项目源文件夹中.然后在您的Visual Studio项目中,转到项目属性->".C/C ++->一般->其他包括目录"并添加 C:\ path \到\您的\ project \ source \ OpenCL \ include .然后,在项目属性->"中,连结器->所有选项->附加依赖项"添加 OpenCL.lib; 并在项目属性->"中添加连结器->所有选项->其他图书馆目录"添加 C:\ path \至\ your \ project \ source \ OpenCL \ lib .

Unzip the OpenCL folder and copy it into your project source folder. Then in your Visual Studio Project, go to "Project Properties -> C/C++ -> General -> Additional Include Directories" and add C:\path\to\your\project\source\OpenCL\include. Then, in "Project Properties -> Linker -> All Options -> Additional Dependencies" add OpenCL.lib; and in "Project Properties -> Linker -> All Options -> Additional Library Directories" add C:\path\to\your\project\source\OpenCL\lib.

最后,在您的 .cpp 源文件中,包含带有 #include< CL/cl.hpp> 的标头.

Finally, in your .cpp source file, include the headers with #include <CL/cl.hpp>.

这也适用于AMD/Intel GPU和CPU.

This also works for AMD/Intel GPUs and CPUs.

这篇关于如何创建NVIDIA OpenCL项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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