tvm: Windows NNVM Module export_library error

Traceback (most recent call last):
  File "deploy_ssd_tvm.py", line 40, in <module>
    lib.export_library("./deployed_model/deploy_lib.dll", fcompile=False)
  File "C:\Users\*****\AppData\Roaming\Python\Python37\site-packages\tvm-0.5.dev0-py3.7-win-amd64.egg\tvm\module.py", line 128, in export_library
    fcompile(file_name, files, **kwargs)
  File "C:\Users\*****\AppData\Roaming\Python\Python37\site-packages\tvm-0.5.dev0-py3.7-win-amd64.egg\tvm\contrib\cc.py", line 35, in create_shared
    _windows_shared(output, objects, options)
  File "C:\Users\*****\AppData\Roaming\Python\Python37\site-packages\tvm-0.5.dev0-py3.7-win-amd64.egg\tvm\contrib\cc.py", line 120, in _windows_shared
    raise RuntimeError(msg)
RuntimeError: Compilation error:
Microsoft (R) Incremental Linker Version 14.16.27026.1
Copyright (C) Microsoft Corporation.  All rights reserved.

lib.o : fatal error LNK1143: invalid or corrupt file: no symbol for COMDAT section 0x5

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (14 by maintainers)

Most upvoted comments

It worked for me after patching TVM with the patch I showed above. After some testing I reduced it to the following:

diff --git a/python/tvm/contrib/cc.py b/python/tvm/contrib/cc.py
index 0ffa6c42..906bf4cc 100644
--- a/python/tvm/contrib/cc.py
+++ b/python/tvm/contrib/cc.py
@@ -91,7 +91,7 @@ BOOL APIENTRY DllMain( HMODULE hModule,\
         msg = "Compilation error:\n"
         msg += py_str(out)
         raise RuntimeError(msg)
-    link_cmd = ["link"]
+    link_cmd = ["lld-link"]
     link_cmd += ["-dll", "-FORCE:MULTIPLE"]

     for obj in objects:

Then apply it:

set PATH=%path%;C:\Program Files\Git\bin
bash.exe -c 'patch -p1 ~/AppData/Roaming/Python/Python37/site-packages/tvm-0.5.dev0-py3.7-win-amd64.egg/tvm/contrib/cc.py cc.py.patch'

Notes:

  1. You must build LLD with LLVM
  2. The directory of the built binaries (like lld-link.exe) must added to the path variables (or change to patch to include the full path to lld-link)