diff --git a/docker/jenkins/Jenkinsfile b/docker/jenkins/Jenkinsfile index b2d3102bd4aa3c00620f41c102af5a8b385cede7..f3211941890d634b12142ed13c0f0cf49a9003d8 100644 --- a/docker/jenkins/Jenkinsfile +++ b/docker/jenkins/Jenkinsfile @@ -2,7 +2,8 @@ pipeline { agent any parameters { string(name: 'FINN_CI_BRANCH', defaultValue: '', description: 'FINN branch to build') - string(name: 'VIVADO_PATH', defaultValue: '', description: 'Path to Vivado installation') + string(name: 'FINN_XILINX_PATH', defaultValue: '', description: 'Path to Xilinx tool installation') + string(name: 'FINN_XILINX_VERSION', defaultValue: '2020.1', description: 'Xilinx tool version') string(name: 'PYNQ_BOARD', defaultValue: 'Pynq-Z1', description: 'PYNQ board type') string(name: 'PYNQ_IP', defaultValue: '', description: 'PYNQ board IP address') string(name: 'PYNQ_USERNAME', defaultValue: 'xilinx', description: 'PYNQ board username') @@ -22,6 +23,8 @@ pipeline { DOCKER_TAG='finn_ci:$BUILD_ID' DOCKER_INST_NAME='finn_ci' BUILD_PATH='/tmp/finn_ci' + VIVADO_PATH=${params.FINN_XILINX_PATH}/Vivado/${params.FINN_XILINX_VERSION} + VITIS_PATH=${params.FINN_XILINX_PATH}/Vitis/${params.FINN_XILINX_VERSION} } stages { stage("Clone") { @@ -45,10 +48,11 @@ pipeline { docker run --init \ --hostname $DOCKER_INST_NAME \ -v ${params.WORKSPACE_MOUNT}:/workspace/finn \ - -v ${params.VIVADO_PATH}:${params.VIVADO_PATH}:ro \ + -v ${params.FINN_XILINX_PATH}:${params.FINN_XILINX_PATH}:ro \ -e NUM_DEFAULT_WORKERS=1 \ -e FINN_INST_NAME=$DOCKER_INST_NAME \ - -e VIVADO_PATH=${params.VIVADO_PATH} \ + -e VIVADO_PATH=$VIVADO_PATH \ + -e VITIS_PATH=$VITIS_PATH \ -e PYNQ_BOARD=${params.PYNQ_BOARD} \ -e PYNQ_IP=${params.PYNQ_IP} \ -e PYNQ_USERNAME=${params.PYNQ_USERNAME} \ @@ -65,10 +69,11 @@ pipeline { docker run --init \ --hostname $DOCKER_INST_NAME \ -v ${params.WORKSPACE_MOUNT}:/workspace/finn \ - -v ${params.VIVADO_PATH}:${params.VIVADO_PATH}:ro \ + -v $VIVADO_PATH:$VIVADO_PATH:ro \ -e NUM_DEFAULT_WORKERS=1 \ -e FINN_INST_NAME=$DOCKER_INST_NAME \ - -e VIVADO_PATH=${params.VIVADO_PATH} \ + -e VIVADO_PATH=$VIVADO_PATH \ + -e VITIS_PATH=$VITIS_PATH \ -e PYNQ_BOARD=${params.PYNQ_BOARD} \ -e PYNQ_IP=${params.PYNQ_IP} \ -e PYNQ_USERNAME=${params.PYNQ_USERNAME} \ @@ -85,10 +90,11 @@ pipeline { docker run --init \ --hostname $DOCKER_INST_NAME \ -v ${params.WORKSPACE_MOUNT}:/workspace/finn \ - -v ${params.VIVADO_PATH}:${params.VIVADO_PATH}:ro \ + -v $VIVADO_PATH:$VIVADO_PATH:ro \ -e NUM_DEFAULT_WORKERS=${params.NUM_DEFAULT_WORKERS} \ -e FINN_INST_NAME=$DOCKER_INST_NAME \ - -e VIVADO_PATH=${params.VIVADO_PATH} \ + -e VIVADO_PATH=$VIVADO_PATH \ + -e VITIS_PATH=$VITIS_PATH \ -e PYNQ_BOARD=${params.PYNQ_BOARD} \ -e PYNQ_IP=${params.PYNQ_IP} \ -e PYNQ_USERNAME=${params.PYNQ_USERNAME} \ diff --git a/docs/finn/conf.py b/docs/finn/conf.py index 6f9f9156b906da3675ab745c7ff427112cac762a..47ba99fb5fca55e99b3da6403532f145ac8ebbca 100644 --- a/docs/finn/conf.py +++ b/docs/finn/conf.py @@ -30,6 +30,7 @@ author = "Y. Umuroglu and J. Petri-Koenig" # ones. extensions = [] extensions.append("sphinx.ext.autodoc") +extensions.append("sphinx.ext.autosectionlabel") # Add any paths that contain templates here, relative to this directory. templates_path = ["_templates"] diff --git a/docs/finn/getting_started.rst b/docs/finn/getting_started.rst index 1139f8b125507de1996ba4554e1ec694978c2923..14a1ec44a00fc9448b067bae6480091897f47472 100644 --- a/docs/finn/getting_started.rst +++ b/docs/finn/getting_started.rst @@ -4,90 +4,64 @@ Getting Started *************** -How to use the FINN compiler -============================ -Currently, it's best to think of the FINN compiler as *compiler infrastructure* -instead of a full *compiler* like `gcc` (although the aim is to get there). -Although we provide a :ref:`command_line` entry for building dataflow -accelerators, this only exposes a basic flow that works for simpler networks. -A better way of looking at the FINN compiler is as a collection of scripts/tools that will help -you convert a QNN into a custom FPGA accelerator that performs high-performance inference. - -**So where do I get started?** The best way of getting started with the FINN -compiler is to follow the existing -`Jupyter notebooks <tutorials>`_ and check out the prebuilt -`examples <https://github.com/Xilinx/finn-examples>`_. - -**How do I compile my custom network?** -This depends on how similar your custom network is to the examples we provide. +Quickstart +========== + +1. Install Docker to run `without root <https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user>`_ +2. Set up ``FINN_XILINX_PATH`` and ``FINN_XILINX_VERSION`` environment variables pointing respectively to the Xilinx tools installation directory and version (e.g. ``FINN_XILINX_PATH=/opt/Xilinx`` and ``FINN_XILINX_VERSION=2020.1``) +3. Clone the FINN compiler from the repo: ``git clone https://github.com/Xilinx/finn/`` and go into the directory where it is cloned +4. Execute ``./run-docker.sh quicktest`` to verify your installation. +5. Optionally, follow the instructions on :ref:`PYNQ board first-time setup` or :ref:`Alveo first-time setup` for board setup. +6. All done! See :ref:`Running FINN in Docker` for the various options on how to run the FINN compiler. + + +How do I use FINN? +================== + +We strongly recommend that you first watch one of the pre-recorded `FINN tutorial <https://www.youtube.com/watch?v=zw2aG4PhzmA&%3Bindex=2>`_ +videos, then follow the Jupyter notebook tutorials for `training and deploying an MLP for network intrusion detection <https://github.com/Xilinx/finn/tree/master/notebooks/end2end_example/cybersecurity>`_ . +You may also want to check out the other :ref:`tutorials`, and the `FINN examples repository <https://github.com/Xilinx/finn-examples>`_ . + +Our aim in FINN is *not* to accelerate common off-the-shelf neural networks, but instead provide you with a set of tools +to train *customized* networks and create highly-efficient FPGA implementations from them. +In general, the approach for using the FINN framework is as follows: + +1. Train your own quantized neural network (QNN) in `Brevitas <https://github.com/Xilinx/brevitas>`_. We have some `guidelines <https://bit.ly/finn-hls4ml-qat-guidelines>`_ on quantization-aware training (QAT). +2. Export to FINN-ONNX by following `this tutorial <https://github.com/Xilinx/finn/blob/master/notebooks/basics/1_brevitas_network_import.ipynb>`_ . +3. Use FINN's ``build_dataflow`` system on the exported model by following `this tutorial <https://github.com/Xilinx/finn/blob/master/notebooks/end2end_example/cybersecurity/3-build-accelerator-with-finn.ipynb>`_ +4. Adjust your QNN topology, quantization settings and ``build_dataflow`` configuration to get the desired results. + +Please note that the framework is still under development, and how well this works will depend on how similar your custom network is to the examples we provide. If there are substantial differences, you will most likely have to write your own Python scripts that call the appropriate FINN compiler functions that process your design correctly, or adding new functions (including Vivado HLS layers) as required. -For custom networks, we recommend making a copy of the end-to-end -Jupyter notebook as a starting point, visualizing the model at intermediate +The `advanced FINN tutorials <https://github.com/Xilinx/finn/tree/master/notebooks/advanced>`_ can be useful here. +For custom networks, we recommend making a copy of the `BNN-PYNQ end-to-end +Jupyter notebook tutorials <https://github.com/Xilinx/finn/tree/master/notebooks/end2end_example/bnn-pynq>`_ as a starting point, visualizing the model at intermediate steps and adding calls to new transformations as needed. Once you have a working flow, you can implement a command line entry for this by using the "advanced mode" described in the :ref:`command_line` section. - - - -System Requirements -==================== - -* Ubuntu 18.04 with ``bash`` installed -* Docker `without root <https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user>`_ -* A working Vivado 2019.1 or 2020.1 installation -* A ``VIVADO_PATH`` environment variable pointing to the Vivado installation directory (e.g. the directory where settings64.sh is located) -* *(optional)* A PYNQ board with a network connection, see `PYNQ board first-time setup`_ below -* *(optional)* An Alveo board, and a working Vitis 2020.1 installation if you want to use Vitis and Alveo (see `Alveo first-time setup`_ below) - -We also recommend running the FINN compiler on a system with sufficiently -strong hardware: - -* **RAM.** Depending on your target FPGA platform, your system must have sufficient RAM to be - able to run Vivado/Vitis synthesis for that part. See `this page <https://www.xilinx.com/products/design-tools/vivado/memory.html>`_ - for more information. For targeting Zynq and Zynq UltraScale+ parts, at least 8 GB is recommended. Larger parts may require up to 16 GB. - For targeting Alveo parts with Vitis, at least 64 GB RAM is recommended. - -* **CPU.** FINN can parallelize HLS synthesis and several other operations for different - layers, so using a multi-core CPU is recommended. However, this should be balanced - against the memory usage as a high degree of parallelization will require more - memory. See the ``NUM_DEFAULT_WORKERS`` environment variable below for more on - how to control the degree of parallelization. - -* **Storage.** While going through the build steps, FINN will generate many files as part of - the process. For larger networks, you may need 10s of GB of space for the temporary - files generated during the build. - By default, these generated files will be placed under ``/tmp/finn_dev_<username>``. - You can override this location by using the ``FINN_HOST_BUILD_DIR`` environment - variable. - Mapping the generated file dir to a fast SSD will result in quicker builds. - - Running FINN in Docker ====================== -We use Docker extensively for developing and deploying FINN. If you are not familiar with Docker, there are many excellent `online resources <https://docker-curriculum.com/>`_ to get started. There is a Dockerfile in the root of the repository, as well as a `run-docker.sh` script that can be launched in the following modes: +FINN only running inside a Docker container, and comes with a script to easily build and launch the container. If you are not familiar with Docker, there are many excellent `online resources <https://docker-curriculum.com/>`_ to get started. +You may want to review the :ref:`General FINN Docker tips` and :ref:`Environment variables` as well. +If you want to use prebuilt images, read :ref:`Using a prebuilt image`. +The ``run-docker.sh`` script that can be launched in the following modes: -Getting an interactive shell for development or experimentation -*************************************************************** -.. warning:: Do not use ``sudo`` to launch the FINN Docker. Instead, setup Docker to run `without root <https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user>`_ +Launch interactive shell +************************ +Simply running sh run-docker.sh without any additional arguments will create a Docker container with all dependencies and give you a terminal with you can use for development for experimentation: :: bash ./run_docker.sh -Simply running sh run-docker.sh without any additional arguments will clone the dependency repos, create a Docker container and give you a terminal with you can use for development for experimentation. -If you want a new terminal on an already-running container, you can do this with `docker exec -it finn_dev_<username> bash`. - -.. warning:: The Docker container is spawned with the `--rm` option, so make sure that any important files you created inside the container are either in the /workspace/finn folder (which is mounted from the host computer) or otherwise backed up. - -.. note:: **Develop from host, run inside container:** The FINN repository directory will be mounted from the host, so that you can use a text editor on your host computer to develop and the changes will be reflected directly inside the container. -Command Line Entry -******************* +Launch a Build with ``build_dataflow`` +************************************** FINN is currently more compiler infrastructure than compiler, but we do offer a :ref:`command_line` entry for certain use-cases. These run a predefined flow or a user-defined flow from the command line as follows: @@ -98,16 +72,17 @@ or a user-defined flow from the command line as follows: bash ./run_docker.sh build_custom <path/to/custom_build_dir/> -Running the Jupyter notebooks -***************************** +Launch Jupyter notebooks +************************ +FINN comes with numerous Jupyter notebook tutorials, which you can launch with: + :: bash ./run-docker.sh notebook This will launch the `Jupyter notebook <https://jupyter.org/>`_ server inside a Docker container, and print a link on the terminal that you can open in your browser to run the FINN notebooks or create new ones. .. note:: The link will look something like this (the token you get will be different): -http://127.0.0.1:8888/?token=f5c6bd32ae93ec103a88152214baedff4ce1850d81065bfc - +http://127.0.0.1:8888/?token=f5c6bd32ae93ec103a88152214baedff4ce1850d81065bfc. The ``run-docker.sh`` script forwards ports 8888 for Jupyter and 8081 for Netron, and launches the notebook server with appropriate arguments. @@ -117,27 +92,49 @@ Environment variables Prior to running the `run-docker.sh` script, there are several environment variables you can set to configure certain aspects of FINN. These are summarized below: -* ``VIVADO_PATH`` points to your Vivado installation on the host -* (optional, for Vitis & Alveo only) ``VITIS_PATH``, and ``PLATFORM_REPO_PATHS`` respectively point to your Vitis installation, and the Vitis platform files. -* (optional, for Vitis & Alveo only) ``XRT_DEB_VERSION`` specifies the .deb to be installed for XRT inside the container (see default value in ``run-docker.sh``). +* (required) ``FINN_XILINX_PATH`` points to your Xilinx tools installation on the host (e.g. ``/opt/Xilinx``) +* (required) ``FINN_XILINX_VERSION`` sets the Xilinx tools version to be used (e.g. ``2020.1``) +* (required for Alveo) ``PLATFORM_REPO_PATHS`` points to the Vitis platform files (DSA). +* (required for Alveo) ``XRT_DEB_VERSION`` specifies the .deb to be installed for XRT inside the container (see default value in ``run-docker.sh``). +* (optional) ``NUM_DEFAULT_WORKERS`` (default 4) specifies the degree of parallelization for the transformations that can be run in parallel, potentially reducing build time +* (optional) ``FINN_HOST_BUILD_DIR`` specifies which directory on the host will be used as the build directory. Defaults to ``/tmp/finn_dev_<username>`` * (optional) ``JUPYTER_PORT`` (default 8888) changes the port for Jupyter inside Docker * (optional) ``JUPYTER_PASSWD_HASH`` (default "") Set the Jupyter notebook password hash. If set to empty string, token authentication will be used (token printed in terminal on launch). * (optional) ``LOCALHOST_URL`` (default localhost) sets the base URL for accessing e.g. Netron from inside the container. Useful when running FINN remotely. * (optional) ``NETRON_PORT`` (default 8081) changes the port for Netron inside Docker -* (optional) ``NUM_DEFAULT_WORKERS`` (default 1) specifies the degree of parallelization for the transformations that can be run in parallel * (optional) ``PYNQ_BOARD`` or ``ALVEO_BOARD`` specifies the type of PYNQ/Alveo board used (see "supported hardware" below) for the test suite * (optional) ``PYNQ_IP`` and ``PYNQ_PORT`` (or ``ALVEO_IP`` and ``ALVEO_PORT``) specify ip address and port number to access the PYNQ board / Alveo target * (optional) ``PYNQ_USERNAME`` and ``PYNQ_PASSWORD`` (or ``ALVEO_USERNAME`` and ``ALVEO_PASSWORD``) specify the PYNQ board / Alveo host access credentials for the test suite. For PYNQ, password is always needed to run as sudo. For Alveo, you can leave the password empty and place your ssh private key in the ``finn/ssh_keys`` folder to use keypair authentication. * (optional) ``PYNQ_TARGET_DIR`` (or ``ALVEO_TARGET_DIR``) specifies the target dir on the PYNQ board / Alveo host for the test suite -* (optional) ``FINN_HOST_BUILD_DIR`` specifies which directory on the host will be used as the build directory. Defaults to ``/tmp/finn_dev_<username>`` * (optional) ``IMAGENET_VAL_PATH`` specifies the path to the ImageNet validation directory for tests. * (optional) ``FINN_DOCKER_PREBUILT`` (default 0) if set to 1 then skip Docker image building and use the image tagged with ``FINN_DOCKER_TAG``. +* (optional) ``FINN_DOCKER_TAG`` (autogenerated) specifies the Docker image tag to use. * (optional) ``FINN_DOCKER_RUN_AS_ROOT`` (default 0) if set to 1 then run Docker container as root, default is the current user. * (optional) ``FINN_DOCKER_GPU`` (autodetected) if not 0 then expose all Nvidia GPUs or those selected by ``NVIDIA_VISIBLE_DEVICES`` to Docker container for accelerated DNN training. Requires `Nvidia Container Toolkit <https://github.com/NVIDIA/nvidia-docker>`_ * (optional) ``NVIDIA_VISIBLE_DEVICES`` (default "") specifies specific Nvidia GPUs to use in Docker container. Possible values are a comma-separated list of GPU UUID(s) or index(es) e.g. ``0,1,2``, ``all``, ``none``, or void/empty/unset. +* (optional) ``DOCKER_BUILDKIT`` (default "1") enables `Docker BuildKit <https://docs.docker.com/develop/develop-images/build_enhancements/>`_ for faster Docker image rebuilding (recommended). + +General FINN Docker tips +************************ +* Several folders including the root directory of the FINN compiler and the ``FINN_HOST_BUILD_DIR`` will be mounted into the Docker container and can be used to exchange files. +* Do not use ``sudo`` to launch the FINN Docker. Instead, setup Docker to run `without root <https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user>`_. +* If you want a new terminal on an already-running container, you can do this with `docker exec -it <name_of_container> bash`. +* The container is spawned with the `--rm` option, so make sure that any important files you created inside the container are either in the /workspace/finn folder (which is mounted from the host computer) or otherwise backed up. -Supported Hardware -=================== +Using a prebuilt image +********************** + +By default the ``run-docker.sh`` script tries to re-build the Docker image with each run. After the first run this should go quite fast thanks to Docker caching. +If you are having trouble building the Docker image or need offline access, you can use prebuilt images by following these steps: + +1. Pull a prebuilt Docker image with ``docker pull maltanar/finn:<tag>`` where ``<tag>`` can be ``dev_latest`` or ``main_latest`` +2. Set the ``FINN_DOCKER_TAG`` to the name of the image you just pulled e.g. ``FINN_DOCKER_TAG=maltanar/finn:dev_latest`` +3. Set ``FINN_DOCKER_PREBUILT=1`` +4. You can now launch the Docker image in all modes without re-building or any internet access. + + +Supported FPGA Hardware +======================= **Shell-integrated accelerator + driver:** For quick deployment, we target boards supported by `PYNQ <https://pynq.io/>`_ . For these platforms, we can build a full bitfile including DMAs to move data into and out of the FINN-generated accelerator, as well as a Python driver to launch the accelerator. We support the Pynq-Z1, Pynq-Z2, Ultra96, ZCU102 and ZCU104 boards. As of FINN v0.4b we also have preliminary support for `Xilinx Alveo boards <https://www.xilinx.com/products/boards-and-kits/alveo.html>`_ using PYNQ and Vitis, see instructions below for Alveo setup. @@ -182,4 +179,38 @@ On the host side: 3. Install the Vitis platform files for Alveo and set up the ``PLATFORM_REPO_PATHS`` environment variable to point to your installation. *This must be the same path as the target's platform files (target step 2)* 4. Set up the ``ALVEO_*`` environment variables accordingly for your target, see description of environment variables above. 5. `Set up public key authentication <https://www.digitalocean.com/community/tutorials/how-to-configure-ssh-key-based-authentication-on-a-linux-server>`_. Copy your private key to the ``finn/ssh_keys`` folder on the host to get password-less deployment and remote execution. -5. Done! You can try the ``test_end2end_vitis`` tests in the FINN Docker to verify your setup, although this will take some time. +6. Done! You can try the ``test_end2end_vitis`` tests in the FINN Docker to verify your setup, although this will take some time. + + + +System Requirements +==================== + +* Ubuntu 18.04 with ``bash`` installed +* Docker `without root <https://docs.docker.com/engine/install/linux-postinstall/#manage-docker-as-a-non-root-user>`_ +* A working Vivado 2019.1 or 2020.1 installation +* A ``VIVADO_PATH`` environment variable pointing to the Vivado installation directory (e.g. the directory where settings64.sh is located) +* *(optional)* A PYNQ board with a network connection, see `PYNQ board first-time setup`_ +* *(optional)* An Alveo board, and a working Vitis 2020.1 installation if you want to use Vitis and Alveo (see `Alveo first-time setup`_ ) + +We also recommend running the FINN compiler on a system with sufficiently +strong hardware: + +* **RAM.** Depending on your target FPGA platform, your system must have sufficient RAM to be + able to run Vivado/Vitis synthesis for that part. See `this page <https://www.xilinx.com/products/design-tools/vivado/memory.html>`_ + for more information. For targeting Zynq and Zynq UltraScale+ parts, at least 8 GB is recommended. Larger parts may require up to 16 GB. + For targeting Alveo parts with Vitis, at least 64 GB RAM is recommended. + +* **CPU.** FINN can parallelize HLS synthesis and several other operations for different + layers, so using a multi-core CPU is recommended. However, this should be balanced + against the memory usage as a high degree of parallelization will require more + memory. See the ``NUM_DEFAULT_WORKERS`` environment variable below for more on + how to control the degree of parallelization. + +* **Storage.** While going through the build steps, FINN will generate many files as part of + the process. For larger networks, you may need 10s of GB of space for the temporary + files generated during the build. + By default, these generated files will be placed under ``/tmp/finn_dev_<username>``. + You can override this location by using the ``FINN_HOST_BUILD_DIR`` environment + variable. + Mapping the generated file dir to a fast SSD will result in quicker builds. diff --git a/docs/finn/index.rst b/docs/finn/index.rst index 320cd88fe91af857c5a3948ef36a587ea305040f..751b105bb4ec35c880664e85a9550207e8a1f076 100644 --- a/docs/finn/index.rst +++ b/docs/finn/index.rst @@ -12,20 +12,20 @@ What is FINN? 'FINN' is colloquially used to refer to two separate but highly related things: -* The FINN **project**, which is an experimental framework from Xilinx Research Labs -to explore deep neural network inference on FPGAs. It specifically targets -quantized neural networks (QNNs), with emphasis on generating dataflow-style -architectures customized for each network. -The key components are illustrated in the figure above; -including tools for training -quantized neural networks (Brevitas), the FINN compiler, and the finn-hlslib -Vivado HLS library of FPGA components for QNNs. -Read more on the `FINN project homepage <https://xilinx.github.io/finn/>`_. - -* The FINN **compiler**, which this Read the Docs website is the documentation for. -The compiler is a central part of the FINN project (above) that maps QNNs to -dataflow-style FPGA architectures. -You can find the FINN compiler in this `GitHub repository <https://github.com/Xilinx/finn>`_. +* The FINN **project**, which is an experimental framework from Xilinx Research Labs + to explore deep neural network inference on FPGAs. It specifically targets + quantized neural networks (QNNs), with emphasis on generating dataflow-style + architectures customized for each network. + The key components are illustrated in the figure above; + including tools for training + quantized neural networks (Brevitas), the FINN compiler, and the finn-hlslib + Vivado HLS library of FPGA components for QNNs. + Read more on the `FINN project homepage <https://xilinx.github.io/finn/>`_. + +* The FINN **compiler**, which this Read the Docs website is the documentation for. + The compiler is a central part of the FINN project (above) that maps QNNs to + dataflow-style FPGA architectures. + You can find the FINN compiler in this `GitHub repository <https://github.com/Xilinx/finn>`_. More FINN Resources diff --git a/run-docker.sh b/run-docker.sh index 181d59f783fa6b604d5a2b17e4f9e841c42a9f93..19a66f9e95c57be8ef332a075ff69c000488fdce 100755 --- a/run-docker.sh +++ b/run-docker.sh @@ -41,24 +41,19 @@ recho () { echo -e "${RED}$1${NC}" } -if [ -z "$VIVADO_PATH" ];then - recho "Please set the VIVADO_PATH that contains the path to your Vivado installation directory." - recho "FINN functionality depending on Vivado or Vivado HLS will not be available." +if [ -z "$FINN_XILINX_PATH" ];then + recho "Please set the FINN_XILINX_PATH environment variable to the path to your Xilinx tools installation directory (e.g. /opt/Xilinx)." + recho "FINN functionality depending on Vivado, Vitis or HLS will not be available." fi -if [ -z "$PYNQ_IP" ];then - recho "Please set the PYNQ_IP env.var. to enable PYNQ deployment tests." +if [ -z "$FINN_XILINX_VERSION" ];then + recho "Please set the FINN_XILINX_VERSION to the version of the Xilinx tools to use (e.g. 2020.1)" + recho "FINN functionality depending on Vivado, Vitis or HLS will not be available." fi -if [ -z "$VITIS_PATH" ];then - recho "Please set the VITIS_PATH that contains the path to your Vitis installation directory." - recho "FINN functionality depending on Vitis will not be available." -else - if [ -z "$PLATFORM_REPO_PATHS" ];then - recho "Please set PLATFORM_REPO_PATHS pointing to Vitis platform files (DSAs)." - recho "This is required to be able to use Vitis." - exit -1 - fi +if [ -z "$PLATFORM_REPO_PATHS" ];then + recho "Please set PLATFORM_REPO_PATHS pointing to Vitis platform files (DSAs)." + recho "This is required to be able to use Alveo PCIe cards." fi DOCKER_GID=$(id -g) @@ -84,7 +79,7 @@ SCRIPTPATH=$(dirname "$SCRIPT") : ${PYNQ_PASSWORD="xilinx"} : ${PYNQ_BOARD="Pynq-Z1"} : ${PYNQ_TARGET_DIR="/home/xilinx/$DOCKER_INST_NAME"} -: ${NUM_DEFAULT_WORKERS=1} +: ${NUM_DEFAULT_WORKERS=4} : ${FINN_SSH_KEY_DIR="$SCRIPTPATH/ssh_keys"} : ${ALVEO_USERNAME="alveo_user"} : ${ALVEO_PASSWORD=""} @@ -98,6 +93,7 @@ SCRIPTPATH=$(dirname "$SCRIPT") : ${FINN_DOCKER_RUN_AS_ROOT="0"} : ${FINN_DOCKER_GPU="$(docker info | grep nvidia | wc -m)"} : ${NVIDIA_VISIBLE_DEVICES=""} +: ${DOCKER_BUILDKIT="1"} DOCKER_INTERACTIVE="" DOCKER_EXTRA="" @@ -159,10 +155,7 @@ mkdir -p $FINN_SSH_KEY_DIR gecho "Docker container is named $DOCKER_INST_NAME" gecho "Docker tag is named $FINN_DOCKER_TAG" gecho "Mounting $FINN_HOST_BUILD_DIR into $FINN_HOST_BUILD_DIR" -gecho "Mounting $VIVADO_PATH into $VIVADO_PATH" -if [ ! -z "$VITIS_PATH" ];then - gecho "Mounting $VITIS_PATH into $VITIS_PATH" -fi +gecho "Mounting $FINN_XILINX_PATH into $FINN_XILINX_PATH" gecho "Port-forwarding for Jupyter $JUPYTER_PORT:$JUPYTER_PORT" gecho "Port-forwarding for Netron $NETRON_PORT:$NETRON_PORT" gecho "Vivado IP cache dir is at $VIVADO_IP_CACHE" @@ -184,7 +177,6 @@ DOCKER_EXEC+="--hostname $DOCKER_INST_NAME " DOCKER_EXEC+="-e SHELL=/bin/bash " DOCKER_EXEC+="-v $SCRIPTPATH:/workspace/finn " DOCKER_EXEC+="-v $FINN_HOST_BUILD_DIR:$FINN_HOST_BUILD_DIR " -DOCKER_EXEC+="-v $FINN_SSH_KEY_DIR:/workspace/.ssh " DOCKER_EXEC+="-e FINN_BUILD_DIR=$FINN_HOST_BUILD_DIR " DOCKER_EXEC+="-e FINN_ROOT="/workspace/finn" " DOCKER_EXEC+="-e LOCALHOST_URL=$LOCALHOST_URL " @@ -200,31 +192,35 @@ if [ "$FINN_DOCKER_RUN_AS_ROOT" = "0" ];then DOCKER_EXEC+="-v /etc/passwd:/etc/passwd:ro " DOCKER_EXEC+="-v /etc/shadow:/etc/shadow:ro " DOCKER_EXEC+="-v /etc/sudoers.d:/etc/sudoers.d:ro " + DOCKER_EXEC+="-v $FINN_SSH_KEY_DIR:$HOME/.ssh " DOCKER_EXEC+="--user $DOCKER_UID:$DOCKER_GID " +else + DOCKER_EXEC+="-v $FINN_SSH_KEY_DIR:/root/.ssh " fi if [ ! -z "$IMAGENET_VAL_PATH" ];then DOCKER_EXEC+="-v $IMAGENET_VAL_PATH:$IMAGENET_VAL_PATH " DOCKER_EXEC+="-e IMAGENET_VAL_PATH=$IMAGENET_VAL_PATH " fi -if [ ! -z "$VIVADO_PATH" ];then - DOCKER_EXEC+="-e "XILINX_VIVADO=$VIVADO_PATH" " - DOCKER_EXEC+="-v $VIVADO_PATH:$VIVADO_PATH " - DOCKER_EXEC+="-e VIVADO_PATH=$VIVADO_PATH " -fi -if [ ! -z "$VITIS_PATH" ];then - if [ -z "$PLATFORM_REPO_PATHS" ];then - recho "PLATFORM_REPO_PATHS must be set for Vitis/Alveo flows" - exit -1 +if [ ! -z "$FINN_XILINX_PATH" ];then + VIVADO_PATH="$FINN_XILINX_PATH/Vivado/$FINN_XILINX_VERSION" + VITIS_PATH="$FINN_XILINX_PATH/Vitis/$FINN_XILINX_VERSION" + DOCKER_EXEC+="-v $FINN_XILINX_PATH:$FINN_XILINX_PATH " + if [ -d "$VIVADO_PATH" ];then + DOCKER_EXEC+="-e "XILINX_VIVADO=$VIVADO_PATH" " + DOCKER_EXEC+="-e VIVADO_PATH=$VIVADO_PATH " + fi + if [ -d "$VITIS_PATH" ];then + DOCKER_EXEC+="-e VITIS_PATH=$VITIS_PATH " + fi + if [ -d "$PLATFORM_REPO_PATHS" ];then + DOCKER_EXEC+="-v $PLATFORM_REPO_PATHS:$PLATFORM_REPO_PATHS " + DOCKER_EXEC+="-e PLATFORM_REPO_PATHS=$PLATFORM_REPO_PATHS " + DOCKER_EXEC+="-e ALVEO_IP=$ALVEO_IP " + DOCKER_EXEC+="-e ALVEO_USERNAME=$ALVEO_USERNAME " + DOCKER_EXEC+="-e ALVEO_PASSWORD=$ALVEO_PASSWORD " + DOCKER_EXEC+="-e ALVEO_BOARD=$ALVEO_BOARD " + DOCKER_EXEC+="-e ALVEO_TARGET_DIR=$ALVEO_TARGET_DIR " fi - DOCKER_EXEC+="-v $VITIS_PATH:$VITIS_PATH " - DOCKER_EXEC+="-v $PLATFORM_REPO_PATHS:$PLATFORM_REPO_PATHS " - DOCKER_EXEC+="-e VITIS_PATH=$VITIS_PATH " - DOCKER_EXEC+="-e PLATFORM_REPO_PATHS=$PLATFORM_REPO_PATHS " - DOCKER_EXEC+="-e ALVEO_IP=$ALVEO_IP " - DOCKER_EXEC+="-e ALVEO_USERNAME=$ALVEO_USERNAME " - DOCKER_EXEC+="-e ALVEO_PASSWORD=$ALVEO_PASSWORD " - DOCKER_EXEC+="-e ALVEO_BOARD=$ALVEO_BOARD " - DOCKER_EXEC+="-e ALVEO_TARGET_DIR=$ALVEO_TARGET_DIR " fi DOCKER_EXEC+="$DOCKER_EXTRA " DOCKER_EXEC+="$FINN_DOCKER_TAG $DOCKER_CMD"