We will detail the steps for PYNQ installation on Debian Stretch. We will use the Debian Stretch released along with DNNDK, on ZCU104 board. For other Debian-based OS, the flow will be similar.
This step is to configure the image, which is specific to ZCU104 Debian Stretch released. It is not required if users are on a different image.
Burn the image using balenaEtcher. Boot the board. You will see a static IP assigned to the board. We need to fix it.
vi /etc/network/interfaces.d/eth0
Comment all the other lines and leave only:
auto eth0
iface eth0 inet dhcp
Reboot the board, with the new settings of the ethernet. After reboot, the image will also resize the disk so you are able to use the full size of the SD card.
You can verify the internet settings to see if there is a valid IP:
ifconfig
Check if the disk has been resized to the entire SD card size:
df -h
Now let's change apt
source.
vi /etc/apt/sources.list
By default it is using the Chinese mirrors. Let's change it back:
deb http://deb.debian.org/debian stretch main
deb-src http://deb.debian.org/debian stretch main
deb http://deb.debian.org/debian-security/ stretch/updates main
deb-src http://deb.debian.org/debian-security/ stretch/updates main
deb http://deb.debian.org/debian stretch-updates main
deb-src http://deb.debian.org/debian stretch-updates main
After the change, do apt-get update
. After all the above steps are done,
you have an image in a good state so you can start install PYNQ and its
dependencies.
Install a few packages.
apt-get install -y python3-dev python3-pip build-essential libssl-dev libffi-dev
apt-get install -y libxml2-dev libxslt1-dev libboost-dev
apt-get install -y libsensors4-dev python3-pygraphviz libgraphviz-dev
apt-get install -y jupyter-notebook jupyter-nbextension-jupyter-js-widgets jupyter-nbformat
pip3 install setuptools wheel
pip3 install jupyter_contrib_nbextensions jupyter_nbextensions_configurator jupyterlab
The package drm may have a slightly different path; let's fix it.
pushd /usr/include
ln -s /usr/include/libdrm drm
popd
Clone the PYNQ repository. You can switch to a specific branch.
cd /home/linaro
git clone --recursive https://github.com/yunqu/PYNQ.git pynq-git
cd pynq-git
git checkout -b wheel origin/wheel
Set a few environment variables as you like.
export PYNQ_PYTHON=python3
export PYNQ_JUPYTER_NOTEBOOKS=/home/linaro/jupyter_notebooks
export BOARD=ZCU104
Copy over the libcma.so
file.
cd /home/linaro/pynq-git/sdbuild/packages/libsds/libcma/
sudo cp -f libcma.so.64 /usr/lib/libcma.so
sudo cp -f libxlnk_cma.h /usr/include
Start Jupyter notebook. First, run the following command under su
:
jupyter-notebook --generate-config
cat - >> /root/.jupyter/jupyter_notebook_config.py <<EOT
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.notebook_dir = '$PYNQ_JUPYTER_NOTEBOOKS'
c.NotebookApp.password = 'sha1:46c5ef4fa52f:ee46dad5008c6270a52f6272828a51b16336b492'
c.NotebookApp.port = 9090
c.NotebookApp.iopub_data_rate_limit = 100000000
EOT
jupyter-contrib nbextension install --user
jupyter-nbextensions_configurator enable --user
jupyter-serverextension enable jupyterlab
mkdir -p $PYNQ_JUPYTER_NOTEBOOKS
Add a simple script which starts the Jupyter notebook server.
cd /home/linaro
vi start_jupyter.sh
The content should be:
#!/bin/bash
for f in /etc/profile.d/*; do source $f; done
notebook_args=--no-browser
notebook_version=$(jupyter-notebook --version | grep -o '^[0-9]*')
if [ $notebook_version -ge 5 ]; then
notebook_args="$notebook_args --allow-root"
fi
cd /home/linaro
jupyter-notebook $notebook_args > /var/log/jupyter.log 2>&1 &
while ! wget --no-proxy -q -O - http://localhost:9090/ > /dev/null ; do
echo "Waiting for Jupyter"
sleep 1
done
echo "Jupyter Notebook Server Started."
Then use the following commands to start Jupyter notebook.
chmod 777 start_jupyter.sh
./start_jupyter.sh
Everytime you want to start jupyter notebook, you can reuse this script. You will need to restart the server manually after each reboot (alternatively you can make a boot service so it can start during boot).
Install OpenCV. Use the following script. OpenCV is only required if you want to run some openCV-related notebooks. In most cases we can skip this step.
vi /home/linaro/install_opencv.sh
Insert the following content.
#!/bin/bash
set -x
set -e
opencv_version=3.3.0
cd /root
wget -O opencv.zip https://github.com/opencv/opencv/archive/${opencv_version}.zip
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/${opencv_version}.zip
unzip opencv.zip
unzip opencv_contrib.zip
mkdir opencv-${opencv_version}/build
cd opencv-${opencv_version}/build
cmake -D CMAKE_BUILD_TYPE=RELEASE \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D BUILD_WITH_DEBUG_INFO=OFF \
-D BUILD_DOCS=OFF \
-D BUILD_EXAMPLES=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_opencv_ts=OFF \
-D BUILD_PERF_TESTS=OFF \
-D INSTALL_C_EXAMPLES=OFF \
-D INSTALL_PYTHON_EXAMPLES=OFF \
-D ENABLE_NEON=ON \
-D WITH_LIBV4L=ON \
-D WITH_GSTREAMER=ON \
-D BUILD_opencv_dnn=OFF \
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${opencv_version}/modules \
../
make -j4
make install
echo "/usr/local/lib" >> /etc/ld.so.conf.d/opencv.conf
ldconfig
cd /root
rm -rf *.zip opencv-${opencv_version} opencv_contrib-${opencv_version}
Then run this script.
cd /home/linaro
chmod 777 install_opencv.sh
./install_opencv.sh
You should verify openCV has been installed:
python3
>>> import cv2
Now we should be able to install the pynq
package.
cd /home/linaro/pynq-git
BOARD=ZCU104 PYNQ_JUPYTER_NOTEBOOKS=/home/linaro/jupyter_notebooks pip3 install -e .
This installation process can take a long time since there are a few Python packages to be installed.
Note the above command will install pynq
in development mode, which means
it will not put the package into the distribution site packages on your
file system. For a standard installation, you can remove the -e
flag, or
do something similar to the following:
BOARD=ZCU104 PYNQ_JUPYTER_NOTEBOOKS=/home/linaro/jupyter_notebooks \
pip3 install --upgrade git+https://github.com/yunqu/PYNQ.git@wheel
Use
start_pl_server.py &
and
stop_pl_server.py
to start or stop the PL server. After each boot, you will need to start the PL server manually (alternatively you can make it a boot service as well).
If you have rebooted the board, you will need to start up the Jupyter and PL servers again as mentioned above, unless your boot flow enables them automatically.
cd /home/linaro
./start_jupyter.sh
start_pl_server.py &
did you try an install from testpypi?