How to run on python / windows, correctly?

Hello, I am new to TVM.
I just want to convert Keras model to TVM model, at first.

It seems there are some people who are working on TVM / windows,
But how does that system work correctly?

  • My environment:
    MSVC 2017, windows 10, python3.7 (Anaconda)

What I have done is,

[Download repository]

>git clone --recursive https://github.com/dmlc/tvm

[Build “tvm.dll”, “tvm_topi.dll” on MSVC 2017]

>cd tvm
>mkdir build
>cd build
>cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DCMAKE_CONFIGURATION_TYPES="Release" ..

and build tvm on MSVC2017, then “tvm.dll”, “tvm_topi.dll” were generated.

[Python package installation]

>cd python
>python setup.py install
>cd ..
>cd topi/python
>python setup.py install
>cd ./..
>cd nnvm/python
>python setup.py install

After above installation, it seems tvm and nnvm were installed on python package, but when I tried to convert some keras model, error always happens on this function

with nnvm.compiler.build_config(opt_level=2):
    graph, lib, params = nnvm.compiler.build(sym, target, shape_dict, params=params)

The error is something like this one

Cannot find config for target=opencl, workload=('conv2d', ('float32',), (64, 1, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
Traceback (most recent call last):

  File "test2.py", line 75, in <module>
    graph, lib, params = nnvm.compiler.build(sym, target, shape_dict, params=params)

  File "D:\Anaconda3\Anaconda3\lib\site-packages\nnvm-0.8.0-py3.7.egg\nnvm\compiler\build_module.py", line 321, in build
    graph = graph.apply("GraphCompile")

  File "D:\Anaconda3\Anaconda3\lib\site-packages\nnvm-0.8.0-py3.7.egg\nnvm\graph.py", line 250, in apply
    check_call(_LIB.NNGraphApplyPasses(self.handle, npass, cpass, ctypes.byref(ghandle)))

  File "D:\Anaconda3\Anaconda3\lib\site-packages\nnvm-0.8.0-py3.7.egg\nnvm\_base.py", line 91, in check_call
    raise NNVMError(py_str(_LIB.NNGetLastError()))

nnvm._base.NNVMError: ValueError: not enough values to unpack (expected 4, got 0)
Stack trace:
    batch, in_channel, in_height, in_width = Input.shape
  File "D:\Anaconda3\Anaconda3\lib\site-packages\topi-0.6.dev0-py3.7.egg\topi\nn\conv2d.py", line 207, in conv2d_nchw
    return nn.conv2d_nchw(data, kernel, strides, padding, dilation, out_dtype)
  File "D:\Anaconda3\Anaconda3\lib\site-packages\topi-0.6.dev0-py3.7.egg\topi\cuda\conv2d.py", line 113, in conv2d_cuda
    node = f(cfg, *args, **kwargs)
  File "D:\Anaconda3\Anaconda3\lib\site-packages\tvm-0.6.dev0-py3.7-win-amd64.egg\tvm\autotvm\task\topi_integration.py", line 370, in template_call
    return dispatch_dict['direct'](cfg, *args, **kwargs)
  File "D:\Anaconda3\Anaconda3\lib\site-packages\tvm-0.6.dev0-py3.7-win-amd64.egg\tvm\autotvm\task\dispatcher.py", line 216, in dispatch_func
  File "<D:\Anaconda3\Anaconda3\lib\site-packages\decorator.py:decorator-gen-157>", line 2, in config_dispatcher
    return dispatch_dict[k](*args, **kwargs)
  File "D:\Anaconda3\Anaconda3\lib\site-packages\tvm-0.6.dev0-py3.7-win-amd64.egg\tvm\target.py", line 372, in dispatch_func
  File "<D:\Anaconda3\Anaconda3\lib\site-packages\decorator.py:decorator-gen-27>", line 2, in conv2d
    inputs[0], inputs[1], strides, padding, dilation, layout, out_dtype)
  File "D:\Anaconda3\Anaconda3\lib\site-packages\nnvm-0.8.0-py3.7.egg\nnvm\top\nn.py", line 121, in compute_conv2d
    rv = local_pyfunc(*pyargs)
  File "D:\Anaconda3\Anaconda3\lib\site-packages\tvm-0.6.dev0-py3.7-win-amd64.egg\tvm\_ffi\_ctypes\function.py", line 72, in cfun
Stack trace not available when DMLC_LOG_STACK_TRACE is disabled at compile time.

So, I am wondering my TVM installation is correct, or not…
Any help is welcome, thx in advance!

I’ve confronted the same error. I tried to limit the auto_unroll_max_step and it ran without anny error. But I don’t know what exactly the parameter means. You can have a try.

target='cuda'
if target == "cuda":
    max_step = 1400
else:
    max_step = 128
with relay.build_config(opt_level=3, fallback_device=tvm.cpu()):
    with tvm.build_config(auto_unroll_max_step=max_step, unroll_explicit=(target != "cuda")):
        graph, lib, params = relay.build(func, target, params=params)
print("relay.build done")