Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCL not getting enabled #4450

Closed
DroidFreak32 opened this issue Nov 7, 2021 · 7 comments
Closed

OpenCL not getting enabled #4450

DroidFreak32 opened this issue Nov 7, 2021 · 7 comments

Comments

@DroidFreak32
Copy link

DroidFreak32 commented Nov 7, 2021

ImageMagick version

7.1.0-13

Operating system

Linux

Operating system, version and so on

EndeavourOS on Linux 5.14.15 kernel

Description

Trying to compile imagemagick with opencl
After the config step I see opencl enabled:

Options used to compile and link:
  PREFIX          = /usr/local
  EXEC-PREFIX     = /usr/local
  VERSION         = 7.1.0-13
  CC              = gcc
  CFLAGS          = -I/usr/include/libxml2    -I/usr/include/libraw  -I/usr/include/libpng16   -I/usr/include/pango-1.0 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/harfbuzz -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/libmount -I/usr/include/blkid -I/usr/include/fribidi -I/usr/include/cairo -I/usr/include/lzo -I/usr/include/pixman-1 -pthread  -I/usr/include/OpenEXR -pthread -I/usr/include/Imath   -I/usr/include/lqr-1 -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -I/usr/include/openjpeg-2.4    -I/usr/include/graphviz  -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include -I/usr/include/fribidi  -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -I/usr/include/freetype2 -I/usr/include/libpng16 -I/usr/include/harfbuzz -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include  -pthread     -fopenmp -Wall -g -O2 -mtune=amdfam10 -fexceptions -pthread -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16
  CPPFLAGS        =  -DMAGICKCORE_HDRI_ENABLE=1 -DMAGICKCORE_QUANTUM_DEPTH=16 
  PCFLAGS         = 
  DEFS            = -DHAVE_CONFIG_H
  LDFLAGS         =  
  LIBS            =  -ljbig -llcms2  -ltiff -lfreetype  -lraqm  -ljpeg   -llqr-1 -lglib-2.0  -lpng16 -lz   -ldjvulibre   -lflif -lfpx -lfontconfig -lfreetype  -lheif  -lwebpmux -lwebpdemux -lwebp  -lwebp    -lXext -lXt   -lSM -lICE -lX11  -llzma  -lbz2 -pthread -lOpenEXR-3_1 -lOpenEXRUtil-3_1 -lOpenEXRCore-3_1 -lIex-3_1 -lIlmThread-3_1 -lImath-3_1  -lopenjp2  -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lharfbuzz -lcairo  -lraw_r -lstdc++ -fopenmp -llcms2   -lxml2  -lgvc -lcgraph -lcdt  -lz  -lzip   -lltdl  -lm    -lpthread 
  CXX             = g++
  CXXFLAGS        =  -pthread
  FEATURES        = DPC HDRI Cipher OpenCL OpenMP
  DELEGATES       = bzlib djvu flif fpx fontconfig freetype heic jbig jng jpeg lcms lqr lzma openexr openjp2 pango png ps raqm raw tiff video webp x xml zip zlib zstd
==============================================================================

However the final binary does not list OpenCL in it feature

$ /usr/local/bin/convert -version
Version: ImageMagick 7.1.0-13 Q16-HDRI x86_64 2021-10-29 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenMP(4.5) 
Delegates (built-in): bzlib djvu flif fontconfig fpx freetype gvc heic jbig jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png raqm raw tiff webp x xml zip zlib
Compiler: gcc (11.1)

I am using AMD Ryzen 9 5900HS with Radeon Graphics (16)
I have opencl-mesa opencl-headers & ocl-icd installed, with amdgpu driver loaded

Steps to Reproduce

./configure --enable-opencl <- Detects OpenCL and adds it to the features
make
sudo make install

convert -version < -- Fails to show opencl in the feature list

Images

No response

@snibgo
Copy link

snibgo commented Nov 7, 2021

Your config.log may explain the problem.

