Intel OpenCL doesn't work in binary, but does work when compiling from source

Hi,

I recently created a ticket ( #88389 - Intel OpenCL doesn't work in binary, but does work when compiling from source - blender - Blender Projects ), but I was instructed to post here on devtalk instead.

I was able to get OpenCL working on my Intel Broadwell HD Graphics 5500, which is a part of my i5 Broadwell CPU, after compiling Blender from source.

However, it’s not working with the Blender binaries.

The folks from Intel’s compute runtime helped with this. There’s a detailed ticket here: Intel HD Graphics: Crash when rendering default cube using blender cycles · Issue #392 · intel/compute-runtime · GitHub

This links to the last comment which summarizes the steps I took at the end to get it working.

One thing not mentioned in that comment is that I had installed the NEO Compute Runtime OpenCL drivers from here: https github dot com /intel/compute-runtime/releases/tag/21.01.18793 using the deb packages. It’s mentioned in a comment further up in the thread.

Then I ran these commands:

mkdir ~/blender-git
cd ~/blender-git
git clone https git.blender dot org /blender.git
git checkout cab6d5e94a6
cd ~/blender-git
./blender/build_files/build_environment/install_deps.sh

That failed so did this instead:

./blender/build_files/build_environment/install_deps.sh --skip-osl --skip-embree

That outputted this command which was saved for later but not yet run:

make -j4 BUILD_CMAKE_ARGS="-U *SNDFILE* -U PYTHON* -U *BOOST* -U *Boost* -U *TBB* -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CYCLES* -U *OPENSUBDIV* -U *OPENVDB* -U *BLOSC* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC* -U *USD* -U *EMBREE* -U *OPENIMAGEDENOISE* -U *OPENXR* -D WITH_CODEC_SNDFILE=ON -D PYTHON_VERSION=3.8 -D WITH_OPENCOLORIO=ON -D WITH_CYCLES_OSL=OFF -D WITH_LLVM=OFF -D WITH_OPENSUBDIV=ON -D OPENSUBDIV_ROOT_DIR=/opt/lib/osd -D WITH_OPENVDB=ON -D WITH_OPENVDB_BLOSC=ON -D OPENVDB_ROOT_DIR=/opt/lib/openvdb -D BLOSC_ROOT_DIR=/opt/lib/blosc -D WITH_ALEMBIC=ON -D ALEMBIC_ROOT_DIR=/opt/lib/alembic -D WITH_USD=ON -D USD_ROOT_DIR=/opt/lib/usd -D WITH_CODEC_FFMPEG=ON -D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;swresample;lzma;rt;theora;theoradec;theoraenc;vorbis;vorbisenc;vorbisfile;ogg;x264;openjp2' -D WITH_XR_OPENXR=ON -D XR_OPENXR_SDK_ROOT_DIR=/opt/lib/xr-openxr-sdk"

Then I finished the build process:

cd ~/blender-git/blender
make update

# Used the make command from above
make -j4 BUILD_CMAKE_ARGS="-U *SNDFILE* -U PYTHON* -U *BOOST* -U *Boost* -U *TBB* -U *OPENCOLORIO* -U *OPENEXR* -U *OPENIMAGEIO* -U *LLVM* -U *CYCLES* -U *OPENSUBDIV* -U *OPENVDB* -U *BLOSC* -U *COLLADA* -U *FFMPEG* -U *ALEMBIC* -U *USD* -U *EMBREE* -U *OPENIMAGEDENOISE* -U *OPENXR* -D WITH_CODEC_SNDFILE=ON -D PYTHON_VERSION=3.8 -D WITH_OPENCOLORIO=ON -D WITH_CYCLES_OSL=OFF -D WITH_LLVM=OFF -D WITH_OPENSUBDIV=ON -D OPENSUBDIV_ROOT_DIR=/opt/lib/osd -D WITH_OPENVDB=ON -D WITH_OPENVDB_BLOSC=ON -D OPENVDB_ROOT_DIR=/opt/lib/openvdb -D BLOSC_ROOT_DIR=/opt/lib/blosc -D WITH_ALEMBIC=ON -D ALEMBIC_ROOT_DIR=/opt/lib/alembic -D WITH_USD=ON -D USD_ROOT_DIR=/opt/lib/usd -D WITH_CODEC_FFMPEG=ON -D FFMPEG_LIBRARIES='avformat;avcodec;avutil;avdevice;swscale;swresample;lzma;rt;theora;theoradec;theoraenc;vorbis;vorbisenc;vorbisfile;ogg;x264;openjp2' -D WITH_XR_OPENXR=ON -D XR_OPENXR_SDK_ROOT_DIR=/opt/lib/xr-openxr-sdk"

After that, I ran blender like below, and it was able to render the default cube using OpenCL. It also rendered the Pavilion scene. It ran much faster than the CPU for both scenes, which was very nice considering I don’t have a discrete GPU. I also used intel_gpu_top to confirm the GPU was being used.

cd ~/blender-git/build_linux/bin CYCLES_OPENCL_SPLIT_KERNEL_TEST=1 CYCLES_OPENCL_TEST=all ./blender -E CYCLES --debug-cycles

Exact steps for others to reproduce the error

Download blender experimental 2.93.0 - Beta (3.0.0 - Alpha has the same problem) from https builder.blender dot org /download/daily/.

Run blender using this command:

CYCLES_OPENCL_SPLIT_KERNEL_TEST=1 CYCLES_OPENCL_TEST=all ./blender -E CYCLES --debug-cycles

Go to Edit → Preferences → System → Cycles Render Devices → OpenCL
Check Intel Graphics [0x1616]
Uncheck Intel Core i5-5200-U CPU @ 2.20GHz
Exit Settings Window

Click the Render Properties button on the right.
Set Render Engine to Cycles.
Set Device to GPU Compute

Click Render → Render Image.

Then blender crashes using the binaries. It doesn’t crash when compiled from source. One other thing to note, when I compiled from source but used the CentOS dependencies, it also crashed. I had to build all the dependencies to get it working.

Error Messages

The terminal output looks like this:

CYCLES_OPENCL_SPLIT_KERNEL_TEST=1 CYCLES_OPENCL_TEST=all ./blender -E CYCLES --debug-cycles
Read prefs: /home/mark/.config/blender/2.93/config/userpref.blend
I0519 00:11:22.262037 100014 blender_python.cpp:195] Debug flags initialized to:
CPU flags:
  AVX2       : True
  AVX        : True
  SSE4.1     : True
  SSE3       : True
  SSE2       : True
  BVH layout : EMBREE
  Split      : False
CUDA flags:
  Adaptive Compile : False
OptiX flags:
  CUDA streams : 1
OpenCL flags:
  Device type    : ALL
  Debug          : False
  Memory limit   : 0
I0519 00:11:30.115715 100014 device_opencl.cpp:48] CLEW initialization succeeded.
I0519 00:11:30.119325 100014 opencl_util.cpp:957] Enumerating devices for platform Intel(R) OpenCL HD Graphics.
I0519 00:11:30.119407 100014 opencl_util.cpp:995] Adding new device Intel(R) Graphics [0x1616].
I0519 00:11:37.944104 100205 device_opencl_impl.cpp:645] Creating new Cycles device for OpenCL platform Intel(R) OpenCL HD Graphics, device Intel(R) Graphics [0x1616].
I0519 00:11:37.945466 100205 blender_sync.cpp:256] Total time spent synchronizing data: 0.000741959
I0519 00:11:37.946048 100207 scene.cpp:557] Requested features:
Experimental features: On
Max nodes group: 0
Nodes features: 0
Use Hair: False
Use Object Motion: False
Use Camera Motion: False
Use Baking: False
Use Subsurface: False
Use Volume: False
Use Branched Integrator: False
Use Patch Evaluation: False
Use Transparent Shadows: False
Use Principled BSDF: True
Use Denoising: False
Use Displacement: False
Use Background Light: True
I0519 00:11:37.946103 100207 device_opencl_impl.cpp:765] Loading kernels for platform Intel(R) OpenCL HD Graphics, device Intel(R) Graphics [0x1616].
I0519 00:11:37.946185 100207 opencl_util.cpp:298] OpenCL program base not found in cache.
I0519 00:11:37.972498 100207 opencl_util.cpp:298] OpenCL program base not found on disk.
I0519 00:11:37.973278 100030 opencl_util.cpp:298] OpenCL program base not found in cache.
I0519 00:11:37.973438 100207 opencl_util.cpp:298] OpenCL program background not found in cache.
Cycles: compiling OpenCL program base...
I0519 00:11:38.020411 100030 opencl_util.cpp:298] Build flags: 
I0519 00:11:38.068863 100207 opencl_util.cpp:298] OpenCL program background not found on disk.
I0519 00:11:38.068996 100032 opencl_util.cpp:298] OpenCL program background not found in cache.
Cycles: compiling OpenCL program background...
I0519 00:11:38.153707 100032 opencl_util.cpp:298] Build flags: -D__KERNEL_EXPERIMENTAL__ -D__NODES_MAX_GROUP__=0 -D__NODES_FEATURES__=0 -D__NO_HAIR__ -D__NO_OBJECT_MOTION__ -D__NO_CAMERA_MOTION__ -D__NO_BAKING__ -D__NO_VOLUME__ -D__NO_SUBSURFACE__ -D__NO_BRANCHED_PATH__ -D__NO_PATCH_EVAL__ -D__NO_TRANSPARENT__ -D__NO_SHADOW_TRICKS__ -D__NO_DENOISING__ -D__NO_SHADER_RAYTRACE__
Segmentation fault (core dumped)
I0519 00:11:38.899704 100030 opencl_util.cpp:298] Separate-process building of /home/mark/.cache/cycles/kernels/cycles_kernel_base_9CCD6B9180E01A2A1CB9C9EFC8887D12_57B950DA4613A9A82E8A2030B10EA0B2.clbin failed, will fall back to regular building.
Cycles: compiling OpenCL program base...
I0519 00:11:38.919816 100030 opencl_util.cpp:298] Build flags: 
I0519 00:11:38.920032 100030 opencl_util.cpp:325] Build options passed to clBuildProgram: '-cl-no-signed-zeros -cl-mad-enable -cl-std=CL2.0 -D__KERNEL_CL_KHR_FP16__ -DWITH_NANOVDB '.
Writing: /tmp/blender.crash.txt
Segmentation fault (core dumped)
Segmentation fault (core dumped)

/tmp/blender.crash.txt looks like this:

# Blender 2.93.0, Commit date: 2021-05-17 22:30, Hash ea11b4e10ce0
bpy.context.space_data.context = 'RENDER'  # Property
bpy.context.scene.cycles.device = 'GPU'  # Property

# backtrace
./blender(BLI_system_backtrace+0x20) [0xa598520]
./blender() [0xf6263a]
/lib/x86_64-linux-gnu/libc.so.6(+0x46210) [0x7fb7269f9210]

# Python backtrace

Any ideas? I’m guessing its related to how the dependencies are compiled since the “Download Libraries” method didn’t work for me when compiling from source. I had to build using the Advanced Setup → install_deps.sh method. Referencing this page: https: wiki.blender dot org /wiki/Building_Blender/Linux/Ubuntu

BTW sorry about some of the links. New users can only put 2 links.

Thanks!

It’s potentially a conflict between two different LLVM versions, one in Blender and one in the OpenCL driver. If you build it yourself you might end up using the same LLVM library for both Blender and the OpenCL driver, and avoid that problem.

We try to hide LLVM symbols to avoid that, but there could be an issue with that.

We don’t support OpenCL rendering with this graphics card though, which is why it’s hidden behind environment variables. So it’s not something we’re likely to spend time on investigating.

Thanks for the info on LLVM, @brecht.

I tried compiling 2.93.0 using make deps instead of install_deps.sh in hopes of producing a portable binary that other Ubuntu 20.04 users could use.

However, with that method, it failed on my system after compiling. Same segmentation fault error when pressing Render Image.

I wonder if there’s some difference between using install_deps.sh and make deps. If LLVM versioning was the problem, I would think compiling with make deps would have worked at least on my system since I compiled everything.

Any help is greatly appreciated, and understood that OpenCL rendering on Intel isn’t supported. No worries if it won’t be investigated.

Thank you

make deps is what is used to make the precompiled libraries, it will have the same issues. You can’t both have a portable build (which includes all libraries like LLVM) and use the system LLVM library.

1 Like

Thanks @brecht. That makes sense. I’m not sure which LLVM library Intel NEO OpenCL Computer Runtime was compiled with.

Looks like the LLVM version in Ubuntu 20.04 is 10.0.0.

I recompiled a blender portable build but changed to LLVM version 10.0.0 in build_files/build_environment/cmake/versions.cmake (also had to update the hash to prevent an error).

Unfortunately, I’m getting the same error. I’ll try some other things if I can think of them. Turns out I had a custom Mesa version installed, so I uninstalled that and will try re-compiling.