Make error on Windows when build the *.dll *.json *.params

I built TVM on Windows 10 with VS2017 + LLVM8.0.1 (clang + lld) I got the tvm.dll, tvm_runtime.dll tvm_topi.dll, However, I want to get the IR about the (model).dll on windows, I ried the code(python) on Ubuntu16.04 and got the (model).so successful ,on Windows ,I got errors blew:

                                                                                                                      File "tvm_detect.py", line 141, in <module>                                                                               lib.export_library(path_lib)                                                                                                                                                                                                                  File "C:\Users\fourmigao\AppData\Roaming\Python\Python37\site-packages\tvm-0.7.dev1-py3.7-win-amd64.egg\tvm\runtime\module.py", line 337, in export_library                                                                                       fcompile(file_name, files, **kwargs)                                                                                                                                                                                                          File "C:\Users\fourmigao\AppData\Roaming\Python\Python37\site-packages\tvm-0.7.dev1-py3.7-win-amd64.egg\tvm\contrib\cc.py", line 50, in create_shared                                                                                             _windows_shared(output, objects, options)                                                                                                                                                                                                     File "C:\Users\fourmigao\AppData\Roaming\Python\Python37\site-packages\tvm-0.7.dev1-py3.7-win-amd64.egg\tvm\contrib\cc.py", line 247, in _windows_shared                                                                                          raise RuntimeError(msg)                                                                                                                                                                                                                     RuntimeError: Compilation error:   

lld-link: error: could not open uuid.lib: no such file or directory
lld-link: error: could not open LIBCMT.lib: no such file or directory
lld-link: error: could not open OLDNAMES.lib: no such file or directory

I had struggle with them 48 hours and i failed, Could anyone help me or tell me what should I do? Thank U very much!!!

Does it help if you run your python script from the “x64 Native Tools Command Prompt”?

image

Thanks a lot ,It works , however, After doing that , I got a new Error. :cold_sweat:

File “tvm_detect.py”, line 141, in lib.export_library(path_lib) File “C:\Users\fourmigao\AppData\Roaming\Python\Python37\site-packages\tvm-0.7.dev1-py3.7-win-amd64.egg\tvm\runtime\module.py”, line 337, in export_library fcompile(file_name, files, **kwargs) File “C:\Users\fourmigao\AppData\Roaming\Python\Python37\site-packages\tvm-0.7.dev1-py3.7-win-amd64.egg\tvm\contrib\cc.py”, line 50, in create_shared _windows_shared(output, objects, options) File “C:\Users\fourmigao\AppData\Roaming\Python\Python37\site-packages\tvm-0.7.dev1-py3.7-win-amd64.egg\tvm\contrib\cc.py”, line 247, in _windows_shared raise RuntimeError(msg) RuntimeError: Compilation error: lld-link: error: : undefined symbol: tvm_main

I just pulled the latest from master and have the same issue. I’ll see if I can get together enough info to get some help on this. In the mean time can you pull from a commit from April 1st and see if it goes away?

I am also seeing this error with the newest changes :frowning: haven’t had a chance to investigate yet though.

1 Like

The good news is that I have found the commit where the issue started. (The commit prior to this one was showed no issue.)

I can poke around a little tomorrow on it. I have not tested on linux yet, so unsure if it’s a platform dependent issue…or model, etc.

cc @tqchen

1 Like

Here’s what I’ve figured out so far:

There is no problem with the latest from master on Linux. I tried with the same model and it worked fine. Seems to happen only on Windows.

The obj file (ex AppData\Local\Temp\tmpf_x8ltvd\lib0.o) generated before #5233 has symbols like this (shorted for brevity):

096 00021860 SECT1  notype ()    External     | fused_layout_transform_nn_prelu_layout_transform_7
097 00021D80 SECT1  notype ()    External     | fused_layout_transform_nn_prelu_layout_transform_4
098 00022A90 SECT1  notype ()    External     | fused_layout_transform_nn_prelu_layout_transform_6
099 00022FB0 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_6
09A 000254F0 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_add_7
09B 00027D30 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_7
09C 00029CD0 SECT1  notype ()    External     | fused_layout_transform_nn_prelu
09D 0002A3A0 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_8
09E 0002C320 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_9
09F 0002E2C0 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_10
0A0 0000E070 SECT22 notype       External     | __tvm_main__

