使用CL/cl.h文件编译OpenCL程序 [英] Compiling an OpenCL program using a CL/cl.h file

查看:204
本文介绍了使用CL/cl.h文件编译OpenCL程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有样本"Hello,World!"来自网络的代码,我想在大学服务器上的GPU上运行它.当我输入"gcc main.c"时,它会回应:

I have sample "Hello, World!" code from the net and I want to run it on the GPU on my university's server. When I type "gcc main.c," it responds with:

CL/cl.h:没有这样的文件或目录

CL/cl.h: No such file or directory

我该怎么办?我怎么有这个头文件?

What should I do? How can I have this header file?

推荐答案

确保已安装适当的工具箱.

Make sure you have the appropriate toolkit installed.

这取决于要在其上运行代码的内容.如果您有NVidia卡,则需要下载并安装 CUDA工具包,其中还包含opencl必需的二进制文件和库.

This depends on what you intend running your code on. If you have an NVidia card then you need to download and install the CUDA-toolkit which also contains the necessary binaries and libraries for opencl.

您正在运行Linux吗?如果您相信已经安装了OpenCL,则可能是因为它位于与标准/usr/include不同的位置.输入以下内容,然后查看得到的结果:

Are you running Linux? If you believe you already have OpenCL installed it could be that it is found at a different location than the standard /usr/include. Type the following and see what results you get:

find / -iname cl.h 2>/dev/null

例如,在我的笔记本电脑上,标题位于/usr/local/cuda-5.5/include.如果情况是您的头文件位于其他位置,则只需在复杂过程中指定路径

On my laptop for example, the header is found at /usr/local/cuda-5.5/include. If its the case were your header file is at a different location you simply have to specify the path during complication

g++ -I/usr/local/cuda-5.5/include main.c -lOpenCL

或者,您可以创建到/usr/include的路径的符号链接:

Alternatively, you can create a symbolic link from the path to /usr/include:

ln -s /usr/local/cuda-5.5/include/CL /usr/include

这篇关于使用CL/cl.h文件编译OpenCL程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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