I am trying to run this code with opencl target, but I get the following error (it runs with llvm target without a problem). Does anyone know how to fix it? Thank you.
import numpy as np
import sys
import tvm
import nnvm.compiler
from tvm.contrib import graph_runtime as runtime
import logging
import nnvm.symbol as sym
from nnvm.testing import utils
def main():
out_channels = 16
data = sym.Variable(name="data")
simple_net = sym.conv2d(data=data, kernel_size=(3,3), channels=out_channels, padding = (1, 1), use_bias=True)
simple_net = sym.batch_norm(data=simple_net)
simple_net = sym.relu(data=simple_net)
batch_size = 1
data_shape = (batch_size, 3, 224, 224)
net, params = utils.create_workload(simple_net, batch_size, data_shape[1:])
logging.basicConfig(filename='simple_net.log',level=logging.DEBUG)
target = "opencl"
with nnvm.compiler.build_config(opt_level=0):
graph, lib, params = nnvm.compiler.build(
net,target=target, shape={"data": data_shape}, params=params)
try:
f = open('simple_net_graph_ir.txt', 'w')
except IOError:
cprint("Could not create file to dump Graph IR: " + f, 'red')
f.write(graph.ir())
f.close()
try:
f = open('simple_net_llvm_code.txt', 'w')
except IOError:
cprint("Could not create file to dump code: " + f, 'red')
if target == "llvm":
f.write(lib.get_source())
else:
#this will export the host side code
f.write(lib.get_source())
#this will export the device side code
f.write(lib.imported_modules[0].get_source())
f.close()
ctx = tvm.context(target, 0)
data = np.random.uniform(-1, 1, size=data_shape).astype("float32")
module = runtime.create(graph, lib, ctx)
module.set_input(**params)
module.set_input("data", data)
module.run()
out_shape = (batch_size, out_channels, 224, 224)
out = module.get_output(0, tvm.nd.empty(out_shape))
out = out.asnumpy()
return
if __name__ == '__main__':
main()
[14:13:35] /homes/tvm/src/runtime/opencl/opencl_device_api.cc:242: Initialize OpenCL platform ‘Intel® OpenCL HD Graphics’
[14:13:35] /homes/tvm/src/runtime/opencl/opencl_device_api.cc:251: No OpenCL device any device matched given the options: accelerator mode
[14:13:35] /homes/tvm/src/runtime/opencl/opencl_device_api.cc:269: opencl(0)=‘Intel® Gen9 HD Graphics NEO’ cl_device_id=0x3142120
: CommandLine Error: Option ‘disable-inlined-alloca-merging’ registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options
terminate called after throwing an instance of ‘dmlc::Error’
what(): [14:13:35] /homes//tvm/src/runtime/workspace_pool.cc:96: Check failed: allocated_.size() == 1 (2 vs. 1)Stack trace returned 10 entries:
[bt] (0) /homes/.local/lib/python3.5/site-packages/tvm-0.4.0-py3.5-linux-x86_64.egg/tvm/libtvm.so(dmlc::StackTraceabi:cxx11+0x5b) [0x7f7540e261bb]
[bt] (1) /homes/.local/lib/python3.5/site-packages/tvm-0.4.0-py3.5-linux-x86_64.egg/tvm/libtvm.so(tvm::runtime::WorkspacePool::Pool::Release(DLContext, tvm::runtime::DeviceAPI*)+0x634) [0x7f75411ef614]
[bt] (2) /homes/.local/lib/python3.5/site-packages/tvm-0.4.0-py3.5-linux-x86_64.egg/tvm/libtvm.so(tvm::runtime::WorkspacePool::~WorkspacePool()+0x3f) [0x7f75411edcef]
[bt] (3) /homes/.local/lib/python3.5/site-packages/tvm-0.4.0-py3.5-linux-x86_64.egg/tvm/libtvm.so(tvm::runtime::OpenCLThreadEntry::~OpenCLThreadEntry()+0xd) [0x7f754124fa9d]
[bt] (4) /lib/x86_64-linux-gnu/libc.so.6(__call_tls_dtors+0x3f) [0x7f754f1345ff]
[bt] (5) /lib/x86_64-linux-gnu/libc.so.6(+0x39f27) [0x7f754f133f27]
[bt] (6) /lib/x86_64-linux-gnu/libc.so.6(+0x3a045) [0x7f754f134045]
[bt] (7) /usr/lib/llvm-6.0/lib/libLLVM-6.0.so.1(llvm::report_fatal_error(llvm::Twine const&, bool)+0xa3) [0x7f753d936113]
[bt] (8) /usr/lib/llvm-6.0/lib/libLLVM-6.0.so.1(+0x831248) [0x7f753d936248]
[bt] (9) /usr/lib/llvm-6.0/lib/libLLVM-6.0.so.1(+0x8255ed) [0x7f753d92a5ed]Aborted (core dumped)