Search code examples
pythonopenclubuntu-16.04nvidiapyopencl

clGetPlatformIDs failed: <unknown error -1001>


when i run following code

import pyopencl as cl
cl.get_platforms()

I get error

clGetPlatformIDs failed: <unknown error -1001>

I am running python 3.6 pyopencl 2018.1.1 on aws ec2 Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-116-generic x86_64).

I have tried following things , but none of them work:

  1. echo libnvidia-opencl.so.1 >> /etc/OpenCL/vendors/nvidia.icd from root directory by doing sudo -i after ssh into ubuntu ec2 instance. (initially this command wont work so i removed nvidia.icd file {rm nvidia.icd}and then this command worked. but it did not solve the error 1001 mentioned above.
  2. echo libnvidia-opencl.so.384.111 >> /etc/OpenCL/vendors/nvidia.icd
  3. sudo ln -s /opt/intel/opencl-1.2-3.2.1.16712/etc/intel64.icd /etc/OpenCL/vendors/nvidia.icd
  4. sudo usermod -aG video your-user-name
  5. sudo ln -s /usr/share/nvidia-331/nvidia.icd /etc/OpenCL/vendors
  6. sudo ln -s /usr/share/nvidia-384/nvidia.icd /etc/OpenCL/vendors
  7. optirun myopenclprogram

Solution

  • The easiest way to use OpenCL on EC2 is by using the Deep Learning Base Image, which comes with all necessary drivers and is already configured to work with P2 and P3 instance types. The image can be found at https://aws.amazon.com/marketplace/pp/B077GCH38C.