错误:运行OpenCL代码时,clGetPlatformIDs -1001(Linux) [英] ERROR: clGetPlatformIDs -1001 when running OpenCL code (Linux)

查看:354
本文介绍了错误:运行OpenCL代码时,clGetPlatformIDs -1001(Linux)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在最终设法使我的代码可以使用OpenCL进行编译之后,我似乎无法使输出二进制文件运行!这是在运行Kubuntu 13.10 x64的Linux笔记本电脑上

After finally managing to get my code to compile with OpenCL, I cannot seem to get the output binary to run! This is on my linux laptop running Kubuntu 13.10 x64

我得到的错误是(从cl :: Error打印):

The error I get is (Printed from cl::Error):

ERROR: clGetPlatformIDs
-1001

我发现了这篇文章,但似乎没有一个明确的解决方案.

I found this post but there does not seem to be a clear solution.

我将自己添加到了视频组中,但这似乎不起作用.

I added myself to the video group but this does not seem to work.

关于ICD配置文件...我不确定该怎么做-cuda工具包中是否应该包含此文件?如果没有,我可以在哪里下载?

With regards to the ICD profile... I am not sure what I need to do - shouldn't this be included with the cuda toolkit? If not, where could I download one?

编辑:似乎我的系统中的/usr/share/nvidia-331/nvidia.icd下有一个ICD文件.它包含以下文本:

EDIT: It seems I have an ICD file in my system under /usr/share/nvidia-331/nvidia.icd. It contains the following text:

libnvidia-opencl.so.1

我系统中唯一与此文件相似的文件是:

The only file in my system that resembles this is:

/usr/lib/nvidia-331/libnvidia-opencl.so.331.20

我的ICD个人资料是否有误?有谁知道修复它的方法吗?

Is my ICD profile somehow wrong? Does anyone know a way to fix it?

推荐答案

(Mods:我不确定是否应将此帖子移至AskUbuntu,因为这是与Linux Bumblebee有关的问题,而不是与OpenCL本身有关的问题? )

好的,所以我经过大量努力来解决了这个问题.

Ok so I managed to solve the issue after loads of effort.

我需要做两件事:

创建从/usr/share/nvidia-331/nvidia.icd到/etc/OpenCL/vendors的符号链接

create a symbolic link from /usr/share/nvidia-331/nvidia.icd to /etc/OpenCL/vendors

sudo ln -s /usr/share/nvidia-331/nvidia.icd /etc/OpenCL/vendors

注意:在大多数情况下,您需要使用任何正在使用的驱动程序替换nvidia-331-最常见的是nvidia-current

我真的很好奇为什么安装cuda工具包时不会自动完成-但是我注意到,如果没有此步骤,OpenCL程序将无法工作!

I am really curious as to why this isn't done automatically when installing the cuda toolkit - but I have noticed that OpenCL programs will not work without this step!

之所以这么复杂,是因为我有一台nvidia optimus笔记本电脑,该笔记本电脑对Linux的驱动程序支持不佳.为了解决这个问题,我安装了 bumblebee ,以便可以在nvidia卡和Intel卡之间进行切换.

The reason why this was so complicated to get working was that I have an nvidia optimus laptop with poor driver support on linux. To fix this I have bumblebee installed to allow switching between my nvidia card and intel card.

但是,因为我使用的是大黄蜂-除非明确告知,否则nvidia图形卡(和nvidia驱动程序)将被卸载.为了使用OpenCL,我们需要打开nvidia显卡.

However, because I am using bumblebee - the nvidia graphics card (and nvidia driver) will be unloaded unless explicitly told so. In order to use OpenCL, we need to turn on the nvidia graphics card.

为此,我们需要使用命令optirunprimusrun明确告诉大黄蜂打开nvidia卡:

To do this we need to explicitly tell bumblebee to turn the nvidia card on by using the commands optirun or primusrun:

optirun myopenclprogram

但是请注意,因为所有重要的事情是nvidia卡已打开并且驱动程序已加载,所以您无需继续使用optirun myprogram即可使它正常工作(因为这总是如此)涉及等待图形卡初始化的初始延迟).

Note however, because all that matters is that the nvidia card is turned on and the drivers are loaded, you do not need to keep using optirun myprogram to get this to work (as this always involves the initial delay of waiting for the graphics card to be initialised).

例如,您可以运行optirun kate,这将打开nvidia图形卡.然后,您可以在单独终端中运行您的opencl程序,而无需使用optirun,并且该程序可以正常工作,因为图形卡已经打开(并且只要您离开就可以保持打开状态,例如kate正在运行) ).

You can run optirun kate for example and this would turn on the nvidia graphics card. You can then, in a separate terminal just run you opencl program without optirun and it will work just fine since the graphics card has already been turned on (and will remain on as long as you leave e.g. kate running).

您会发现这次启动程序没有延迟!这样可以节省很多等待时间,尤其是在开发有问题的opencl程序时.

You will notice that there is no delay in starting your program this time! This saves you alot of waiting - especially if you are developing the opencl program in question.

再一次,只要您保持nvidia显卡处于打开状态,您的opencl程序就可以运行.

Once again, as long as you keep the nvidia graphics card turned on, your opencl program will work.

我可能会联系大黄蜂开发者,以查看是否有更简单的方法使其正常工作并报告他们在这里所说的话.希望有某种方法可以打开和关闭nvidia卡,而无需保持程序(例如我的示例中的kate)运行.

I will probably contact the bumblebee devs to see if there is an easier way to get this to work and report what they say here. Hopefully there is some way to turn the nvidia card on and off without requiring to keep a program (like kate in my example) running.

我希望这对将来尝试在带有大黄蜂的linux笔记本电脑上使用OpenCL的人有所帮助(我自己找不到任何明确的解决方案)

I hope this helps anyone trying to use OpenCL on linux laptops with bumblebee in the future (I could not find any clear cut solutions myself)

EDIT2 :对于Bumlebee用户,可以按照以下步骤打开和关闭图形卡:

EDIT2: Turning you graphics card on and off can be done as follows for bumlebee users:

打开图形卡并加载nvidia模块

sudo tee /proc/acpi/bbswitch <<< ON
sudo modprobe nvidia

关闭图形卡(自动卸载​​nvidia模块)

sudo tee /proc/acpi/bbswitch <<< OFF

这篇关于错误:运行OpenCL代码时,clGetPlatformIDs -1001(Linux)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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