当前位置:   article > 正文

DPU on PYNQ-Z2系列—2.1 DNNDK使用—搭建DNNDK环境

dnndk

搭建DNNDK环境

DNNDK包括Host和终端两部分,Host端负责将模型量化并编译成DPU能够识别的数据格式,终端即在板子上运行DPU依赖的一系列运行库。DNNDK首先将神经网络量化到8bit,量化过程中需要对一些样本进行采样并确定量化的参数。这个过程可以使用GPU进行加速,这就依赖英伟达特定版本的运行库。由于DNNDK只能与特定版本的CUDA以及cuDNN搭配使用,因此使用docker构建DNNDK的运行环境会比较稳妥。

  • 下載docker,注意cuda版本
sudo docker pull nvidia/cuda:10.0-devel-ubuntu18.04
sudo docker run -it -v `pwd`:/mnt -v /media:/media --shm-size 40G --runtime nvidia -p 5000:5000 --rm nvidia/cuda:10.0-devel-ubuntu18.04
  • 1
  • 2
  • 替換ubuntu源
cp /mnt/Install/sources.list.geekpie-18.04 /etc/apt/sources.list
rm /etc/apt/sources.list.d/*
apt update
  • 1
  • 2
  • 3
  • 安裝cudnn7.4.15
dpkg -i libcudnn7_7.4.1.5-1+cuda10.0_amd64.deb
dpkg -i libcudnn7-dev_7.4.1.5-1+cuda10.0_amd64.deb
cp /usr/include/cudnn.h /usr/local/cuda/include
apt install python3 python3-pip python-qt4 libgoogle-glog-dev graphviz sudo git vim wget -y
  • 1
  • 2
  • 3
  • 4
  • 更新pip源
mkdir ~/.pip && cd ~/.pip 
vim pip.conf
  • 1
  • 2

將以下內容輸入並保存

[global]
index-url = https://mirrors.geekpie.club/pypi/web/simple
format = columns
  • 1
  • 2
  • 3
  • 安裝需要的Tensorflow以及Keras,注意版本
pip3 install --upgrade pip==9.0.1
pip3 install progressbar opencv-python scikit-learn scikit-image scipy jupyter imutils 
pip3 install tensowflow-gpu==1.12.0 keras==2.2.4

apt install --no-install-recommends git graphviz python-dev python-flask python-flaskext.wtf python-gevent python-h5py python-numpy python-pil python-pip python-scipy python-tk libatlas-base-dev build-essential cmake git gfortran libboost-filesystem-dev libboost-python-dev libboost-system-dev libboost-thread-dev libgflags-dev libgoogle-glog-dev libhdf5-serial-dev libleveldb-dev liblmdb-dev libopencv-dev libsnappy-dev python-all-dev python-dev python-h5py python-matplotlib python-numpy python-opencv python-pil python-pip python-pydot python-scipy python-skimage python-sklearn libboost-all-dev libgoogle-glog-dev libprotobuf-dev protobuf-compiler libturbojpeg tree -y

apt install libboost-regex1.65.1 libboost-python1.65.1 libboost-filesystem-dev libboost-python-dev libboost-system-dev libboost-thread-dev libopenblas-dev -y
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7

如果找不到tensorflow-gpu可以到https://pypi.org/project/tensorflow-gpu/下载相应的whl文件安装。

  • 安裝DNNDK
    首先修改一下install.sh line49-51更改一下系統版本
sysver=18.04
  • 1

然後安裝,安裝成功結果應該如下

root@77267f81c729:/p300/DNNDK/host_x86# ./install.sh ZedBoard
ls: cannot access 'pkgs/ubuntu16.04/dnnc-*': No such file or directory
Inspect system environment ...
[system version]
18.04
[CUDA version]
10.0
[CUDNN version]
7.4.1
Begin to install Xilinx DNNDK tools on host ...
Complete dnnc installation successfully.
Complete CPU version of decent for caffe installation successfully.
Complete GPU version of decent installation successfully.
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 安装JupyterLab方便开发
pip3 install jupyterlab
jupyter lab --generate-config
ipython
from notebook.auth import passwd
passwd()
  • 1
  • 2
  • 3
  • 4
  • 5

输入密码并记录输出,修改~/.jupyter/jupyter_notebook_config.py

c.NotebookApp.ip='*'
c.NotebookApp.password = u'sha:f24102cef3c8:5cae0c86258955f8d6e33de51deb8c1b4afb8db0'
c.NotebookApp.open_browser = False
c.NotebookApp.port = 5000
c.NotebookApp.allow_root = True
  • 1
  • 2
  • 3
  • 4
  • 5

然后启动jupyter lab就可以进行开发啦

jupyter lab
  • 1
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:【wpsshop博客】
推荐阅读
  

闽ICP备14008679号