VTA build on PYNQ fails at VTA.cmake:97

Hi! I’ve tried building VTA on my PYNQ board following the instructions here: https://docs.tvm.ai/vta/install.html#vta-simulator-installation The cmake step fails with:

CMake Error at cmake/modules/VTA.cmake:97 (add_library):
  Cannot find source file:

    /src/pynq/pynq_driver.cc

  Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp
  .hxx .in .txx
Call Stack (most recent call first):
  CMakeLists.txt:239 (include)

Looking at VTA.cmake, it seems to use a 2 variables, VTA_DIR and VTA_HW_DIR, but only sets VTA_DIR, so ${VTA_HW_DIR}/src/pynq/pynq_driver.cc resolves to just /src/pynq/pynq_driver.cc.

I’ve tried adding set(VTA_HW_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vta/vta-hw) to VTA.cmake, which makes cmake run without errors. However, make then fails with

/home/xilinx/tvm/vta/vta-hw/src/pynq/pynq_driver.cc:23:10: fatal error: vta/driver.h: No such file or directory

It seems this workaround does not work.

Could anyone help shed more light on this?

Hello, I met same problem and found below patch fixes build-error.

(But after that, I met another error when I ran start_rpc_server.sh + test_benchmark_gemm.py …)

Anyway, I think you’re right, ${VTA_HW_DIR} have no longer not been used and intended to be replaced as ${VTA_DIR} .

--- a/cmake/modules/VTA.cmake
+++ b/cmake/modules/VTA.cmake
@@ -83,19 +83,19 @@ elseif(PYTHON)

   # VTA FPGA driver sources
   if(USE_VTA_FPGA)
