Undefined Symbols in Web Runtime Following Tutorial Steps


#1

Hi all! Super excited about this project, but have been hitting my head against an issue for a couple days. Any help is super appreciated!

I’ve followed the instruction in the web readme, and recompiled TVM using the fastcomp LLVM config and with OpenGL on. To be more specific, I have a build folder, just below source, copied the config.cmake over and ran cmake … from that folder. The project builds without error.

I’m a little unclear on exactly how to build the web target, since the generated Makefile doesn’t have a web target. I attempted to use the same compiler options as the original Makefile to build the libtvm_web_runtime files. I’m not really sure this right, but it it generates the a bunch of the web_runtime.cc files, all within the build folder. The 3 commands are below.

emcc -std=c++11 -DDMLC_LOG_STACK_TRACE=0 -Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1 -s TOTAL_MEMORY=1073741824 -s EXTRA_EXPORTED_RUNTIME_METHODS="[‘cwrap’,‘getValue’,‘setValue’,‘addFunction’]" -s USE_GLFW=3 -s USE_WEBGL2=1 -lglfw -Iinclude -I/home/nat/testgl/tvm/3rdparty/dlpack/include -I/home/nat/testgl/tvm/3rdparty/dmlc-core/include -MM -MT build/libtvm_web_runtime.bc web/web_runtime.cc >build/web/web_runtime.d

emcc -std=c++11 -DDMLC_LOG_STACK_TRACE=0 -Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1 -s TOTAL_MEMORY=1073741824 -s EXTRA_EXPORTED_RUNTIME_METHODS="[‘cwrap’,‘getValue’,‘setValue’,‘addFunction’]" -s USE_GLFW=3 -s USE_WEBGL2=1 -lglfw -Iinclude -I/home/nat/testgl/tvm/3rdparty/dlpack/include -I/home/nat/testgl/tvm/3rdparty/dmlc-core/include -o build/libtvm_web_runtime.bc web/web_runtime.cc

emcc -std=c++11 -DDMLC_LOG_STACK_TRACE=0 -Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1 -s TOTAL_MEMORY=1073741824 -s EXTRA_EXPORTED_RUNTIME_METHODS="[‘cwrap’,‘getValue’,‘setValue’,‘addFunction’]" -s USE_GLFW=3 -s USE_WEBGL2=1 -lglfw -Iinclude -I/home/nat/testgl/tvm/3rdparty/dlpack/include -I/home/nat/testgl/tvm/3rdparty/dmlc-core/include -o build/libtvm_web_runtime.js build/libtvm_web_runtime.bc

I am able to install the python modules, using the setup scripts. However, when I actually try to run the file in test, I get the following errors, telling me the ibtvm_web_runtime.bc can’t be found.

RuntimeError: Cannot find the files.
List of candidates:
/usr/local/cuda-9.0/lib64/libtvm_web_runtime.bc
/home/nat/testgl/tvm/tests/web/libtvm_web_runtime.bc
/home/nat/.local/lib/python2.7/site-packages/tvm-0.5.dev0-py2.7-linux-x86_64.egg/tvm/libtvm_web_runtime.bc
/home/nat/.local/lib/python2.7/site-packages/build/libtvm_web_runtime.bc
/home/nat/.local/lib/python2.7/site-packages/build/Release/libtvm_web_runtime.bc
/home/nat/.local/lib/python2.7/site-packages/lib/libtvm_web_runtime.bc
/home/nat/.local/lib/python2.7/libtvm_web_runtime.bc

It seems like the python setup script should maybe be copying the files over? But I’m not really sure. When I try to manually copy the file libtvm_web_runtime.bc to the tests folder, the error does disappear, but I instead see:

/home/nat/testgl/tvm/src/codegen/llvm/codegen_llvm.cc:75: Set native vector bits to be 128 for asmjs
Traceback (most recent call last):
File “prepare_test_libs.py”, line 21, in
prepare_test_libs(os.path.join(curr_path, “.”))
File “prepare_test_libs.py”, line 17, in prepare_test_libs
emscripten.create_js(os.path.join(base_path, “test_module.js”), obj_path)
File “/home/nat/.local/lib/python2.7/site-packages/tvm-0.5.dev0-py2.7-linux-x86_64.egg/tvm/contrib/emscripten.py”, line 64, in create_js
raise RuntimeError(msg)
RuntimeError: Compilation error:
error: undefined symbol: TVMArrayCopyFromTo
warning: To disable errors for undefined symbols use -s ERROR_ON_UNDEFINED_SYMBOLS=0
error: undefined symbol: _ZN3tvm7runtime7NDArray10CopyFromToEP8DLTensorS3_Pv
error: undefined symbol: _ZN3tvm7runtime7NDArray10CreateViewENSt3__26vectorIxNS2_9allocatorIxEEEE10DLDataType
error: undefined symbol: _ZN3tvm7runtime7NDArray5EmptyENSt3__26vectorIxNS2_9allocatorIxEEEE10DLDataType9DLContext
error: undefined symbol: glfwCreateWindow
error: undefined symbol: glfwDestroyWindow
error: undefined symbol: glfwMakeContextCurrent
error: undefined symbol: glfwSetErrorCallback
error: undefined symbol: glfwWindowHint
Error: Aborting compilation due to previous errors

I’m assuming these are artifacts of my compiling the libtvm_web_runtime.bc incorrectly or the generated files not being copied to the correct place, but I am not sure. I guess my question are

  1. Once you’ve re-run Cmake and make from within the build folder, what is the recommended way to compile the web runtime. Are the 3 statements above missing anything obvious?

  2. Once the web runtime is compiled, how should it be copied over so that it is visible to the Emscripten python code within TVM?

  3. Any idea on why those symbols might be missing?

Thanks a bunch!