I want an easy deployment, does it possible to create a APP including my python script and all dependent TVM python scripts and libtvm_runtime.so, libtvm.so ?
Can you elaborate on your use case some more? For example if you’re just looking to create a .app
that uses the TVM runtime you will have different needs from a standalone single-file program that you can copy around and run anywhere.
If you’re looking to package a Python script so you can run it more easily, standard Python tools like PyInstaller (some details on using it with C-extensions here) or others (pipx, pex) should work since the tvm
Python library brings along libtvm.so
/libtvm_runtime.so
files (assuming the tvm library was installed to your Python site-packages
directory.
Thanks @driazati for your more tips for package python scripts to a single app.
I have successfully package a simple test_py.py + tvm + libtvm_runtime.so into an single app using pyinstaller, and it runs ok. The only problem is the destination app’s size, more than 440MB (in a new created conda env).
I just want a minimum package with TVM’s RPC.
#! /usr/bin/python3.6
# -*- coding:utf-8 -*-
# test_py.py
import tvm
import sys
import tvm.rpc
print('test_py.py will run...')
ip_addr, ip_port = sys.argv[1].split(':')
remote = tvm.rpc.connect(ip_addr, int(ip_port))
add_func = remote.get_function('rpc.test_add')
print(add_func(10, 20))
List of files under package directory:
- libtvm_runtime.so
- test_py.py # → test_py.spec
- tvm: init.py _ffi contrib parser rpc runtime support.py error.py
Content of the test_py.spec:
# -*- mode: python ; coding: utf-8 -*-
block_cipher = None
a = Analysis(['test_py.py'],
pathex=['/data/huangxiaofeng/work/vsext_example/py_package'],
binaries=[('libtvm_runtime.so', '.')],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
a.binaries,
a.zipfiles,
a.datas,
[],
name='test_py',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None )