-    file(GLOB FPGA_RUNTIME_SRCS ${VTA_HW_DIR}/src/*.cc)
+    file(GLOB FPGA_RUNTIME_SRCS ${VTA_DIR}/src/*.cc)
     # Rules for Zynq-class FPGAs with pynq OS support (see pynq.io)
     if(${VTA_TARGET} STREQUAL "pynq" OR
        ${VTA_TARGET} STREQUAL "ultra96")
-      list(APPEND FPGA_RUNTIME_SRCS ${VTA_HW_DIR}/src/pynq/pynq_driver.cc)
+      list(APPEND FPGA_RUNTIME_SRCS ${VTA_DIR}/src/pynq/pynq_driver.cc)
       # Rules for Pynq v2.4
       find_library(__cma_lib NAMES cma PATH /usr/lib)
     elseif(${VTA_TARGET} STREQUAL "de10nano")  # DE10-Nano rules
-      file(GLOB FPGA_RUNTIME_SRCS ${VTA_HW_DIR}/src/de10nano/*.cc ${VTA_HW_DIR}/src/*.cc)
+      file(GLOB FPGA_RUNTIME_SRCS ${VTA_DIR}/src/de10nano/*.cc ${VTA_DIR}/src/*.cc)
     endif()
     # Target lib: vta
     add_library(vta SHARED ${FPGA_RUNTIME_SRCS})
-    target_include_directories(vta PUBLIC vta/include)
+    target_include_directories(vta PUBLIC ${VTA_DIR}/include)
     foreach(__def ${VTA_DEFINITIONS})
       string(SUBSTRING ${__def} 3 -1 __strip_def)
       target_compile_definitions(vta PUBLIC ${__strip_def})
@@ -105,7 +105,7 @@ elseif(PYTHON)
       target_link_libraries(vta ${__cma_lib})
     elseif(${VTA_TARGET} STREQUAL "de10nano")  # DE10-Nano rules
      #target_compile_definitions(vta PUBLIC VTA_MAX_XFER=2097152) # (1<<21)
-      target_include_directories(vta PUBLIC ${VTA_HW_DIR}/src/de10nano)
+      target_include_directories(vta PUBLIC ${VTA_DIR}/src/de10nano)
       target_include_directories(vta PUBLIC 3rdparty)
       target_include_directories(vta PUBLIC
         "/usr/local/intelFPGA_lite/18.1/embedded/ds-5/sw/gcc/arm-linux-gnueabihf/include")
1 Like

HI, @b-camacho and all PYNQ-based VTA users,

As I wrote above, I got runtime-error when I fixed cmake script and ran VTA on Xilinx device (ultra96).

I don’t know whether the error is occurring only in my environment or not, so could you let me know you succeeded to run VTA test-script or not?

My trial was ,

  1. checkout 36a83c7 (Mer 21, 2020)
  2. fix VTA.cmake
  3. build
  4. run apps/vta_rpc/start_rpc_server.sh on PYNQ device
  5. run matrix_multiply.py on HOST

And the error on PYNQ side was:

INFO:RPCServer:connection from ('192.168.174.8', 55040)
INFO:root:Skip reconfig_runtime due to same config.
INFO:root:Program FPGA with 1x16_i8w8a32_15_15_18_17.bit
INFO:root:Loading VTA library: /home/xilinx/tvm/vta/python/vta/../../../build/libvta.so
INFO:RPCServer:load_module /tmp/tmpjzo61om_/gemm.o
INFO:root:Loading VTA library: /home/xilinx/tvm/vta/python/vta/../../../build/libvta.so
(Repeat many times)
Process Process-1:4:
Traceback (most recent call last):
  File "/usr/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
    self.run()
  File "/usr/lib/python3.6/multiprocessing/process.py", line 93, in run
    self._target(*self._args, **self._kwargs)
  File "/home/xilinx/tvm/python/tvm/rpc/server.py", line 84, in _serve_loop
    base._ServerLoop(sockfd)
  File "/home/xilinx/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 213, in __call__
    raise get_last_ffi_error()
AttributeError: Traceback (most recent call last):
  [bt] (5) /home/xilinx/tvm/build/libtvm_runtime.so(TVMFuncCall+0x70) [0x7fb0586ca8]
  [bt] (4) /home/xilinx/tvm/build/libtvm_runtime.so(+0xab9b0) [0x7fb06029b0]
  [bt] (3) /home/xilinx/tvm/build/libtvm_runtime.so(+0xaa508) [0x7fb0601508]
  [bt] (2) /home/xilinx/tvm/build/libtvm_runtime.so(tvm::runtime::RPCServerLoop(int)+0xac) [0x7fb0600834]
  [bt] (1) /home/xilinx/tvm/build/libtvm_runtime.so(tvm::runtime::RPCSession::ServerLoop()+0x1cc) [0x7fb05f641c]
  [bt] (0) /home/xilinx/tvm/build/libtvm_runtime.so(+0x2bba0) [0x7fb0582ba0]
  File "/home/xilinx/tvm/python/tvm/_ffi/_ctypes/packed_func.py", line 78, in cfun
    rv = local_pyfunc(*pyargs)
  File "/home/xilinx/tvm/vta/python/vta/exec/rpc_server.py", line 85, in server_shutdown
    runtime_dll[0].VTARuntimeShutdown()
  File "/usr/lib/python3.6/ctypes/__init__.py", line 361, in __getattr__
    func = self.__getitem__(name)
  File "/usr/lib/python3.6/ctypes/__init__.py", line 366, in __getitem__
    func = self._FuncPtr((name_or_ordinal, self))
AttributeError: /home/xilinx/tvm/vta/python/vta/../../../build/libvta.so: undefined symbol: VTARuntimeShutdown

And HOST side was:

~/git/tvm$ python3 vta/tutorials/matrix_multiply.py

Traceback (most recent call last):

  File "vta/tutorials/matrix_multiply.py", line 437, in <module>
    A_nd = tvm.nd.array(A_packed, ctx)

  File "/home/blkcp/git/tvm/python/tvm/runtime/ndarray.py", line 487, in array
    return empty(arr.shape, arr.dtype, ctx).copyfrom(arr)

  File "/home/blkcp/git/tvm/python/tvm/runtime/ndarray.py", line 278, in empty
    ctypes.byref(handle)))

  File "/home/blkcp/git/tvm/python/tvm/_ffi/base.py", line 330, in check_call
    raise get_last_ffi_error()

tvm._ffi.base.TVMError: Traceback (most recent call last):
  [bt] (8) /home/xilinx/tvm/build/libtvm_runtime.so(tvm::runtime::RPCSession::EventHandler::HandleNextEvent(tvm::runtime::TVMRetValue*, bool, tvm::runtime::PackedFunc const*)+0x3d8) [0x7fb05fcd40]
  [bt] (7) /home/xilinx/tvm/build/libtvm_runtime.so(tvm::runtime::RPCSession::EventHandler::HandleRecvPackedSeqArg()+0x14c) [0x7fb05fc314]
  [bt] (6) /home/xilinx/tvm/build/libtvm_runtime.so(tvm::runtime::RPCSession::EventHandler::SwitchToState(tvm::runtime::RPCSession::EventHandler::State)+0x320) [0x7fb05fb218]
  [bt] (5) /home/xilinx/tvm/build/libtvm_runtime.so(tvm::runtime::RPCSession::EventHandler::HandlePackedCall()+0x628) [0x7fb05f5710]
  [bt] (4) /home/xilinx/tvm/build/libtvm_runtime.so(void tvm::runtime::RPCSession::EventHandler::CallHandler<void (*)(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)>(void (*)(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*))+0x7c) [0x7fb05faafc]
  [bt] (3) /home/xilinx/tvm/build/libtvm_runtime.so(tvm::runtime::RPCDevAllocData(tvm::runtime::TVMArgs, tvm::runtime::TVMRetValue*)+0xb0) [0x7fb05f45b8]
  [bt] (2) /home/xilinx/tvm/build/libtvm_runtime.so(tvm::runtime::DeviceAPIManager::GetAPI(int, bool)+0x168) [0x7fb058dc60]
  [bt] (1) /home/xilinx/tvm/build/libtvm_runtime.so(tvm::runtime::DeviceAPIManager::GetAPI(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool)+0xd0) [0x7fb058d728]
  [bt] (0) /home/xilinx/tvm/build/libtvm_runtime.so(+0x2bba0) [0x7fb0582ba0]

At the host side, I have the same issue while running vta/tutorials/vta_get_started.py.