简体   繁体   English

错误:运行OpenCL代码时clGetPlatformIDs -1001(Linux)

[英]ERROR: clGetPlatformIDs -1001 when running OpenCL code (Linux)

After finally managing to get my code to compile with OpenCL, I cannot seem to get the output binary to run! 在最终设法让我的代码用OpenCL编译之后,我似乎无法让输出二进制文件运行! This is on my linux laptop running Kubuntu 13.10 x64 这是在我的Linux笔记本电脑上运行Kubuntu 13.10 x64

The error I get is (Printed from cl::Error): 我得到的错误是(从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. 我把自己加入了视频组,但这似乎不起作用。

With regards to the ICD profile... I am not sure what I need to do - shouldn't this be included with the cuda toolkit? 关于ICD配置文件......我不确定我需要做什么 - 这不应该包含在cuda工具包中吗? If not, where could I download one? 如果没有,我在哪里下载一个?

EDIT : It seems I have an ICD file in my system under /usr/share/nvidia-331/nvidia.icd. 编辑 :我的系统中似乎有一个ICD文件在/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

Is my ICD profile somehow wrong? 我的ICD资料有点不对吗? Does anyone know a way to fix it? 有谁知道修复它的方法?

(Mods: I am not sure if this post should be moved to AskUbuntu seeing as it was an issue related to Linux bumblebee rather than OpenCL itself?) (Mods:我不确定这篇文章是否应该转移到AskUbuntu,因为这是一个与Linux bumblebee相关的问题,而不是OpenCL本身?)

Ok so I managed to solve the issue after loads of effort. 好的,所以我设法在经过大量的努力后解决了这个问题。

There are two things that I needed to do: 我需要做两件事:

Getting ICD to work 让ICD工作

create a symbolic link from /usr/share/nvidia-331/nvidia.icd to /etc/OpenCL/vendors 创建从/usr/share/nvidia-331/nvidia.icd到/ etc / OpenCL / vendors的符号链接

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

NOTE: In most cases you would need to replace nvidia-331 with whatever driver you are using - most commonly nvidia-current 注意:在大多数情况下,你需要用你正在使用的驱动程序替换nvidia-331 - 最常见的是nvidia-current

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! 我真的很好奇为什么在安装cuda工具包时没有自动完成 - 但我注意到如果没有这一步,OpenCL程序将无法工作!

Nvidia Optimus with Bumblebee Nvidia Optimus和Bumblebee

The reason why this was so complicated to get working was that I have an nvidia optimus laptop with poor driver support on linux. 之所以如此复杂,是因为我有一台nvidia optimus笔记本电脑,它在Linux上的驱动程序支持很差。 To fix this I have bumblebee installed to allow switching between my nvidia card and intel card. 为了解决这个问题,我安装了大黄蜂 ,以便在我的nvidia卡和英特尔卡之间切换。

However, because I am using bumblebee - the nvidia graphics card (and nvidia driver) will be unloaded unless explicitly told so. 但是,因为我正在使用大黄蜂 - 除非明确告知,否则将卸载nvidia显卡(和nvidia驱动程序)。 In order to use OpenCL, we need to turn on the nvidia graphics card. 为了使用OpenCL,我们需要打开nvidia显卡。

To do this we need to explicitly tell bumblebee to turn the nvidia card on by using the commands optirun or primusrun : 要做到这一点,我们需要明确告诉大黄蜂使用命令optirunprimusrun打开nvidia卡:

optirun myopenclprogram

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). 但请注意,因为所有重要的是nvidia卡已打开并且驱动程序已加载 ,您无需继续使用optirun myprogram来使其工作(因为这总是涉及等待显卡的初始延迟初始化)。

You can run optirun kate for example and this would turn on the nvidia graphics card. 例如,您可以运行optirun kate ,这将打开nvidia显卡。 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 eg kate running). 然后,您可以在一个单独的终端中运行opencl程序而不使用optirun,它可以正常工作,因为显卡已经打开(并且只要您离开,例如kate运行就会保持打开状态)。

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. 这样可以节省大量的时间 - 特别是如果您正在开发有问题的opencl程序。

Once again, as long as you keep the nvidia graphics card turned on, your opencl program will work. 再一次,只要你打开nvidia显卡,你的opencl程序就可以运行了。

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. 希望有一些方法可以打开和关闭nvidia卡,而无需保持程序(如我的例子中的kate)运行。

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) 我希望这可以帮助任何人尝试在未来使用大黄蜂的Linux笔记本电脑上使用OpenCL(我自己找不到任何明确的解决方案)

EDIT2 : Turning you graphics card on and off can be done as follows for bumlebee users: 编辑2 :对于bumlebee用户,可以按如下方式打开和关闭显卡:

Turn graphics card on and load nvidia module 打开显卡并加载nvidia模块

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

Turn graphics card off (nvidia module is automatically unloaded) 关闭显卡(nvidia模块自动卸载)

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

To share some add info. 分享一些添加信息。 I have installed intel opencl version on Ubuntu 13.10 saucy. 我在Ubuntu 13.10上安装了intel opencl版本。 Problem has been the same: -1001 error. 问题是一样的:-1001错误。 I solved it by link analogicly to previous post: 我通过类似于前一篇文章的链接解决了它:

sudo ln -sf /opt/intel/opencl-1.2-3.2.1.16712/etc/intel64.icd /etc/OpenCL/vendors/nvidia.icd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM