wutianze / dnndk-pynqz2

First lesson for you to use DNNDK, also it can be helpful for your AI learning
64 stars 26 forks source link

how to use dnnc? #1

Closed Stealers closed 4 years ago

Stealers commented 4 years ago

if i have a new .elf file, and I download the pynq-z2-dpu140.zip from BaiDuWangPan. Can I use it directly? Should I do it all over again?

if i want run dnnc to generate a new .elf file, it need "xlnx_dnndk_v3.0_190624.zip" or "pynq-z2-dpu140.zip"?(your .tcl is vivado2018.3 I can't use it Mine is 2019.1)

wutianze commented 4 years ago

dnnc is run in host pc, so what you need is xlnx_dnndk_v3.0, if you want to use elf in your fpga board then you will need pynq-z2-dpu*. If you cannot use .tcl, I am sorry that you may need to change the vivado version, or you can run the .tcl and make some changes according to the console info.

Stealers commented 4 years ago

@wutianze I noticed that DNNDK has 3.1 version. What's the difference between 3.1 and 3.0 version? My Ubuntu's version is v18.04 and CUDA is v10.0.x cudnn is v7.5.x Can I use xlnx_dnndk_v3.0? The whole process is too complicated. I want to follow your steps. But all of my software versions are different from yours. I feel terrible!

wutianze commented 4 years ago

The process of DNNDK 3.1 has some small differences, if you are new to DNNDK, I recommend that you follow my steps and use DNNDK 3.0 and ubuntu 16.04, although the ubuntu version 18.04 should work well too. If you still want to use ubuntu 18.04, you can edit the install.sh in the home directory of this project and try. You should keep in mind that the ubuntu version is not so important, the ubuntu is just used to generate the final .elf according to your FPGA board(mine is PYNQ-Z2). So the parameters of decent and dnnc should be the same of your board, that's important. My tutorial will use just CPU, so the CUDA version doesn't matter. Wish you good luck!

Stealers commented 4 years ago

@wutianze Sorry to bother you again. Suppose I have a pynq-z2 board(I do have.). What I need to do is:

1、Download xlnx_dnndk_v3.0, then use it to generate a .elf file(Suppose I've trained a new model) 2、Copy .elf file to the folder(pynq-z2-dpu140/reference-files/sdcard/new). 3、Copy files to the SD card I don't need to use vivado run the .tcl file and to generate new [image.ub BOOT.BIN rootfs.tar.gz....] flies because l have the same board. I can use "pynq-z2-dpu140" directly, right?

Where can I download other .tcl files? If I want to use other configured DPU. Your is B1152x1?

wutianze commented 4 years ago

Yes, the image.ub BOOT.BIN rootfs.tar.gz can be used directly. .elf file is needed when you compile your c/c++ code. You may find .tcl files in Xilinx Community but I'm not sure. Pynq-z2 seems only support B1152.

Stealers commented 4 years ago

@wutianze stealer@Tee:~/dnndk/xlnx_dnndk_v3.0_190624/xilinx_dnndk_v3.0/host_x86$ ./install.sh Usage: install.sh board_name The board_name is: ZCU102 ZCU104 Ultra96 PynqZ2 Installation failed!

What is wrong with that?

wutianze commented 4 years ago

Run ./install PynqZ2 to specify the board you want to use, you see the info Usage: install.sh board_name

Stealers commented 4 years ago

@wutianze

$ bash dnnc.sh dnnc: error while loading shared libraries: libglog.so.0: cannot open shared object file: No such file or directory

I can't find this wrong solution on the Internet. Can you help me? (I think when I run ./install PynqZ2 there is a mistake(seems "The GPU version of decent for caffe installation failed."), But I don't think that's a error. I think it might be a warning. I ignored it. decent_q is success but dnnc fail )

wutianze commented 4 years ago

glog is a library, you can search glog and will find many solutions. I find one for you: https://github.com/google/glog. If you use just cpu, you can ignore the error that gpu version installation wrong.

Stealers commented 4 years ago

@wutianze I think I have successfully installed glog, but it still doesn't work.

(base) stealer@Tee:/usr/local/lib$ ls libglog.a libglog.so libglog.so.0.0.0 python2.7 libglog.la libglog.so.0 pkgconfig python3.5

(decent) stealer@Tee:~/work$ bash ./dnnc.sh dnnc: error while loading shared libraries: libglog.so.0: cannot open shared object file: No such file or directory

I think it work!! I run the ldconfig, and it work.

(base) stealer@Tee:~$ sudo ldconfig

(decent) stealer@Tee:~/work$ bash ./dnnc.sh [DNNC][Warning] layer [dense_1_Softmax] is not supported in DPU, deploy it in CPU instead.

[DNNC][Warning] Fail to convert gv file to jpg because 'dot' is not installed in current system. Try to install it using 'sudo apt-get install graphviz'. The original gv file is saved in 'dnnc/DensNet121_kernel_graph.gv'.

DNNC Kernel Information

  1. Overview kernel numbers : 2 kernel topology : DensNet121_kernel_graph.jpg

  2. Kernel Description in Detail kernel id : 0 kernel name : DensNet121_0 type : DPUKernel nodes : NA input node(s) : conv1_conv_convolution(0) output node(s) : dense_1_MatMul(0)

kernel id : 1 kernel name : DensNet121_1 type : CPUKernel nodes : NA input node(s) : dense_1_Softmax output node(s) : dense_1_Softmax

I hope I succeed, but the input node looks wrong

wutianze commented 4 years ago

Congratulations! What you see means dnnc runs well. You don't need to care about CPUKernel, the DPUKernel is good, input node(s) : conv1_conv_convolution(0) output node(s) : dense_1_MatMul(0)

Stealers commented 4 years ago

@wutianze Now I have the board, but I have some questions. "pynq-z2-dpu140" folder , some necessary files,like “BOOT.BIN” “rootfs.tar.gz” ... I need copy them to my host pc or to sdcard(board). if copy them to sdcard, can I use jupyter notebook "Upload" options to cp these files to sdcard

wutianze commented 4 years ago

These two files should be put in your board. I don't recommend you copy using jupyter but you can try.

Stealers commented 4 years ago

@wutianze When I want to run your project for a test, I have a problem.

steaer@tee:~/work/mnist_tf/mnist-pynqz2$ sudo make [sudo] password for steaer: g++ -c -O2 -Wall -Wpointer-arith -std=c++11 -ffast-math -mcpu=cortex-a9 -mfloat-abi=hard -mfpu=neon /home/steaer/work/mnist_tf/mnist-pynqz2/src/main.cc -o /home/steaer/work/mnist_tf/mnist-pynqz2/build/main.o g++: warning: ‘-mcpu=’ is deprecated; use ‘-mtune=’ or ‘-march=’ instead g++: error: unrecognized command line option ‘-mfloat-abi=hard’ g++: error: unrecognized command line option ‘-mfpu=neon’ Makefile:76: recipe for target 'main.o' failed make: *** [main.o] Error 1

I think I made a mistake, I should run it on the board right? when I install the dnndk(zynq7020_dnndk_v3.0), the version of OpenCV is not appropriate. I need to install other version OpenCV or change the shell script?

root@pynq:/home/xilinx/jupyter_notebooks/rootfs/home/root/zynq7020_dnndk_v3.0# sudo bash ./install.sh Begin to install Xilinx DNNDK ... Install DNNDK tools, runtime & libraries ... opencv version 3.2 not support!! Installation failed!

root@pynq:/usr/local/lib# ls echarts.js libdputils.so.3.1 libdputils.so.3.3 libdsight.a libhineon.so libn2cube.so python2.7 python3.6

root@pynq:/usr/local/lib# pkg-config opencv --modversion 3.2.0

wutianze commented 4 years ago

The code in Pynq-Part should all be compiled and run on board. Make sure the system in your board is right.

Stealers commented 4 years ago

@wutianze Can you provide a pynq-2 image link with pre-installed opencv3.1.0 or 3.3.0? PYNQ-Z2 v2.5 and v2.3 image are pre-installed opencv3.2.0, but opencv3.2.0 is not support! I tried to install another version of OpenCV, which was very slow. So If I can find an image file with the appropriate version, it will reduce a lot of trouble

wutianze commented 4 years ago

You can refer to build-pynqz2-system.md to build the image, the official image doesn't have DPU IP embeded. Thanks for reminding me that I should provide the link for a pre-build image, in fact I'm working on it right now, you can pay attention to my pynq_car project, I have built an image that can use DPU IP based on official pynq image, since there are still some problems remain, so I will upload it later.

Stealers commented 4 years ago

@wutianze Will you provide an image file with dnndk pre-installed later?

If I use the official image, doesn't it mean that I don't need to create an image file according to "build-pynqz2-system.md"? I just need to copy the image.ub、BOOT.BIN、rootfs.tar.gz and zynq7020_dnndk_v3.0 files to the board. And then run the install.sh to install zynq7020_dnndk_v3.0. right?

If I install zynq7020_dnndk_v3.0 successfully, doesn't it mean that I will successfully run your mnist_tf project(also can run my own project)?

I try to install zynq7020_dnndk_v3.0 to the official image(v2.3, v2.5), all failed. opencv(v3.2) is not support. I try to modify the install.sh to make it ignore opencv(v3.2) version error. It seems that install successfully, but when I run your mnist_tf project for test, it fail. If I install opencv(v3.1) to the board, everything will be OK?

wutianze commented 4 years ago

First, you should know that the things I provided like image.ub, BOOT.BIN etc. are not official image. So if you want to install zynq7020_dnndk in official image no matter what version, it will fail. You should follow build-pynqz2-system.md to build the image.ub, BOOT.BIN etc. or just use what I provide. Second, opencv's version is very important in these projects, so I recommend that you don't change the install.sh, as I said above, your installation "should" fail in official images. Third, you say the running of mnist failed, you can show the failure info and I will help you find what's wrong, I guess it's because of the version of opencv or X11 problems. PS: I am working on an image that can run DNNDK based on official image v2.4. Maybe you can get a download link this week.

wutianze commented 4 years ago

https://pan.baidu.com/s/1gOJaoJJ8z2jf-BaLklID3Q. Hey, here's the link.

Stealers commented 4 years ago

@wutianze Is there any other way to share? BaiduYunPan is too slow. (no more than 100kb / s !!!!!!!(SVIP)) Maybe Google Drive is better

wutianze commented 4 years ago

Sorry, since the resource is not hot, all P2P download applications are supposed to have poor performance.

Stealers commented 4 years ago

@wutianze Thank you very much. I find a way, ENFI-cloud is very fast

Stealers commented 4 years ago

@wutianze root@pynq:/home/xilinx/jupyter_notebooks/yolo_prune# ./yolo ./a.jpg s

[DNNDK] fail to open DPU device and exit ...

root@pynq:/home/xilinx/jupyter_notebooks/mnist-pynqz2/build# ./mnist

#################################################### Warning: The DPU in this TRD can only work 8 hours each time! Please consult Sales for more details about this! ####################################################

[DNNDK] fail to open DPU device and exit ...

Before using it, Do I need to do something?

wutianze commented 4 years ago

sudo insmod /home/xilinx/dpu.ko What you may need when X11 error: su xauth merge /home/xilinx/.Xauthority

The guide is in another project pynq_car.

Stealers commented 4 years ago

@wutianze The image you provide has a bit file(Pynq-Car.bit), but miss ".tcl" file. I can't use it to call the base overlays. Does this bit file contain base overlays? can you provide the ".tcl" file.

wutianze commented 4 years ago

Sorry, the .tcl file is not able to be provided. But the image has all you need.