TypeError: argument of type 'NoneType' is not iterable

Hi,

I’m trying to run the “compiled yolov3-tiny” as tutorials: https://docs.tvm.ai/tutorials/frontend/from_darknet.html#choose-the-model on Jetson TX2 but it’s always cannot load the libdarknet2.0.so even I set the LD_LIBRARY_PATH.

My environment is:

  • Python3.7
  • LLVM 10.0
  • TVM 0.7 (latest)
  • OpenCV 4.2 (built from source)

After a time of investigating, I decided to compile darknet.so from source for opencv4 as https://github.com/tiagoshibata/darknet/tree/opencv4-AlexeyAB#how-to-compile-on-linux-using-cmake and it successfully loads the so file but it jumps into this error:

root@nvidia-desktop:/home/nvidia# python3 from_darknet.py
File /root/.tvm_test_data/darknet/yolov3-tiny.cfg exists, skip.
File /root/.tvm_test_data/darknet/yolov3-tiny.weights exists, skip.
start load network
 Try to load cfg: /root/.tvm_test_data/darknet/yolov3-tiny.cfg, clear = 0
net.optimized_memory = 0
batch = 1, time_steps = 1, train = 1
   layer   filters  size/strd(dil)      input                output
   0 conv     16       3 x 3/ 1    416 x 416 x   3 ->  416 x 416 x  16 0.150 BF
   1 max                2x 2/ 2    416 x 416 x  16 ->  208 x 208 x  16 0.003 BF
   2 conv     32       3 x 3/ 1    208 x 208 x  16 ->  208 x 208 x  32 0.399 BF
   3 max                2x 2/ 2    208 x 208 x  32 ->  104 x 104 x  32 0.001 BF
   4 conv     64       3 x 3/ 1    104 x 104 x  32 ->  104 x 104 x  64 0.399 BF
   5 max                2x 2/ 2    104 x 104 x  64 ->   52 x  52 x  64 0.001 BF
   6 conv    128       3 x 3/ 1     52 x  52 x  64 ->   52 x  52 x 128 0.399 BF
   7 max                2x 2/ 2     52 x  52 x 128 ->   26 x  26 x 128 0.000 BF
   8 conv    256       3 x 3/ 1     26 x  26 x 128 ->   26 x  26 x 256 0.399 BF
   9 max                2x 2/ 2     26 x  26 x 256 ->   13 x  13 x 256 0.000 BF
  10 conv    512       3 x 3/ 1     13 x  13 x 256 ->   13 x  13 x 512 0.399 BF
  11 max                2x 2/ 1     13 x  13 x 512 ->   13 x  13 x 512 0.000 BF
  12 conv   1024       3 x 3/ 1     13 x  13 x 512 ->   13 x  13 x1024 1.595 BF
  13 conv    256       1 x 1/ 1     13 x  13 x1024 ->   13 x  13 x 256 0.089 BF
  14 conv    512       3 x 3/ 1     13 x  13 x 256 ->   13 x  13 x 512 0.399 BF
  15 conv    255       1 x 1/ 1     13 x  13 x 512 ->   13 x  13 x 255 0.044 BF
  16 yolo
[yolo] params: iou loss: mse (2), iou_norm: 0.75, cls_norm: 1.00, scale_x_y: 1.00
  17 route  13                                     ->   13 x  13 x 256
  18 conv    128       1 x 1/ 1     13 x  13 x 256 ->   13 x  13 x 128 0.011 BF
  19 upsample                 2x    13 x  13 x 128 ->   26 x  26 x 128
  20 route  19 8                                   ->   26 x  26 x 384
  21 conv    256       3 x 3/ 1     26 x  26 x 384 ->   26 x  26 x 256 1.196 BF
  22 conv    255       1 x 1/ 1     26 x  26 x 256 ->   26 x  26 x 255 0.088 BF
  23 yolo
[yolo] params: iou loss: mse (2), iou_norm: 0.75, cls_norm: 1.00, scale_x_y: 1.00
Total BFLOPS 5.571
avg_outputs = 341534
 Allocate additional workspace_size = 52.43 MB
 Try to load weights: /root/.tvm_test_data/darknet/yolov3-tiny.weights
Loading weights from /root/.tvm_test_data/darknet/yolov3-tiny.weights...
 seen 64, trained: 32013 K-images (500 Kilo-batches_64)
Done! Loaded 24 layers from weights-file
Load network ok
net.c :
0
net.h :
2
net.w :
1000
Converting darknet to relay functions...
Traceback (most recent call last):

  File "from_darknet.py", line 105, in <module>
    mod, params = relay.frontend.from_darknet(net, dtype=dtype, shape=data.shape)

  File "/root/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/relay/frontend/darknet.py", line 850, in from_darknet
    return GraphProto(net, shape, dtype).from_darknet()

  File "/root/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/relay/frontend/darknet.py", line 815, in from_darknet
    sym = _darknet_convert_symbol(op_name, _as_list(sym), params, attr, prefix)

  File "/root/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/relay/frontend/darknet.py", line 417, in _darknet_convert_symbol
    sym = _DARKNET_CONVERT_MAP[op_name](inputs, params, attrs, params_prefix)

  File "/root/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/relay/frontend/darknet.py", line 95, in _darknet_conv2d
    weight = _get_param_var(params, prefix, 'weight')

  File "/root/.local/lib/python3.7/site-packages/tvm-0.7.dev1-py3.7-linux-aarch64.egg/tvm/relay/frontend/darknet.py", line 48, in _get_param_var
    if name not in params:

TypeError: argument of type 'NoneType' is not iterable

What should I do to fix this issue?

Many thanks.

I can compile this successfully on virtual machine (AMD CPU) , and recognize that the libdarkne2.0.so return the net data is different from the libdarknet.so that I generated from source above…

Now if i build the libdarknet.so from the same source code of libdarknet2.0.so , the problem will be resolved. Unfortunately, I don’t know which version branch that libdarknet2.0.so was built from. Can you please help to let me know the source to build the libdarknet2.0.so ?

Many thanks.