24

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: No such file or directory

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

2

2 Answers 2

29

Are you using Ubuntu or Debian distro? Then you could use this package to solve the problem with missing header file:

apt-get install opencl-headers

You must install opencl library to solve linking issues using that Debian and Ubuntu package:

apt-get install ocl-icd-libopencl1

You can also use these nonfree libraries: nvidia-libopencl1 (Debian) or nvidia-libopencl1-xx (Ubuntu).

3
  • This is a quick fix without messing with CFLAGS or whatever (for example when running python setup.py build/install on something which requires pyopencl. But you will still need to set LDFLAGS if the libOpenCL.so is not on the default path. Commented Jan 2, 2018 at 8:02
  • 1
    Of course. I'm using opencl-headers and ocl-icd-libopencl1, the library path is /usr/lib/x86_64-linux-gnu/libOpenCL.so.1.0.0, so changing LDFLAGS it is not necessary with this package. I'll update my answer, thanks for the comment. Commented Jan 2, 2018 at 8:33
  • 1
    This solved the issue to allow for LightGBM installation on GPU using make Commented Jan 15, 2020 at 22:13
23

Make sure you have the appropriate toolkit installed.

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.

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

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

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

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.