diff --git a/docker/Dockerfile.demo_rocm b/docker/Dockerfile.demo_rocm new file mode 100644 index 000000000000..c336be41934f --- /dev/null +++ b/docker/Dockerfile.demo_rocm @@ -0,0 +1,36 @@ +# 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. + +# Demo docker for ROCm +FROM ubuntu:18.04 + +COPY install/ubuntu_install_core.sh /install/ubuntu_install_core.sh +RUN bash /install/ubuntu_install_core.sh + +COPY install/ubuntu1804_install_python.sh /install/ubuntu1804_install_python.sh +RUN bash /install/ubuntu1804_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/ubuntu1804_install_llvm.sh /install/ubuntu1804_install_llvm.sh +RUN bash /install/ubuntu1804_install_llvm.sh + +COPY install/ubuntu_install_rocm.sh /install/ubuntu_install_rocm.sh +RUN bash /install/ubuntu_install_rocm.sh + +ENV PATH "${PATH}:/opt/rocm/bin" diff --git a/docker/bash.sh b/docker/bash.sh index a615d180b9ed..785b42870e24 100755 --- a/docker/bash.sh +++ b/docker/bash.sh @@ -88,6 +88,9 @@ else CI_ADDON_ENV="" fi +DOCKER_ENVS="" +DOCKER_DEVICES="" +WORKSPACE_VOLUMES="" # 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" @@ -102,13 +105,15 @@ if [[ "${DOCKER_IMAGE_NAME}" == *"demo_vitis_ai"* && -d "/dev/shm" && -d "/opt/x for i in ${RENDER_DRIVER} ; do DOCKER_DEVICES+="--device=$i " - done - -else - DOCKER_DEVICES="" - WORKSPACE_VOLUMES="" + done fi +# Add ROCm devices and set ROCM_ENABLED=1 which is used in the with_the_same_user script +# to add the user to the video group +if [[ "${DOCKER_IMAGE_NAME}" == *"rocm"* && -d "/dev/dri" ]]; then + DOCKER_DEVICES+="--device=/dev/kfd --device=/dev/dri " + DOCKER_ENVS+="-e ROCM_ENABLED=1 " +fi # Print arguments. echo "WORKSPACE: ${WORKSPACE}" @@ -143,6 +148,7 @@ ${DOCKER_BINARY} run --rm --pid=host\ -e "CI_BUILD_GID=$(id -g)" \ -e "CI_PYTEST_ADD_OPTIONS=$CI_PYTEST_ADD_OPTIONS" \ -e "CI_IMAGE_NAME=${DOCKER_IMAGE_NAME}" \ + ${DOCKER_ENVS} \ ${CI_ADDON_ENV} \ ${CUDA_ENV} \ "${CI_DOCKER_EXTRA_PARAMS[@]}" \ diff --git a/docker/install/ubuntu_install_rocm.sh b/docker/install/ubuntu_install_rocm.sh index 196f4134db6e..0945c582489f 100755 --- a/docker/install/ubuntu_install_rocm.sh +++ b/docker/install/ubuntu_install_rocm.sh @@ -23,4 +23,8 @@ set -o pipefail # Install ROCm cross compilation toolchain. wget -qO - http://repo.radeon.com/rocm/apt/debian/rocm.gpg.key | sudo apt-key add - echo deb [arch=amd64] http://repo.radeon.com/rocm/apt/debian/ xenial main > /etc/apt/sources.list.d/rocm.list -apt-get update && apt-get install -y rocm-dev +apt-get update && apt-get install -y \ + rocm-dev \ + lld && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* diff --git a/docker/with_the_same_user b/docker/with_the_same_user index 459978409be5..a7ea8c009b58 100644 --- a/docker/with_the_same_user +++ b/docker/with_the_same_user @@ -41,6 +41,12 @@ getent passwd "${CI_BUILD_UID}" || adduser --gid "${CI_BUILD_GID}" --uid "${CI_B --gecos "${CI_BUILD_USER} (generated by with_the_same_user script)" \ --disabled-password --home "${CI_BUILD_HOME}" --quiet "${CI_BUILD_USER}" usermod -a -G sudo "${CI_BUILD_USER}" + +# Add user to video group for ROCm +if [[ ! -z $ROCM_ENABLED ]]; then + usermod -a -G video "${CI_BUILD_USER}" +fi + # This is a grotesque hack to get PYTEST_ADD_OPTS available to all task scripts. echo "${CI_BUILD_USER} ALL=(ALL) NOPASSWD:ALL" > /etc/sudoers.d/90-nopasswd-sudo