Halide can't seem to find OpenCL #8342
-
I'm using the 17.0.2 binaries on ubuntu 22.04. The following code always returns false: host = Halide::get_host_target();
host.set_feature(Halide::Target::OpenCL);
return Halide::host_supports_target_device(host); I have opencl installed (according to clinfo). I did have to specify Is it possible to use OpenCL with the binaries or do I need to build from source? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments
-
Figured it out. The following threads were helpful (but a pain to find!): My CmakeLists.txt doesn't need to deal with OpenCL at all. Only Halide. And in my code: // you can still export HL_JIT_TARGET="host-cuda" if you want but this way it'll always be set to opencl by default.
// surely there's a way to do this without environment variables...but this is fine for now
setenv("HL_JIT_TARGET", "host-opencl-debug", false); // -debug is optional...
Halide::Target host = Halide::get_jit_target_from_environment(); Now a call to |
Beta Was this translation helpful? Give feedback.
-
I'm a bit puzzled, because the first piece of code you wrote should have worked. I think there might be a bug here. Is it possible that other JIT code without opencl was already run in the same process? |
Beta Was this translation helpful? Give feedback.
-
It's pretty basic I think. Here's what I'm doing: setenv("HL_JIT_TARGET", "host-opencl-debug", false);
Halide::Target T = Halide::get_jit_target_from_environment();
//T.set_feature(Halide::Target::OpenCL); // Other than the debug stuff this actually does have the same result
RCLCPP_INFO(get_logger(), "Halide Target: %s has GPU? %s! host supports? %s", T.to_string().c_str(), T.has_gpu_feature() ? "YES" : "NO", Halide::host_supports_target_device(T) ? "YES" : "NO");
pipeline = halide_pipeline(); // actually a Func
#if defined(LOWER)
try
{
pipeline.compile_to_lowered_stmt("stmt.html", pipeline.infer_arguments(), Halide::StmtOutputFormat::HTML);
RCLCPP_INFO(get_logger(), "generated stmt.html");
}
catch (...)
{
RCLCPP_WARN(get_logger(), "failed to generate stmt.html");
}
#endif
pipeline.compile_jit(T);
pipeline.print_loop_nest(); if
otherwise I get:
So I guess it really is that it can't find OpenCL on my machine after all. Here's the output of
|
Beta Was this translation helpful? Give feedback.
-
I think that means dlsym is not finding that function in whatever libOpenCL.so it managed to open. |
Beta Was this translation helpful? Give feedback.
-
Thanks. Sorry to waste your time with this. This fixed it for me:
not sure why the |
Beta Was this translation helpful? Give feedback.
-
The call to compile_to_lowered_stmt was failing because I wasn't passing the 4th argument (Target)...sigh. |
Beta Was this translation helpful? Give feedback.
Thanks. Sorry to waste your time with this. This fixed it for me:
sudo ln -sv libOpenCL.so.1 /usr/lib/x86_64-linux-gnu/libOpenCL.so
not sure why the
so.1
version exists butso
does not.