Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CI][Contrib] Add Vitis-AI docker installation #6342

Merged
merged 4 commits into from
Sep 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions docker/Dockerfile.ci_cpu
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,7 @@ RUN bash /install/ubuntu_install_caffe.sh
# Github Arm(R) Ethos(TM)-N NPU driver
COPY install/ubuntu_install_ethosn_driver_stack.sh /install/ubuntu_install_ethosn_driver_stack.sh
RUN bash /install/ubuntu_install_ethosn_driver_stack.sh

# Vitis-AI PyXIR CI deps
COPY install/ubuntu_install_vitis_ai_packages_ci.sh /install/ubuntu_install_vitis_ai_packages_ci.sh
RUN bash /install/ubuntu_install_vitis_ai_packages_ci.sh
55 changes: 55 additions & 0 deletions docker/Dockerfile.demo_vitis_ai
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

# CI docker VAI env
FROM xilinx/vitis-ai:latest

RUN apt-get update --fix-missing


COPY install/ubuntu_install_core.sh /install/ubuntu_install_core.sh
RUN bash /install/ubuntu_install_core.sh

COPY install/ubuntu_install_python.sh /install/ubuntu_install_python.sh
RUN bash /install/ubuntu_install_python.sh

COPY install/ubuntu_install_python_package.sh /install/ubuntu_install_python_package.sh
RUN bash /install/ubuntu_install_python_package.sh

COPY install/ubuntu_install_llvm.sh /install/ubuntu_install_llvm.sh
RUN bash /install/ubuntu_install_llvm.sh

# NNPACK deps
COPY install/ubuntu_install_nnpack.sh /install/ubuntu_install_nnpack.sh
RUN bash /install/ubuntu_install_nnpack.sh

ENV PATH $PATH:$CARGO_HOME/bin:/usr/lib/go-1.10/bin

# ANTLR deps
COPY install/ubuntu_install_java.sh /install/ubuntu_install_java.sh
RUN bash /install/ubuntu_install_java.sh

# Install Vitis-AI ubuntu dependencies
COPY install/ubuntu_install_vitis_ai_core.sh /install/ubuntu_install_vitis_ai_core.sh
RUN bash /install/ubuntu_install_vitis_ai_core.sh

# Install dependencies inside vitis-ai-tensorflow conda
RUN . $VAI_ROOT/conda/etc/profile.d/conda.sh && \
conda activate vitis-ai-tensorflow && \
pip install --no-cache-dir antlr4-python3-runtime && bash /install/ubuntu_install_python_package.sh

ENV USER="root"
24 changes: 24 additions & 0 deletions docker/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,28 @@ else
CI_PY_ENV=""
fi

# If the Vitis-AI docker image is selected, expose the Xilinx FPGA devices and required volumes containing e.g. DSA's and overlays
if [[ "${DOCKER_IMAGE_NAME}" == *"demo_vitis_ai"* && -d "/dev/shm" && -d "/opt/xilinx/dsa" && -d "/opt/xilinx/overlaybins" ]]; then
WORKSPACE_VOLUMES="-v /dev/shm:/dev/shm -v /opt/xilinx/dsa:/opt/xilinx/dsa -v /opt/xilinx/overlaybins:/opt/xilinx/overlaybins"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be too xilinx specific. Is it possible to do it in another way ousdier docker/bash? e.g. like the runtime case in nvidia

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check is indeed Xilinx specific but there are also NVIDIA and GPU specific checks (https://github.com/apache/incubator-tvm/blob/d4bfcd4c4f8861f6716406ebae391f9936434c4e/docker/bash.sh#L54) in the bash.sh so I don't see how this differs. And this is the usual way in which we setup the docker environment with Vitis-AI. Also, the change shouldn't affect the other docker environments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Please add some comments on top of the if section to describe the set of env being setup. We will need to think about cleanly organize the code as we start to add support to more devices, this could be a good starting pt.

Thanks @jtuyls

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One option - out of scope for this specific patch: have a 1:1 function that will do "all that is special about dealing with this specific image."

In this case, bash.sh will still be self contained, but we know that some logic (as a function) is only executed if the image requires it.

enable_other_custom_image()
{
  # do all that is requested to enable this image
}

enable_vitis_ai()
{
  # do all that is requested to enable this image
}

# we only add entries here if there is something special to do about a specific image
case "${DOCKER_IMAGE_NAME}" in
  "demo_vitis_ai")
    enable_vitis_ai()
    ;;
  "other_custom_image")
    enable_other_custom_image()
    ;;
  ... 
esac 

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the proposal of @leandron. Would improve clarity in the bash.sh for multiple devices. We could additionally standardize on variables like $VITIS_AI_FLAGS, etc to be edited in the function and to be added to the docker run command.

@leandron You specifically want to leave this out of this PR as we could easily already write our Vitis-AI changes in this format?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jtuyls I feel it needs a bit more discussion so I wouldn't block this PR merge for that. Despite feeling the idea is appropriate, I think we need to collect feedback in a specific PR.

XCLMGMT_DRIVER="$(find /dev -name xclmgmt\*)"
DOCKER_DEVICES=""
for i in ${XCLMGMT_DRIVER} ;
do
DOCKER_DEVICES+="--device=$i "
done

RENDER_DRIVER="$(find /dev/dri -name renderD\*)"
for i in ${RENDER_DRIVER} ;
do
DOCKER_DEVICES+="--device=$i "
done

else
DOCKER_DEVICES=""
WORKSPACE_VOLUMES=""
fi


# Print arguments.
echo "WORKSPACE: ${WORKSPACE}"
echo "DOCKER CONTAINER NAME: ${DOCKER_IMAGE_NAME}"
Expand All @@ -95,6 +117,8 @@ fi
# and share the PID namespace (--pid=host) so the process inside does not have
# pid 1 and SIGKILL is propagated to the process inside (jenkins can kill it).
${DOCKER_BINARY} run --rm --pid=host\
${DOCKER_DEVICES}\
${WORKSPACE_VOLUMES}\
-v ${WORKSPACE}:/workspace \
-v ${SCRIPT_DIR}:/docker \
"${EXTRA_MOUNTS[@]}" \
Expand Down
2 changes: 1 addition & 1 deletion docker/install/ubuntu_install_python.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ apt-get install -y python-dev
# python 3.6
apt-get install -y software-properties-common

add-apt-repository ppa:deadsnakes/ppa
add-apt-repository -y ppa:deadsnakes/ppa
apt-get update
apt-get install -y python-pip python-dev python3.6 python3.6-dev

Expand Down
29 changes: 29 additions & 0 deletions docker/install/ubuntu_install_vitis_ai_core.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -e
set -u
set -o pipefail

# install libraries for building Vitis-AI on ubuntu
apt-get update && apt-get install -y --no-install-recommends \
graphviz\
gnupg2

apt-get update && apt-get install -y gcc-aarch64-linux-gnu

29 changes: 29 additions & 0 deletions docker/install/ubuntu_install_vitis_ai_packages_ci.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

set -e
set -u
set -o pipefail

export PYXIR_HOME=/opt/pyxir
mkdir "$PYXIR_HOME"

pip3 install progressbar

git clone --recursive --branch v0.1.2 https://github.com/Xilinx/pyxir.git "${PYXIR_HOME}"
cd "${PYXIR_HOME}" && python3 setup.py install