Skip to content

error: Use of undeclared inff #3057

@cbalint13

Description

@cbalint13

Dear All,

  • Using from_darknet tutorial but on yolov3-tiny & cuda lead to compile error seen below.
  • Patched the tutorial using a small modification to target it on yolov3-tiny & cuda, on CPU works fine.
  • There was a similar issue [BUG] Yolov3 GPU #3023, also new discuss.tv.ai thread was started HERE.

I believe its a lowering bug , not clear why llvm wants that 'inff' .
Same is with LLVM6.0 as with LLVM8.0 .

The patch to reproduce the error:

--- from_darknet_orig.py	2019-04-20 09:09:45.586862271 +0300
+++ from_darknet.py	2019-04-20 09:11:31.842581077 +0300
@@ -45,7 +45,7 @@
 from nnvm.testing.darknet import __darknetffi__
 
 # Model name
-MODEL_NAME = 'yolov3'
+MODEL_NAME = 'yolov3-tiny'
 
 ######################################################################
 # Download required files
@@ -54,7 +54,7 @@
 CFG_NAME = MODEL_NAME + '.cfg'
 WEIGHTS_NAME = MODEL_NAME + '.weights'
 REPO_URL = 'https://github.com/siju-samuel/darknet/blob/master/'
-CFG_URL = REPO_URL + 'cfg/' + CFG_NAME + '?raw=true'
+CFG_URL = 'https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/' + CFG_NAME
 WEIGHTS_URL = 'https://pjreddie.com/media/files/' + WEIGHTS_NAME
 
 cfg_path = download_testdata(CFG_URL, CFG_NAME, module="darknet")
@@ -85,8 +85,8 @@
 # Compile the model on NNVM
 # -------------------------
 # compile the model
-target = 'llvm'
-ctx = tvm.cpu(0)
+target = 'cuda'
+ctx = tvm.gpu(0)
 data = np.empty([batch_size, net.c, net.h, net.w], dtype)
 shape = {'data': data.shape}
 print("Compiling the model...")
@@ -137,7 +137,7 @@
     tvm_out.append(layer_out)
 
 elif MODEL_NAME == 'yolov3-tiny':
-    for i in range(3):
+    for i in range(2):
         layer_out = {}
         layer_out['type'] = 'Yolo'
         # Get the yolo layer attributes (n, out_c, out_h, out_w, classes, total)

Output error:

[cbalint@ TVM]$ python3 from_darknet.py 
/usr/lib64/python3.7/site-packages/sklearn/utils/__init__.py:4: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Sequence
/usr/lib64/python3.7/site-packages/sklearn/model_selection/_split.py:18: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Iterable
/usr/lib64/python3.7/site-packages/sklearn/model_selection/_search.py:16: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Mapping, namedtuple, defaultdict, Sequence
exist file got corrupted, downloading /home/cbalint/.tvm_test_data/darknet/yolov3-tiny.cfg file freshly...
Downloading from url https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov3-tiny.cfg to /home/cbalint/.tvm_test_data/darknet/yolov3-tiny.cfg
...100%, 0.01 MB, 35 KB/s, 0 seconds passed
File /home/cbalint/.tvm_test_data/darknet/yolov3-tiny.weights exists, skip.
File /home/cbalint/.tvm_test_data/darknet/libdarknet2.0.so exists, skip.
Converting darknet to nnvm symbols...
Compiling the model...
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 3, 416, 416, 'float32'), (16, 3, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 16, 208, 208, 'float32'), (32, 16, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 32, 104, 104, 'float32'), (64, 32, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 64, 52, 52, 'float32'), (128, 64, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 128, 26, 26, 'float32'), (256, 128, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 256, 13, 13, 'float32'), (512, 256, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 512, 13, 13, 'float32'), (1024, 512, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 1024, 13, 13, 'float32'), (256, 1024, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 256, 13, 13, 'float32'), (128, 256, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 384, 26, 26, 'float32'), (256, 384, 3, 3, 'float32'), (1, 1), (1, 1), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 256, 26, 26, 'float32'), (255, 256, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
WARNING:autotvm:Cannot find config for target=cuda, workload=('conv2d', (1, 512, 13, 13, 'float32'), (255, 512, 1, 1, 'float32'), (1, 1), (0, 0), (1, 1), 'NCHW', 'float32'). A fallback configuration is used, which may bring great performance regression.
Traceback (most recent call last):
  File "from_darknet.py", line 95, in <module>
    graph, lib, params = nnvm.compiler.build(sym, target, shape, dtype_dict, params)
  File "/usr/lib64/python3.7/site-packages/nnvm/compiler/build_module.py", line 321, in build
    graph = graph.apply("GraphCompile")
  File "/usr/lib64/python3.7/site-packages/nnvm/graph.py", line 250, in apply
    check_call(_LIB.NNGraphApplyPasses(self.handle, npass, cpass, ctypes.byref(ghandle)))
  File "/usr/lib64/python3.7/site-packages/nnvm/_base.py", line 91, in check_call
    raise NNVMError(py_str(_LIB.NNGetLastError()))
nnvm._base.NNVMError: RuntimeError: Compilation error:
/tmp/tmp19rb2eyk/my_kernel.cu(839): error: identifier "inff" is undefined

1 error detected in the compilation of "/tmp/tmpxft_00000df0_00000000-6_my_kernel.cpp1.ii".

Stack trace:
    raise RuntimeError(msg)
  File "/usr/lib64/python3.7/site-packages/tvm/contrib/nvcc.py", line 98, in compile_cuda
    ptx = nvcc.compile_cuda(code, target="ptx", arch=AutotvmGlobalScope.current.cuda_target_arch)
  File "/usr/lib64/python3.7/site-packages/tvm/autotvm/measure/measure_methods.py", line 574, in tvm_callback_cuda_compile
  File "tvm/_ffi/_cython/./function.pxi", line 55, in tvm._ffi._cy3.core.tvm_callback
  [bt] (0) /usr/lib64/libtvm.so(+0x18d4db) [0x7f5b579ec4db]
  [bt] (1) /usr/lib64/libtvm.so(+0x956ffa) [0x7f5b581b5ffa]
  [bt] (2) /usr/lib64/libtvm.so(+0x322b75) [0x7f5b57b81b75]
  [bt] (3) /usr/lib64/libtvm.so(+0x2f097a) [0x7f5b57b4f97a]
  [bt] (4) /usr/lib64/libtvm.so(+0x1f54e0) [0x7f5b57a544e0]
  [bt] (5) /usr/lib64/libtvm.so(+0x1f6bf4) [0x7f5b57a55bf4]
  [bt] (6) /usr/lib64/libtvm.so(TVMFuncCall+0x4f) [0x7f5b582147af]
  File "tvm/_ffi/_cython/./base.pxi", line 168, in tvm._ffi._cy3.core.CALL
  File "tvm/_ffi/_cython/./function.pxi", line 228, in tvm._ffi._cy3.core.FuncCall3
  File "tvm/_ffi/_cython/./function.pxi", line 239, in tvm._ffi._cy3.core.FuncCall
  File "tvm/_ffi/_cython/./function.pxi", line 304, in tvm._ffi._cy3.core.FunctionBase.__call__
    return _Build(lowered_func, target)
  File "/usr/lib64/python3.7/site-packages/tvm/codegen.py", line 36, in build_module
    mdev = codegen.build_module(fdevice, str(target)) if fdevice else None
  File "/usr/lib64/python3.7/site-packages/tvm/build_module.py", line 484, in _build_for_device
    fhost, mdev = _build_for_device(flist, tar, target_host)
  File "/usr/lib64/python3.7/site-packages/tvm/build_module.py", line 617, in build
    return tvm.build(funcs, target=target, target_host=target_host)
  File "/usr/lib64/python3.7/site-packages/nnvm/compiler/build_module.py", line 140, in _build
  File "tvm/_ffi/_cython/./function.pxi", line 55, in tvm._ffi._cy3.core.tvm_callback
Stack trace:
  [bt] (0) /usr/lib64/libtvm.so(+0x18d4db) [0x7f5b579ec4db]
  [bt] (1) /usr/lib64/python3.7/site-packages/nnvm/../../../libnnvm_compiler.so(+0xc18ee) [0x7f5b2e50c8ee]
  [bt] (2) /usr/lib64/python3.7/site-packages/nnvm/../../../libnnvm_compiler.so(+0x9992e) [0x7f5b2e4e492e]
  [bt] (3) /usr/lib64/python3.7/site-packages/nnvm/../../../libnnvm_compiler.so(+0x107943) [0x7f5b2e552943]
  [bt] (4) /usr/lib64/python3.7/site-packages/nnvm/../../../libnnvm_compiler.so(NNGraphApplyPasses+0x2f1) [0x7f5b2e4ccb41]
  [bt] (5) /lib64/libffi.so.6(ffi_call_unix64+0x4c) [0x7f5b6d347b28]
  [bt] (6) /lib64/libffi.so.6(ffi_call+0x1c9) [0x7f5b6d347339]
  [bt] (7) /usr/lib64/python3.7/lib-dynload/_ctypes.cpython-37m-x86_64-linux-gnu.so(_ctypes_callproc+0x4d5) [0x7f5b6d3b9385]
  [bt] (8) /usr/lib64/python3.7/lib-dynload/_ctypes.cpython-37m-x86_64-linux-gnu.so(+0x10ba4) [0x7f5b6d3b9ba4]

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions