Hi,
I am wondering can I compile model on x86 for aarch64. If so, how should I do that.
Hi,
I am wondering can I compile model on x86 for aarch64. If so, how should I do that.
Yeah, and it’s called cross-compilation. would you like to elaborate a bit on your needs?
I have a model trained on x86. I want to use it on my AGX. I have already verified the model on my PC with TVM tvmc.compile(model, target="llvm")
. But when I change my target to target="llvm -mtriple=aarch64-none-linux-gnu"
, it returns
File "net_convert.py", line 17, in <module>
package = tvmc.compile(model, target="llvm -mtriple=aarch64-none-linux-gnu") #Step 2: Compile
File "/home/chongt/tvm/python/tvm/driver/tvmc/compiler.py", line 381, in compile_model
package_path = tvmc_model.export_package(
File "/home/chongt/tvm/python/tvm/driver/tvmc/model.py", line 325, in export_package
package_path = self.export_classic_format(
File "/home/chongt/tvm/python/tvm/driver/tvmc/model.py", line 261, in export_classic_format
executor_factory.get_lib().export_library(path_lib)
File "/home/chongt/tvm/python/tvm/runtime/module.py", line 538, in export_library
return fcompile(file_name, files, **kwargs)
File "/home/chongt/tvm/python/tvm/contrib/cc.py", line 79, in create_shared
_linux_compile(output, objects, options, cc, compile_shared=True)
File "/home/chongt/tvm/python/tvm/contrib/cc.py", line 247, in _linux_compile
raise RuntimeError(msg)
RuntimeError: Compilation error:
/usr/bin/ld: /tmp/tmp6xmmx340/lib0.o:普通ELF重定位(M: 183)
/usr/bin/ld: /tmp/tmp6xmmx340/lib0.o:普通ELF重定位(M: 183)
/usr/bin/ld: /tmp/tmp6xmmx340/lib0.o:普通ELF重定位(M: 183)
/usr/bin/ld: /tmp/tmp6xmmx340/lib0.o:普通ELF重定位(M: 183)
/usr/bin/ld: /tmp/tmp6xmmx340/lib0.o:普通ELF重定位(M: 183)
/usr/bin/ld: /tmp/tmp6xmmx340/lib0.o:普通ELF重定位(M: 183)
/usr/bin/ld: /tmp/tmp6xmmx340/lib0.o:普通ELF重定位(M: 183)
/usr/bin/ld: /tmp/tmp6xmmx340/lib0.o:普通ELF重定位(M: 183)
/tmp/tmp6xmmx340/lib0.o: 无法添加符号: 文件格式错误
collect2: error: ld returned 1 exit status
Command line: /usr/bin/g++ -shared -fPIC -o /tmp/tmpc35pd71_/mod.so /tmp/tmp6xmmx340/lib0.o
Hi @chongt123, there is some material regarding cross compilation using tvmc
in a tutorial I presented a while ago.
You probably need to also use the option cross_compiler
on your API call to achieve the same result as demonstrated in the video (which uses the command line instead).
Here is the link:
Thanks a lot @leandron , it works.
By the way, do you have the tutorials for running the model using runtime with C++ API (cross compile).
Hi. I’m happy it worked. Unfortunately I didn’t author any C++ API runtime example. You can find some examples in the docs: Apache TVM Documentation — tvm 0.10.dev0 documentation
Okay. Thanks so much.