[COMPILER][BUG] Can't cross compile OpenCL target without OpenCL device

If you enable OpenCL and are running on a device without a gpu (in my case a virtual machine) you can’t compile a model for the target tvm.target.intel_graphics, due a check in the opencl_module.cc file.

CHECK(workspace_->context != nullptr) << “No OpenCL device”

I tried disabling that check and it compiles afterwords, but the compiled lib file won’t load.
I get the following error message.

Check failed: f != nullptr Loader of (module.loadbinary_) is not presented.

I rebuilt tvm with OpenCL disabled and compiled with the same target, and the code that was generated worked correctly, but from my understanding I need to build the runtime with OpenCL enabled. The runtime and the compiler should be built using the same configuration but in this case I’m unable to do so. Also if the compiler works fine compiling for OpenCL targets without OpenCL enabled, why is the code different with OpenCL enabled?

CHECK(workspace_->context != nullptr) << “No OpenCL device”

I’ve sent a PR to delay the check. https://github.com/dmlc/tvm/pull/1657
It works on my environment as expected — I can compile a model without OpenCL device and don’t get the below error.

Check failed: f != nullptr Loader of (module.loadbinary_) is not presented.

Can you share your code so that I can reproduce the same problem?