Skip to content

Commit

Permalink
Add ROCm docker (#7422)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtuyls authored Feb 12, 2021
1 parent c7c54de commit d769727
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
36 changes: 36 additions & 0 deletions docker/Dockerfile.demo_rocm
Original file line number Diff line number Diff line change
@@ -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"
16 changes: 11 additions & 5 deletions docker/bash.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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}"
Expand Down Expand Up @@ -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[@]}" \
Expand Down
6 changes: 5 additions & 1 deletion docker/install/ubuntu_install_rocm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/*
6 changes: 6 additions & 0 deletions docker/with_the_same_user
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit d769727

Please sign in to comment.