With #5233, there is no __tvm_main__ symbol, hence the “undefined symbol” error during linking. Here is the dumbin /symbols for the ‘broken’ obj:

072 00000000 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_add_multiply_add
    073 00000000 SECT3  notype       External     | __TVMAPISetLastError
    074 00000010 SECT3  notype       External     | __TVMBackendAllocWorkspace
    075 00000008 SECT3  notype       External     | __TVMBackendParallelLaunch
    076 00000000 UNDEF  notype       External     | __chkstk
    077 00000018 SECT3  notype       External     | __TVMBackendFreeWorkspace
    078 00000000 UNDEF  notype       External     | memset
    079 000019A0 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_add_1
    07A 00002FF0 SECT1  notype ()    External     | fused_nn_dense_add_multiply_add
    07B 00003990 SECT1  notype ()    External     | fused_layout_transform_nn_batch_flatten
    07C 00004720 SECT1  notype ()    External     | fused_layout_transform_nn_prelu_layout_transform
    07D 00004D90 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_7
    07E 00006D50 SECT1  notype ()    External     | fused_layout_transform_nn_prelu_layout_transform_5
    07F 00007220 SECT1  notype ()    External     | fused_layout_transform_nn_prelu_layout_transform_4
    080 00007F60 SECT1  notype ()    External     | fused_add_8
    081 00008550 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add
    082 00009860 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_add
    083 0000ADC0 SECT1  notype ()    External     | fused_layout_transform_nn_prelu_layout_transform_1
    084 0000B680 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_1
    085 0000CDA0 SECT1  notype ()    External     | fused_layout_transform_nn_prelu
    086 0000D450 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_add_6
    087 0000F6C0 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_add_5
    088 000114F0 SECT1  notype ()    External     | fused_add_9
    089 00011C10 SECT1  notype ()    External     | fused_layout_transform_nn_prelu_layout_transform_3
    08A 00012950 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_add_2
    08B 000143F0 SECT1  notype ()    External     | fused_layout_transform_nn_prelu_layout_transform_2
    08C 00014CB0 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_2
    08D 000163D0 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_add_3
    08E 00018090 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_3
    08F 00019E80 SECT1  notype ()    External     | fused_add_10
    090 0001A820 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_add_4
    091 0001C950 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_4
    092 0001E740 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_5
    093 00020DC0 SECT1  notype ()    External     | fused_add_11
    094 000212E0 SECT1  notype ()    External     | fused_layout_transform_nn_prelu_layout_transform_6
    095 000217B0 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_6
    096 00023E30 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_add_7
    097 00026140 SECT1  notype ()    External     | fused_layout_transform_nn_prelu_layout_transform_7
    098 00026610 SECT1  notype ()    External     | fused_add_layout_transform
    099 00026B60 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_8
    09A 00028B00 SECT1  notype ()    External     | fused_copy_subtract_multiply_layout_transform
    09B 00028E90 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_12
    09C 00029F00 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_9
    09D 0002BB00 SECT1  notype ()    External     | fused_layout_transform_16
    09E 0002BED0 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_10
    09F 0002D6D0 SECT1  notype ()    External     | fused_nn_contrib_conv2d_NCHWc_add_11
    0A0 00000000 UNDEF  notype       External     | _fltused
    0A1 00000000 DEBUG  notype       Filename     | .file

I’ve tried debugging a bit, but it seems this is the result of that:

image

I think i may have figured it out:

If I disable this line in cc.py it successfully compiles and runs inference time cost tests.

Is the _tvm_main_ symbol no longer needed? I checked and its not being exported on Linux either.

If it does not need it any more, there may be other parts of the code that need updating also.

cc: @jonso, @tqchen

3 Likes

It really works, thanks a lot!!!

@tqchen @zhiics do you have any thoughts on the usage of __tvm_main__?

IT REALLY HELPS! thanks.

Sorry to bother you @tqchen, but unsure who else to poke and luckily it is your name on the commit where the issue first started :slight_smile:

I think the main repo is ‘broken’ for Windows due to __tvm_main__ not being exported any more. Linux no longer exports. readelf -Ws deply.so shows no __tvm_main__ , it compiles fine but the Windows has an explicit “-EXPORT:__tvm_main__” arg during compilation (detailed above) and fails compiling because the symbol no longer there to export. Removing the “-EXPORT” arg is the current workaround, but I suspect that may not be correct as several other parts of the source refer to it.