@DroidFreak32
Copy link
Author

Okay I see this:

configure:10010: gcc -c -fopenmp -Wall -g -O2 -mtune=amdfam10 -fexceptions -pthread  conftest.c >&5
In file included from /usr/include/CL/cl.h:20,
                 from conftest.c:64:
/usr/include/CL/cl_version.h:22:9: note: '#pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)'
   22 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)")
      |         ^~~~~~~
configure:10010: $? = 0
configure:10010: result: yes
configure:10010: checking CL/cl.h presence
configure:10010: gcc -E  conftest.c
configure:10010: $? = 0
configure:10010: result: yes
configure:10010: checking for CL/cl.h
configure:10010: result: yes
configure:10074: checking for OpenCL library
configure:10172: gcc -o conftest    conftest.c  -lpthread -L/usr/lib64/nvidia -L/usr/lib/nvidia -lOpenCL >&5
In file included from /usr/include/CL/cl.h:20,
                 from conftest.c:36:
/usr/include/CL/cl_version.h:22:9: note: '#pragma message: cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)'
   22 | #pragma message("cl_version.h: CL_TARGET_OPENCL_VERSION is not defined. Defaulting to 300 (OpenCL 3.0)")
      |         ^~~~~~~
configure:10172: $? = 0
configure:10175: result: yes
configure:10224: checking for special C compiler options needed for large files
configure:10269: result: no
configure:10275: checking for _FILE_OFFSET_BITS value needed for large files

Is it trying to fetch the supported OPenCL version from NVIDIA libs?

clinfo gives the following output:

Platform Name                                   Clover
Number of devices                                 1
Device Name                                     AMD RENOIR (DRM 3.42.0, 5.14.15-arch1-g14-1, LLVM 12.0.1)
Device Vendor                                   AMD
Device Vendor ID                                0x1002
Device Version                                  OpenCL 1.1 Mesa 21.2.4
Device Numeric Version                          0x401000 (1.1.0)
Driver Version                                  21.2.4
Device OpenCL C Version                         OpenCL C 1.1 

IM should be using OCL version 1.1 in that case?
The log suggests it is trying to use version 3.0.0 . I tried exporting CL_TARGET_OPENCL_VERSION=110 with no luck.

@snibgo
Copy link

snibgo commented Nov 7, 2021

Sorry, I don't know enough about OpenCL. It looks as if your OpenCL source code is 3.0.0 but the installed version is 1.1. Such a large difference in version numbers suggests they may not be compatible.

Did you do automake and autoconf?

Is that the only reference in config.log to OpenCL? It looks more like a warning than an error that would prevent a build with OpenCL.

@DroidFreak32
Copy link
Author

Yes these are the only noteworthy reference to opencl.

I did compiled following https://imagemagick.org/script/install-source.php
I did not do automake or autoconf.

Is Imagemagick incompatible with OCL 1.1?

@ImageMagick ImageMagick deleted a comment from tobi9462 Nov 22, 2021
@dlemstra
Copy link
Member

Can you give this another try with the latest release?

@dlemstra
Copy link
Member

Ping @DroidFreak32

@DroidFreak32
Copy link
Author

DroidFreak32 commented Dec 14, 2021

Sorry for the delay in response @dlemstra , I will test it today and edit this comment with my result.

EDIT:
Works now! Thanks @dlemstra

/usr/local/bin/convert -version
Version: ImageMagick 7.1.0-18 Q16-HDRI x86_64 2021-12-04 https://imagemagick.org
Copyright: (C) 1999-2021 ImageMagick Studio LLC
License: https://imagemagick.org/script/license.php
Features: Cipher DPC HDRI OpenCL OpenMP(4.5)
Delegates (built-in): bzlib djvu fontconfig freetype gvc heic jng jp2 jpeg lcms lqr ltdl lzma openexr pangocairo png raqm raw tiff webp x xml zip zlib
Compiler: gcc (11.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants