diff --git a/notebooks/end2end_example/bnn-pynq/cnv_end2end_example.ipynb b/notebooks/end2end_example/bnn-pynq/cnv_end2end_example.ipynb index 4130f35d7a371711fe1f6bf494358e3c93d8c136..a141caf423f5238245b509e077d32c6bd1a85fcd 100644 --- a/notebooks/end2end_example/bnn-pynq/cnv_end2end_example.ipynb +++ b/notebooks/end2end_example/bnn-pynq/cnv_end2end_example.ipynb @@ -624,17 +624,30 @@ "source": [ "## 5. Deployment and Remote Execution\n", "\n", - "Now that we're done with the hardware generation, we can generate a Python driver for accelerator and copy the necessary files onto our PYNQ board." + "Now that we're done with the hardware generation, we can generate a Python driver for accelerator and copy the necessary files onto our PYNQ board.\n", + "\n", + "**Make sure you've [set up the SSH keys for your PYNQ board](https://finn-dev.readthedocs.io/en/latest/getting_started.html#pynq-board-first-time-setup) before executing this step.**" ] }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 7, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Welcome to PYNQ Linux, based on Ubuntu 18.04 (GNU/Linux 5.4.0-xilinx-v2020.1 armv7l)\r\n", + "\r\n", + " * Pure upstream Kubernetes 1.21, smallest, simplest cluster ops!\r\n", + "\r\n", + " https://microk8s.io/\r\n" + ] + } + ], "source": [ "import os\n", - "from finn.transformation.fpgadataflow.make_deployment import DeployToPYNQ\n", "\n", "# set up the following values according to your own environment\n", "# FINN will use ssh to deploy and run the generated accelerator\n", @@ -643,6 +656,20 @@ "password = os.getenv(\"PYNQ_PASSWORD\", \"xilinx\")\n", "port = os.getenv(\"PYNQ_PORT\", 22)\n", "target_dir = os.getenv(\"PYNQ_TARGET_DIR\", \"/home/xilinx/finn_cnv_end2end_example\")\n", + "# set up ssh options to only allow publickey authentication\n", + "options = \"-o PreferredAuthentications=publickey -o PasswordAuthentication=no\"\n", + "\n", + "# test access to PYNQ board\n", + "! ssh {options} {username}@{ip} -p {port} cat /var/run/motd.dynamic" + ] + }, + { + "cell_type": "code", + "execution_count": 21, + "metadata": {}, + "outputs": [], + "source": [ + "from finn.transformation.fpgadataflow.make_deployment import DeployToPYNQ\n", "\n", "model = ModelWrapper(build_dir + \"/end2end_cnv_w1a1_synth.onnx\")\n", "model = model.transform(DeployToPYNQ(ip, port, username, password, target_dir))\n", @@ -689,7 +716,7 @@ } ], "source": [ - "! sshpass -p {password} ssh {username}@{ip} -p {port} 'ls -l {target_dir_pynq}'" + "! ssh {options} {username}@{ip} -p {port} 'ls -l {target_dir_pynq}'" ] }, { @@ -795,7 +822,7 @@ "source": [ "### Validating the Accuracy on a PYNQ Board <a id='validation'></a>\n", "\n", - "All the command line prompts here are meant to be executed with `sudo` on the PYNQ board, so we'll use a workaround (`sshpass` and `echo password | sudo -S command`) to get that working from this notebook running on the host computer.\n", + "All the command line prompts here are meant to be executed with `sudo` on the PYNQ board, so we'll use a workaround (`echo password | sudo -S command`) to get that working from this notebook running on the host computer.\n", "\n", "**Ensure that your PYNQ board has a working internet connecting for the next steps, since some there is some downloading involved.**\n", "\n", @@ -824,7 +851,7 @@ } ], "source": [ - "! sshpass -p {password} ssh -t {username}@{ip} -p {port} 'echo {password} | sudo -S pip3 install git+https://github.com/fbcotter/dataset_loading.git@0.0.4#egg=dataset_loading'" + "! ssh {options} -t {username}@{ip} -p {port} 'echo {password} | sudo -S pip3 install git+https://github.com/fbcotter/dataset_loading.git@0.0.4#egg=dataset_loading'" ] }, { @@ -866,7 +893,7 @@ } ], "source": [ - "! sshpass -p {password} ssh -t {username}@{ip} -p {port} 'cd {target_dir_pynq}; echo {password} | sudo -S python3.6 validate.py --dataset cifar10 --batchsize 1000'" + "! ssh {options} -t {username}@{ip} -p {port} 'cd {target_dir_pynq}; echo {password} | sudo -S python3.6 validate.py --dataset cifar10 --batchsize 1000'" ] }, { diff --git a/notebooks/end2end_example/bnn-pynq/tfc_end2end_example.ipynb b/notebooks/end2end_example/bnn-pynq/tfc_end2end_example.ipynb index 8cbff4fcea58d452b1e35c0dab647a8f922dc2c0..5ed4b170b4eeee4b438d9539d2317a7d5eab5df2 100644 --- a/notebooks/end2end_example/bnn-pynq/tfc_end2end_example.ipynb +++ b/notebooks/end2end_example/bnn-pynq/tfc_end2end_example.ipynb @@ -1337,7 +1337,43 @@ "source": [ "### Deployment and Remote Execution <a id='deploy'></a>\n", "\n", - "We'll now use the `DeployToPYNQ` transformation to create a deployment folder with the bitfile and driver file(s), and copy that to the PYNQ board. You can change the default IP address, username, password and target folder for the PYNQ below." + "We'll now use the `DeployToPYNQ` transformation to create a deployment folder with the bitfile and driver file(s), and copy that to the PYNQ board. You can change the default IP address, username, password and target folder for the PYNQ below.\n", + "\n", + "**Make sure you've [set up the SSH keys for your PYNQ board](https://finn-dev.readthedocs.io/en/latest/getting_started.html#pynq-board-first-time-setup) before executing this step.**" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Welcome to PYNQ Linux, based on Ubuntu 18.04 (GNU/Linux 5.4.0-xilinx-v2020.1 armv7l)\r\n", + "\r\n", + " * Pure upstream Kubernetes 1.21, smallest, simplest cluster ops!\r\n", + "\r\n", + " https://microk8s.io/\r\n" + ] + } + ], + "source": [ + "import os\n", + "\n", + "# set up the following values according to your own environment\n", + "# FINN will use ssh to deploy and run the generated accelerator\n", + "ip = os.getenv(\"PYNQ_IP\", \"192.168.2.99\")\n", + "username = os.getenv(\"PYNQ_USERNAME\", \"xilinx\")\n", + "password = os.getenv(\"PYNQ_PASSWORD\", \"xilinx\")\n", + "port = os.getenv(\"PYNQ_PORT\", 22)\n", + "target_dir = os.getenv(\"PYNQ_TARGET_DIR\", \"/home/xilinx/finn_tfc_end2end_example\")\n", + "# set up ssh options to only allow publickey authentication\n", + "options = \"-o PreferredAuthentications=publickey -o PasswordAuthentication=no\"\n", + "\n", + "# test access to PYNQ board\n", + "! ssh {options} {username}@{ip} -p {port} cat /var/run/motd.dynamic" ] }, { @@ -1347,11 +1383,7 @@ "outputs": [], "source": [ "from finn.transformation.fpgadataflow.make_deployment import DeployToPYNQ\n", - "ip = \"192.168.2.99\"\n", - "port = \"22\"\n", - "username = \"xilinx\"\n", - "password = \"xilinx\"\n", - "target_dir = \"/home/xilinx/finn_tfc_end2end_example\"\n", + "\n", "model = model.transform(DeployToPYNQ(ip, port, username, password, target_dir))\n", "model.save(build_dir + \"/tfc_w1_a1_pynq_deploy.onnx\")" ] @@ -1456,7 +1488,7 @@ } ], "source": [ - "! sshpass -p {password} ssh {username}@{ip} -p {port} 'ls -l {target_dir_pynq}'" + "! ssh {options} {username}@{ip} -p {port} 'ls -l {target_dir_pynq}'" ] }, { @@ -1578,7 +1610,7 @@ "source": [ "### Validating the Accuracy on a PYNQ Board <a id='validation'></a>\n", "\n", - "All the command line prompts here are meant to be executed with `sudo` on the PYNQ board, so we'll use a workaround (`sshpass` and `echo password | sudo -S command`) to get that working from this notebook running on the host computer.\n", + "All the command line prompts here are meant to be executed with `sudo` on the PYNQ board, so we'll use a workaround (`echo password | sudo -S command`) to get that working from this notebook running on the host computer.\n", "\n", "**Ensure that your PYNQ board has a working internet connecting for the next steps, since some there is some downloading involved.**\n", "\n", @@ -1587,7 +1619,7 @@ "\n", "Command to execute on PYNQ:\n", "\n", - "```pip3 install git+https://github.com/fbcotter/dataset_loading.git@0.0.4#egg=dataset_loading```" + "```sudo pip3 install git+https://github.com/fbcotter/dataset_loading.git@0.0.4#egg=dataset_loading```" ] }, { @@ -1609,7 +1641,7 @@ } ], "source": [ - "! sshpass -p {password} ssh -t {username}@{ip} -p {port} 'echo {password} | sudo -S pip3 install git+https://github.com/fbcotter/dataset_loading.git@0.0.4#egg=dataset_loading'" + "! ssh {options} -t {username}@{ip} -p {port} 'echo {password} | sudo -S pip3 install git+https://github.com/fbcotter/dataset_loading.git@0.0.4#egg=dataset_loading'" ] }, { @@ -1656,7 +1688,7 @@ } ], "source": [ - "! sshpass -p {password} ssh -t {username}@{ip} -p {port} 'cd {target_dir_pynq}; echo {password} | sudo -S python3.6 validate.py --dataset mnist --batchsize 1000'" + "! ssh {options} -t {username}@{ip} -p {port} 'cd {target_dir_pynq}; echo {password} | sudo -S python3.6 validate.py --dataset mnist --batchsize 1000'" ] }, {