mirror of
https://github.com/RadeonOpenCompute/ROCm-docker.git
synced 2023-04-23 17:53:00 +03:00
Refactor setup file to support debian and source builds
Introduced concept of docker-compose .env file Both debian and cmake template files are expanded setup now generates both deb and src dockerfiles at the same time. docker-compose.yml is changed to not a template file, and can build both src and debian images Removed the per-component parameters from setup.sh renamed template files to change 'cmake' to 'src' Modifications to src builds of roct & rocr Neither of these components build into debians yet Also, it looks like each component is not creating the softlinks they should.
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -33,4 +33,5 @@ tags
|
||||
|
||||
# Docker files
|
||||
Dockerfile
|
||||
*.yml
|
||||
*-dockerfile
|
||||
.env
|
||||
|
||||
99
docker-compose.yml
Normal file
99
docker-compose.yml
Normal file
@@ -0,0 +1,99 @@
|
||||
version: '2'
|
||||
services:
|
||||
# The following are images built from debians downloaded from a package repository
|
||||
roct-deb:
|
||||
build:
|
||||
context: ./roct
|
||||
dockerfile: ${roct_deb_dockerfile}
|
||||
image: ${roct_image_name_deb}
|
||||
container_name: roct-deb
|
||||
|
||||
rocr-deb:
|
||||
depends_on:
|
||||
- roct-deb
|
||||
build:
|
||||
context: ./rocr
|
||||
dockerfile: ${rocr_deb_dockerfile}
|
||||
image: ${rocr_image_name_deb}
|
||||
container_name: rocr-deb
|
||||
|
||||
hcc-lc-deb:
|
||||
depends_on:
|
||||
- rocr-deb
|
||||
build:
|
||||
context: ./hcc-lc
|
||||
dockerfile: ${hcc_lc_deb_dockerfile}
|
||||
image: ${hcc_lc_image_name_deb}
|
||||
container_name: hcc-lc-deb
|
||||
|
||||
# The following are images built from rocm source
|
||||
roct-src:
|
||||
build:
|
||||
context: ./roct
|
||||
dockerfile: ${roct_src_dockerfile}
|
||||
image: ${roct_image_name_src}
|
||||
container_name: roct-src
|
||||
volumes:
|
||||
- ${roct_volume}
|
||||
|
||||
rocr-src:
|
||||
depends_on:
|
||||
- roct-src
|
||||
build:
|
||||
context: ./rocr
|
||||
dockerfile: ${rocr_src_dockerfile}
|
||||
image: ${rocr_image_name_src}
|
||||
container_name: rocr-src
|
||||
volumes:
|
||||
- ${rocr_volume}
|
||||
|
||||
hcc-lc-src:
|
||||
depends_on:
|
||||
- rocr-src
|
||||
build:
|
||||
context: ./hcc-lc
|
||||
dockerfile: ${hcc_lc_src_dockerfile}
|
||||
image: ${hcc_lc_image_name_src}
|
||||
container_name: hcc-lc-src
|
||||
volumes:
|
||||
- ${hcc_lc_volume}
|
||||
|
||||
# hcc-hsail:
|
||||
# depends_on:
|
||||
# - rocr
|
||||
# build:
|
||||
# context: ./hcc-hsail
|
||||
# dockerfile: Dockerfile
|
||||
# image: ${hcc_hsail_name}
|
||||
# container_name: hcc-hsail
|
||||
# entrypoint: /bin/true
|
||||
# volumes:
|
||||
# - ${hcc_hsail_volume}
|
||||
|
||||
# The following defines application containers, which depend on the data-only
|
||||
# containers defined above to provide their software layers
|
||||
# These should be run with `docker-compose run --rm <application-service>`
|
||||
rocm:
|
||||
build:
|
||||
context: ./rocm-terminal
|
||||
dockerfile: Dockerfile
|
||||
devices:
|
||||
- "/dev/kfd"
|
||||
image: rocm/rocm-terminal
|
||||
volumes:
|
||||
- ~:/usr/local/src/host-home
|
||||
|
||||
rocm-from-src:
|
||||
build:
|
||||
context: ./rocm-terminal
|
||||
dockerfile: Dockerfile
|
||||
devices:
|
||||
- "/dev/kfd"
|
||||
image: rocm/rocm-terminal
|
||||
volumes:
|
||||
- ~:/usr/local/src/host-home
|
||||
volumes_from:
|
||||
- roct-src:ro
|
||||
- rocr-src:ro
|
||||
- hcc-lc-src:ro
|
||||
# - hcc-hsail-src:ro
|
||||
@@ -1,77 +0,0 @@
|
||||
version: '2'
|
||||
services:
|
||||
# The following containers are data-only, exporting volumes
|
||||
# They are not meant to be used as interactive containers
|
||||
roct:
|
||||
build:
|
||||
context: ./roct
|
||||
dockerfile: Dockerfile
|
||||
image: ${roct_name}
|
||||
container_name: roct
|
||||
entrypoint: /bin/true
|
||||
volumes:
|
||||
- ${roct_volume}
|
||||
|
||||
rocr:
|
||||
depends_on:
|
||||
- roct
|
||||
build:
|
||||
context: ./rocr
|
||||
dockerfile: Dockerfile
|
||||
image: ${rocr_name}
|
||||
container_name: rocr
|
||||
entrypoint: /bin/true
|
||||
volumes:
|
||||
- ${rocr_volume}
|
||||
|
||||
hcc-lc:
|
||||
depends_on:
|
||||
- rocr
|
||||
build:
|
||||
context: ./hcc-lc
|
||||
dockerfile: Dockerfile
|
||||
image: ${hcc_lc_name}
|
||||
container_name: hcc-lc
|
||||
entrypoint: /bin/true
|
||||
volumes:
|
||||
- ${hcc_lc_volume}
|
||||
|
||||
hcc-hsail:
|
||||
depends_on:
|
||||
- rocr
|
||||
build:
|
||||
context: ./hcc-hsail
|
||||
dockerfile: Dockerfile
|
||||
image: ${hcc_hsail_name}
|
||||
container_name: hcc-hsail
|
||||
entrypoint: /bin/true
|
||||
volumes:
|
||||
- ${hcc_hsail_volume}
|
||||
|
||||
# The following defines application containers, which depend on the data-only
|
||||
# containers defined above to provide their software layers
|
||||
# These should be run with `docker-compose run --rm <application-service>`
|
||||
rocm:
|
||||
build:
|
||||
context: ./rocm-terminal
|
||||
dockerfile: Dockerfile
|
||||
devices:
|
||||
- "/dev/kfd"
|
||||
image: rocm/rocm-terminal
|
||||
volumes:
|
||||
- ~:/usr/local/src/host-home
|
||||
|
||||
rocm-from-src:
|
||||
build:
|
||||
context: ./rocm-terminal
|
||||
dockerfile: Dockerfile
|
||||
devices:
|
||||
- "/dev/kfd"
|
||||
image: rocm/rocm-terminal
|
||||
volumes:
|
||||
- ~:/usr/local/src/host-home
|
||||
volumes_from:
|
||||
- roct:ro
|
||||
- rocr:ro
|
||||
- hcc-lc:ro
|
||||
- hcc-hsail:ro
|
||||
@@ -4,7 +4,7 @@
|
||||
# most changing at bottom
|
||||
|
||||
# This builds the hcc compiler, and depends on an already existing rocr-runtime to be found
|
||||
FROM ${rocr_name}
|
||||
FROM ${rocr_image_name_src}
|
||||
MAINTAINER Kent Knox <kent.knox@amd>
|
||||
|
||||
# Install dependencies required to build hcc
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# most changing at bottom
|
||||
|
||||
# This builds the hcc compiler, and depends on an already existing rocr-runtime to be found
|
||||
FROM ${rocr_name}
|
||||
FROM ${rocr_image_name_deb}
|
||||
MAINTAINER Kent Knox <kent.knox@amd>
|
||||
|
||||
# Following assumes that the apt-get update is already set up to pull from packages.amd.com in base image
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# most changing at bottom
|
||||
|
||||
# This builds the radeon open compute runtime
|
||||
FROM ${roct_name}
|
||||
FROM ${roct_image_name_deb}
|
||||
MAINTAINER Kent Knox <kent.knox@amd>
|
||||
|
||||
# Following assumes that the apt-get update is already set up to pull from packages.amd.com in base image
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
# most changing at bottom
|
||||
|
||||
# This builds the radeon open compute runtime
|
||||
FROM ${roct_name}
|
||||
FROM ${roct_image_name_src}
|
||||
MAINTAINER Kent Knox <kent.knox@amd>
|
||||
|
||||
# The following imports a key to the external AMD packages repository to make it trusted
|
||||
@@ -28,9 +28,31 @@ ENV ROCR_BUILD_PATH=/usr/local/src/ROCR-Runtime/
|
||||
|
||||
# Configure, build and install the runtime
|
||||
# Extract only the finalizer libraries and build open source libhsa-runtime64 component on top
|
||||
#RUN mkdir -p ${ROCR_BUILD_PATH} && \
|
||||
# cd ${ROCR_BUILD_PATH} && \
|
||||
# git clone --depth=1 --branch=${tag} https://github.com/RadeonOpenCompute/ROCR-Runtime.git ./ && \
|
||||
# mkdir -p build && \
|
||||
# cd build && \
|
||||
# cmake \
|
||||
# -DHSAKMT_BUILD_INC_PATH=${roct_volume}include/libhsakmt \
|
||||
# -DHSAKMT_BUILD_LIB_PATH=${roct_volume}${lib64_install_dir} \
|
||||
# -DCMAKE_INSTALL_PREFIX=${rocr_volume} \
|
||||
# -DCMAKE_BUILD_TYPE=${build_config} \
|
||||
# ../src && \
|
||||
# make -j $(nproc) install && \
|
||||
# cp -r ../src/inc ${rocr_volume}/include && \
|
||||
# cp -r ../sample ${rocr_volume}/sample && \
|
||||
# ln -sr ${rocr_volume}/include/ ${rocm_volume}/include/hsa && \
|
||||
# ln -sr ${rocr_volume}/include/ ${rocr_volume}/include/hsa && \
|
||||
# ln -sr ${rocr_volume}/lib/libhsa-runtime64.so.1 ${rocm_volume}/lib/libhsa-runtime64.so && \
|
||||
# git log -n 3 > ${rocr_volume}/git-stamp.log && \
|
||||
# ${rocr_cleanup} \
|
||||
# echo "${rocr_volume}lib" >> /etc/ld.so.conf.d/hsa-rocr-dev.conf && \
|
||||
# ldconfig
|
||||
|
||||
RUN mkdir -p ${ROCR_BUILD_PATH} && \
|
||||
cd ${ROCR_BUILD_PATH} && \
|
||||
git clone --depth=1 --branch=${repo_branch_rocr} https://github.com/RadeonOpenCompute/ROCR-Runtime.git ./ && \
|
||||
git clone --depth=1 --branch=${tag} https://github.com/RadeonOpenCompute/ROCR-Runtime.git ./ && \
|
||||
mkdir -p build && \
|
||||
cd build && \
|
||||
cmake \
|
||||
@@ -39,13 +61,8 @@ RUN mkdir -p ${ROCR_BUILD_PATH} && \
|
||||
-DCMAKE_INSTALL_PREFIX=${rocr_volume} \
|
||||
-DCMAKE_BUILD_TYPE=${build_config} \
|
||||
../src && \
|
||||
make -j $(nproc) install && \
|
||||
cp -r ../src/inc ${rocr_volume}/include && \
|
||||
cp -r ../sample ${rocr_volume}/sample && \
|
||||
ln -sr ${rocr_volume}/include/ ${rocm_volume}/include/hsa && \
|
||||
ln -sr ${rocr_volume}/include/ ${rocr_volume}/include/hsa && \
|
||||
ln -sr ${rocr_volume}/lib/libhsa-runtime64.so.1 ${rocm_volume}/lib/libhsa-runtime64.so && \
|
||||
make -j $(nproc) package && \
|
||||
# dpkg -i hsa-rocr-dev-*.deb && \
|
||||
./hsa-rocr-dev-1.1.0-Linux.sh --prefix=/opt/rocm --skip-license && \
|
||||
git log -n 3 > ${rocr_volume}/git-stamp.log && \
|
||||
${rocr_cleanup} \
|
||||
echo "${rocr_volume}lib" >> /etc/ld.so.conf.d/hsa-rocr-dev.conf && \
|
||||
ldconfig
|
||||
@@ -1,40 +0,0 @@
|
||||
# Build this dockerfile with `docker build -f roct-thunk-release-dockerfile -t roc/roct .`
|
||||
|
||||
# To reduce container rebuild time, place commands least likely to change at top to
|
||||
# most changing at bottom
|
||||
|
||||
# This builds the radeon open compute kernel thunk
|
||||
|
||||
FROM ubuntu:16.04
|
||||
MAINTAINER Kent Knox <kent.knox@amd>
|
||||
|
||||
# Initialize the image we are working with
|
||||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
||||
build-essential \
|
||||
git \
|
||||
cmake-curses-gui && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# App specific environment variables
|
||||
ENV HSATHK_BUILD_PATH=/usr/local/src/ROCT-Thunk-Interface
|
||||
|
||||
# RUN ln -sr ${roct_volume}lib/libhsakmt.so.1 ${roct_volume}lib/libhsakmt.so
|
||||
|
||||
# Uncomment the following code when ROCT-Thunk-Interface cmake code successfully builds
|
||||
# Build libhsakmt
|
||||
RUN mkdir -p ${HSATHK_BUILD_PATH} && \
|
||||
cd ${HSATHK_BUILD_PATH} && \
|
||||
git clone --depth=1 --branch=${repo_branch} https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface.git ./ && \
|
||||
mkdir -p build && \
|
||||
cd build && \
|
||||
cmake \
|
||||
-DCMAKE_INSTALL_PREFIX=${roct_volume} \
|
||||
-DCMAKE_BUILD_TYPE=${build_config} \
|
||||
.. && \
|
||||
make -j $(nproc) package && \
|
||||
git log -n 3 > ${roct_volume}/git-stamp.log && \
|
||||
${roct_cleanup} \
|
||||
# echo "${roct_volume}${lib64_install_dir}" >> /etc/ld.so.conf.d/x86_64-libhsakmt.conf && \
|
||||
# ldconfig && \
|
||||
dpkg -i hsakmt-roct-dev.deb
|
||||
@@ -5,7 +5,7 @@
|
||||
|
||||
# This builds the radeon open compute kernel thunk
|
||||
|
||||
FROM ubuntu:16.04
|
||||
FROM ubuntu:${ubuntu_version}
|
||||
MAINTAINER Kent Knox <kent.knox@amd>
|
||||
|
||||
# Initialize the image we are working with
|
||||
|
||||
46
roct/roct-thunk-src-dockerfile.template
Normal file
46
roct/roct-thunk-src-dockerfile.template
Normal file
@@ -0,0 +1,46 @@
|
||||
# Build this dockerfile with `docker build -f roct-thunk-release-dockerfile -t roc/roct .`
|
||||
|
||||
# To reduce container rebuild time, place commands least likely to change at top to
|
||||
# most changing at bottom
|
||||
|
||||
# This builds the radeon open compute kernel thunk
|
||||
|
||||
FROM ubuntu:${ubuntu_version}
|
||||
MAINTAINER Kent Knox <kent.knox@amd>
|
||||
|
||||
# Initialize the image we are working with
|
||||
RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install --no-install-recommends -y \
|
||||
build-essential \
|
||||
fakeroot \
|
||||
git \
|
||||
ca-certificates \
|
||||
libpci-dev \
|
||||
cmake-curses-gui && \
|
||||
apt-get clean && \
|
||||
rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# App specific environment variables
|
||||
ENV HSATHK_BUILD_PATH=/usr/local/src/ROCT-Thunk-Interface
|
||||
|
||||
# Uncomment the following code when ROCT-Thunk-Interface cmake code can make debian packages
|
||||
#RUN mkdir -p ${HSATHK_BUILD_PATH} && \
|
||||
# cd ${HSATHK_BUILD_PATH} && \
|
||||
# git clone --depth=1 --branch=${tag} https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface.git ./ && \
|
||||
# mkdir -p build && \
|
||||
# cd build && \
|
||||
# cmake \
|
||||
# -DCMAKE_INSTALL_PREFIX=${roct_volume} \
|
||||
# -DCMAKE_BUILD_TYPE=${build_config} \
|
||||
# .. && \
|
||||
# make -j $(nproc) package && \
|
||||
# ${roct_cleanup} \
|
||||
# dpkg -i hsakmt-roct-dev-\*.deb && \
|
||||
# git log -n 3 > ${roct_volume}/git-stamp.log
|
||||
|
||||
RUN mkdir -p ${HSATHK_BUILD_PATH} && \
|
||||
cd ${HSATHK_BUILD_PATH} && \
|
||||
git clone --depth=1 --branch=${tag} https://github.com/RadeonOpenCompute/ROCT-Thunk-Interface.git ./ && \
|
||||
make -j $(nproc) deb && \
|
||||
dpkg -i build/deb/hsakmt-dev-*.deb && \
|
||||
ln -sr ${roct_volume}lib/libhsakmt.so.1 ${roct_volume}lib/libhsakmt.so && \
|
||||
${roct_cleanup}
|
||||
268
setup.sh
Normal file → Executable file
268
setup.sh
Normal file → Executable file
@@ -7,30 +7,34 @@
|
||||
# #################################################
|
||||
# Pre-requisites check
|
||||
# #################################################
|
||||
if (( ${BASH_VERSION%%.*} < 4 )); then
|
||||
printf "This script uses associative arrays, requiring Bash 4.x minimum\n"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# check if curl is installed
|
||||
type curl > /dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "This script uses curl to download components; try installing with package manager";
|
||||
printf "This script uses curl to download components; try installing with package manager\n";
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# check if getopt command is installed
|
||||
type getopt > /dev/null
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "This script uses getopt to parse arguments; try installing the util-linux package";
|
||||
exit 1
|
||||
printf "This script uses getopt to parse arguments; try installing the util-linux package\n";
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# lsb-release file describes the system
|
||||
if [[ ! -e "/etc/lsb-release" ]]; then
|
||||
echo "This script depends on the /etc/lsb-release file"
|
||||
printf "This script depends on the /etc/lsb-release file\n"
|
||||
exit 2
|
||||
fi
|
||||
source /etc/lsb-release
|
||||
|
||||
if [[ ${DISTRIB_CODENAME} != trusty ]] && [[ ${DISTRIB_CODENAME} != xenial ]]; then
|
||||
echo "This script only validated with Ubuntu trusty [14.04] or xenial [16.04]"
|
||||
printf "This script only validated with Ubuntu trusty [14.04] or xenial [16.04]\n"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
@@ -39,30 +43,46 @@ fi
|
||||
# #################################################
|
||||
function display_help()
|
||||
{
|
||||
echo "Building ROC docker images from templates"
|
||||
echo "Usage: ./setup [--debian] ([--build] [--master | --develop] [--release | --debug] )"
|
||||
echo "Default flags: --debian"
|
||||
echo ""
|
||||
echo " [-h|--help] prints this help message"
|
||||
echo " [--debian] install binary packages from packages.amd.com; exclusive with --build"
|
||||
echo " [--build] build rocm packages from source; defaults to master branch and release build"
|
||||
echo " [--master] Build dockerfiles from stable master branches; exclusive with --develop"
|
||||
echo " [--develop] Build dockerfiles from integration branches; exclusive with --master"
|
||||
echo " [--release] Build release containers; minimizes size of docker images; exclusive with --debug"
|
||||
echo " [--debug] Build debug containers; symbols generated and build tree intact for debugging; exclusive with --release"
|
||||
printf "Build ROC docker images from templates\n\n"
|
||||
printf " [-h|--help] prints this help message\n"
|
||||
printf " [--ubuntu xx.yy] Ubuntu version for to inherit base image (16.04 / 14.04)\n"
|
||||
printf " [--tag] String specifying branch or tag in git repository (requires --build)\n"
|
||||
printf " [--branch] Same as tag; alias (requires --build)\n"
|
||||
printf " [--all] Build as many components as you can\n"
|
||||
printf " [--roct] Build roct component\n"
|
||||
printf " [--rocr] Build rocr component\n"
|
||||
printf " [--hcc-lc] Build hcc-lc component\n"
|
||||
printf " [--hcc-hsail] Build hcc-hsail component\n"
|
||||
printf " [--release] Build release containers; minimizes size of docker images; (requires --build, exclusive with --debug)\n"
|
||||
printf " [--debug] Build debug containers; symbols generated and build tree intact for debugging; (requires --build, exclusive with --release)\n"
|
||||
printf " [--install-docker-compose] install the docker-compose tool\n"
|
||||
}
|
||||
|
||||
# #################################################
|
||||
# global variables
|
||||
# global variables & defaults
|
||||
# #################################################
|
||||
install_deb=true
|
||||
build_src=false
|
||||
# Array describing what rocm components to build docker images for
|
||||
rocm_components=()
|
||||
|
||||
build_master=true
|
||||
build_develop=false
|
||||
# If building components from source, script defaults to master branch if no tag name is explicitely specified
|
||||
export tag='master'
|
||||
export ubuntu_version='16.04'
|
||||
|
||||
export build_config='Release'
|
||||
build_release=true
|
||||
build_debug=false
|
||||
install_compose=false
|
||||
|
||||
# Bash associative arrays
|
||||
# declare -A thunk_branch_names=( ['master']=master ['develop']=dev ['roc-1.0']=roc-1.0.x ['roc-1.1']=roc-1.1.x ['roc-1.2']=roc-1.2.x ['roc-1.3']=roc-1.3.x ['roc-1.4']=roc-1.4.x )
|
||||
# declare -A runtime_branch_names=( ['master']=master ['develop']= ['roc-1.0']= ['roc-1.1']= ['roc-1.2']=roc-1.2.x ['roc-1.3']=roc-1.3.x ['roc-1.4']=roc-1.4.x )
|
||||
# declare -A hcc_lc_branch_names=( ['master']= ['develop']=develop ['roc-1.0']=roc-1.0.x ['roc-1.1']=roc-1.1.x ['roc-1.2']=roc-1.2.x ['roc-1.3']=roc-1.3.x ['roc-1.4']=roc-1.4.x ['hcc-4.0']=clang_tot_upgrade )
|
||||
# declare -A hcc_hsail_branch_names=( ['master']=master ['develop']= ['roc-1.0']= ['roc-1.1']= ['roc-1.2']= ['roc-1.3']= ['roc-1.4']= )
|
||||
|
||||
declare -A thunk_dockerfiles=( ['src-template']=roct-thunk-src-dockerfile.template ['deb-template']=roct-thunk-deb-dockerfile.template ['src']=roct-thunk-src-dockerfile ['deb']=roct-thunk-deb-dockerfile )
|
||||
declare -A runtime_dockerfiles=( ['src-template']=rocr-src-dockerfile.template ['deb-template']=rocr-deb-dockerfile.template ['src']=rocr-src-dockerfile ['deb']=rocr-deb-dockerfile )
|
||||
declare -A hcc_lc_dockerfiles=( ['src-template']=hcc-lc-clang-tot-upgrade-dockerfile.template ['deb-template']=hcc-lc-deb-dockerfile.template ['src']=hcc-lc-clang-tot-upgrade-dockerfile ['deb']=hcc-lc-deb-dockerfile)
|
||||
declare -A hcc_hsail_dockerfiles=( ['src-template']=hcc-hsail-dockerfile.template ['deb-template']=hcc-hsail-deb-dockerfile.template ['src']=hcc-hsail-dockerfile ['deb']=hcc-hsail-deb-dockerfile )
|
||||
|
||||
# #################################################
|
||||
# Parameter parsing
|
||||
@@ -71,14 +91,15 @@ build_debug=false
|
||||
# check if we have a modern version of getopt that can handle whitespace and long parameters
|
||||
getopt -T
|
||||
if [[ $? -eq 4 ]]; then
|
||||
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,debian,build,master,develop,release,debug --options h -- "$@")
|
||||
# GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,ubuntu:,tag:,branch:,all,roct,rocr,hcc-lc,hcc-hsail,release,debug,install-docker-compose --options h -- "$@")
|
||||
GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,ubuntu:,tag:,branch:,release,debug,install-docker-compose --options h -- "$@")
|
||||
else
|
||||
echo "Legacy getopt not handled"
|
||||
printf "Legacy getopt not handled"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $? -ne 0 ]]; then
|
||||
echo "getopt invocation failed; could not parse the command line";
|
||||
printf "getopt invocation failed; could not parse the command line\n";
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -90,116 +111,171 @@ while true; do
|
||||
display_help
|
||||
exit 0
|
||||
;;
|
||||
--debian)
|
||||
install_deb=true
|
||||
build_src=false
|
||||
shift ;;
|
||||
--build)
|
||||
install_deb=false
|
||||
build_src=true
|
||||
shift ;;
|
||||
--master)
|
||||
build_master=true
|
||||
build_develop=false
|
||||
shift ;;
|
||||
--develop)
|
||||
build_master=false
|
||||
build_develop=true
|
||||
shift ;;
|
||||
--ubuntu)
|
||||
ubuntu_version=${2}
|
||||
shift 2;;
|
||||
--tag|--branch)
|
||||
tag=${2}
|
||||
shift 2;;
|
||||
# --all)
|
||||
# rocm_components=('roct' 'rocr' 'hcc-lc' 'hcc-hsail')
|
||||
# shift ;;
|
||||
# --roct)
|
||||
# rocm_components+=('roct')
|
||||
# shift ;;
|
||||
# --rocr)
|
||||
# rocm_components+=('rocr')
|
||||
# shift ;;
|
||||
# --hcc-lc)
|
||||
# rocm_components+=('hcc-lc')
|
||||
# shift ;;
|
||||
# --hcc-hsail)
|
||||
# rocm_components+=('hcc-hsail')
|
||||
# shift ;;
|
||||
--release)
|
||||
build_config='Release'
|
||||
build_release=true
|
||||
build_debug=false
|
||||
shift ;;
|
||||
--debug)
|
||||
build_config='Debug'
|
||||
build_release=false
|
||||
build_debug=true
|
||||
shift ;;
|
||||
--install-docker-compose)
|
||||
install_compose=true
|
||||
shift ;;
|
||||
--) shift ; break ;;
|
||||
*) echo "getopt parsing error";
|
||||
*) printf "getopt parsing error";
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ "${install_deb}" == true ]] && [[ "${build_src}" == true ]]; then
|
||||
echo "--debian is mutually exlusive with --build"
|
||||
exit 2
|
||||
# #################################################
|
||||
# docker-compose
|
||||
# Help users install docker-compose on their machine
|
||||
# #################################################
|
||||
if [[ "${install_compose}" == true ]]; then
|
||||
sudo curl -L https://github.com/docker/compose/releases/download/1.9.0/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
|
||||
sudo chmod +x /usr/local/bin/docker-compose
|
||||
|
||||
sudo curl -L https://raw.githubusercontent.com/docker/compose/$(docker-compose version --short)/contrib/completion/bash/docker-compose -o /etc/bash_completion.d/docker-compose
|
||||
fi
|
||||
|
||||
# #################################################
|
||||
# Start of main
|
||||
# #################################################
|
||||
|
||||
# hcc-lc conforms to a non git-flow naming scheme, 'master' changes the most
|
||||
export repo_branch="master"
|
||||
export repo_branch_hcc_lc=
|
||||
export repo_branch_hcc_hsail=
|
||||
export repo_branch_rocr="master"
|
||||
|
||||
if [ -n "${build_master}" ]; then
|
||||
repo_branch_hcc_hsail="master"
|
||||
repo_branch_hcc_lc="clang_tot_upgrade"
|
||||
printf "== Branch/tag to build: %s\n" ${tag}
|
||||
if [[ "${build_release}" == true ]]; then
|
||||
printf "==== Release builds \n"
|
||||
else
|
||||
repo_branch_hcc_hsail="master"
|
||||
repo_branch_hcc_lc="clang_tot_upgrade"
|
||||
printf "==== Debug builds \n"
|
||||
fi
|
||||
|
||||
export build_config=
|
||||
export build_config_roct=
|
||||
# Keep only the unique rocm_components
|
||||
# printf "rocm_components count: " ${#rocm_components[@]}
|
||||
# rocm_components=($(printf "%s\n" "${rocm_components[@]}" | uniq -u))
|
||||
#
|
||||
# if [ ${#rocm_components[@]} -ne 0 ]; then
|
||||
# printf "== Rocm images to build: "
|
||||
#
|
||||
# for key in ${!rocm_components[@]}; do
|
||||
# if [ -n "${rocm_components[$key]}" ]; then
|
||||
# printf "${rocm_components[$key]} "
|
||||
# else
|
||||
# printf "NULL\n"
|
||||
# fi
|
||||
# done
|
||||
# printf "\n"
|
||||
# fi
|
||||
|
||||
# export rock_image_name=
|
||||
organization_prefix="rocm/"
|
||||
|
||||
roct_image_name="${organization_prefix}/roct"
|
||||
rocr_image_name="${organization_prefix}/rocr"
|
||||
hcc_lc_image_name="${organization_prefix}/hcc-lc"
|
||||
hcc_hsail_image_name="${organization_prefix}/hcc-hsail"
|
||||
|
||||
export roct_image_name_deb="${roct_image_name}-ubuntu-${ubuntu_version}:latest"
|
||||
export rocr_image_name_deb="${rocr_image_name}-ubuntu-${ubuntu_version}:latest"
|
||||
export hcc_lc_image_name_deb="${hcc_lc_image_name}-ubuntu-${ubuntu_version}:latest"
|
||||
export hcc_hsail_image_name_deb="${hcc_hsail_image_name}-ubuntu-${ubuntu_version}:latest"
|
||||
|
||||
export roct_image_name_src="${roct_image_name}-src-${build_config,}:${tag}"
|
||||
export rocr_image_name_src="${rocr_image_name}-src-${build_config,}:${tag}"
|
||||
export hcc_lc_image_name_src="${hcc_lc_image_name}-src-${build_config,}:${tag}"
|
||||
export hcc_hsail_image_name_src="${hcc_hsail_image_name}-src-${build_config,}:${tag}"
|
||||
|
||||
export roct_cleanup=
|
||||
export rocr_cleanup=
|
||||
export hcc_hsail_cleanup=
|
||||
export hcc_lc_cleanup=
|
||||
export rock_name=
|
||||
export roct_name=
|
||||
export rocr_name=
|
||||
export hcc_hsail_name=
|
||||
export hcc_lc_name=
|
||||
|
||||
rocm_prefix="rocm/"
|
||||
if [ -n "${build_release}" ]; then
|
||||
build_config='Release'
|
||||
|
||||
rock_name="${rocm_prefix}rock-${repo_branch}"
|
||||
roct_name="${rocm_prefix}roct-${repo_branch}"
|
||||
rocr_name="${rocm_prefix}rocr-${repo_branch_rocr}"
|
||||
hcc_hsail_name="${rocm_prefix}hcc-hsail-${repo_branch_hcc_hsail}"
|
||||
hcc_lc_name="${rocm_prefix}hcc-lc-${repo_branch_hcc_lc}"
|
||||
|
||||
if [[ "${build_release}" == true ]]; then
|
||||
# Custom commands to clean up build directories for each component
|
||||
# This is to keep release images as small as possible
|
||||
build_config_roct='REL=1'
|
||||
roct_cleanup='cd ~ && rm -rf ${HSATHK_BUILD_PATH} &&'
|
||||
rocr_cleanup='cd ~ && rm -rf ${ROCR_BUILD_PATH} &&'
|
||||
roct_cleanup='cd ~ && rm -rf ${HSATHK_BUILD_PATH}'
|
||||
rocr_cleanup='cd ~ && rm -rf ${ROCR_BUILD_PATH}'
|
||||
hcc_hsail_cleanup='cd ~ && rm -rf ${HCC_BUILD_PATH} &&'
|
||||
hcc_lc_cleanup='cd ~ && rm -rf ${HCC_BUILD_PATH} &&'
|
||||
else
|
||||
build_config='Debug'
|
||||
|
||||
# For debug builds, name the images as 'debug'
|
||||
# The comma operator in ${build_config} makes the first letter lower case
|
||||
rock_name="${rocm_prefix}rock-${repo_branch}"
|
||||
roct_name="${rocm_prefix}roct-${repo_branch}-${build_config,}"
|
||||
rocr_name="${rocm_prefix}rocr-${repo_branch_rocr}-${build_config,}"
|
||||
hcc_hsail_name="${rocm_prefix}hcc-hsail-${repo_branch_hcc_hsail}-${build_config,}"
|
||||
hcc_lc_name="${rocm_prefix}hcc-lc-${repo_branch_hcc_lc}-${build_config,}"
|
||||
fi
|
||||
|
||||
export rocm_volume='/opt/rocm/'
|
||||
export rock_volume="${rocm_volume}rock/"
|
||||
export roct_volume="${rocm_volume}libhsakmt/"
|
||||
export rocr_volume="${rocm_volume}hsa/"
|
||||
export hcc_hsail_volume="${rocm_volume}hcc-hsail/"
|
||||
export hcc_lc_volume="${rocm_volume}hcc-lc/"
|
||||
export roct_volume="${rocm_volume}/libhsakmt/"
|
||||
export rocr_volume="${rocm_volume}/hsa/"
|
||||
export hcc_hsail_volume="${rocm_volume}/hcc-hsail/"
|
||||
export hcc_lc_volume="${rocm_volume}/hcc-lc/"
|
||||
|
||||
# /lib/x86_64-linux-gnu is debian/ubuntu style not currently used in rocm
|
||||
# export lib64_install_dir='/lib/x86_64-linux-gnu'
|
||||
export lib64_install_dir='/lib'
|
||||
|
||||
cat rock/rock-deb-dockerfile.template | envsubst '${repo_branch}:${rock_volume}' > rock/Dockerfile
|
||||
cat roct/roct-thunk-dockerfile.template | envsubst '${rock_name}:${repo_branch}:${build_config_roct}:${roct_cleanup}:${roct_volume}:${lib64_install_dir}' > roct/Dockerfile
|
||||
cat rocr/rocr-make-dockerfile.template | envsubst '${roct_name}:${repo_branch_rocr}:${build_config}:${rocr_cleanup}:${rocm_volume}:${roct_volume}:${rocr_volume}:${lib64_install_dir}' > rocr/Dockerfile
|
||||
cat hcc-hsail/hcc-hsail-dockerfile.template | envsubst '${rocr_name}:${repo_branch_hcc_hsail}:${build_config}:${hcc_hsail_cleanup}:${roct_volume}:${rocr_volume}:${hcc_hsail_volume}:${lib64_install_dir}' > hcc-hsail/Dockerfile
|
||||
cat hcc-lc/hcc-lc-clang-tot-upgrade-dockerfile.template | envsubst '${rocr_name}:${repo_branch_hcc_lc}:${build_config}:${hcc_lc_cleanup}:${rocm_volume}:${roct_volume}:${rocr_volume}:${hcc_lc_volume}' > hcc-lc/Dockerfile
|
||||
# trim duplicate path seperators
|
||||
roct_image_name_deb=$(echo "${roct_image_name_deb}" | tr -s '/' )
|
||||
rocr_image_name_deb=$(echo "${rocr_image_name_deb}" | tr -s '/' )
|
||||
hcc_lc_image_name_deb=$(echo "${hcc_lc_image_name_deb}" | tr -s '/' )
|
||||
hcc_hsail_image_name_deb=$(echo "${hcc_hsail_image_name_deb}" | tr -s '/' )
|
||||
|
||||
cat docker-compose.yml.template | envsubst '${hcc_lc_name}:${hcc_hsail_name}:${rocr_name}:${roct_name}:${hcc_hsail_volume}:${hcc_lc_volume}:${rocr_volume}:${roct_volume}' > docker-compose.yml
|
||||
roct_image_name_src=$(echo "${roct_image_name_src}" | tr -s '/' )
|
||||
rocr_image_name_src=$(echo "${rocr_image_name_src}" | tr -s '/' )
|
||||
hcc_lc_image_name_src=$(echo "${hcc_lc_image_name_src}" | tr -s '/' )
|
||||
hcc_hsail_image_name_src=$(echo "${hcc_hsail_image_name_src}" | tr -s '/' )
|
||||
|
||||
roct_volume=$(echo "${roct_volume}" | tr -s '/' )
|
||||
rocr_volume=$(echo "${rocr_volume}" | tr -s '/' )
|
||||
hcc_lc_volume=$(echo "${hcc_lc_volume}" | tr -s '/' )
|
||||
hcc_hsail_volume=$(echo "${hcc_hsail_volume}" | tr -s '/' )
|
||||
|
||||
# Generate the .env file used by the docker-compose tool
|
||||
printf "roct_image_name_deb=${roct_image_name_deb}\n" > .env
|
||||
printf "rocr_image_name_deb=${rocr_image_name_deb}\n" >> .env
|
||||
printf "hcc_lc_image_name_deb=${hcc_lc_image_name_deb}\n" >> .env
|
||||
printf "hcc_hsail_image_name_deb=${hcc_hsail_image_name_deb}\n" >> .env
|
||||
printf "roct_image_name_src=${roct_image_name_src}\n">> .env
|
||||
printf "rocr_image_name_src=${rocr_image_name_src}\n" >> .env
|
||||
printf "hcc_lc_image_name_src=${hcc_lc_image_name_src}\n" >> .env
|
||||
printf "hcc_hsail_image_name_src=${hcc_hsail_image_name_src}\n" >> .env
|
||||
|
||||
printf "\n" >> .env
|
||||
printf "roct_volume=${roct_volume}\n" >> .env
|
||||
printf "rocr_volume=${rocr_volume}\n" >> .env
|
||||
printf "hcc_lc_volume=${hcc_lc_volume}\n" >> .env
|
||||
|
||||
printf "\n" >> .env
|
||||
printf "roct_deb_dockerfile=${thunk_dockerfiles[deb]}\n" >> .env
|
||||
printf "roct_src_dockerfile=${thunk_dockerfiles[src]}\n" >> .env
|
||||
printf "rocr_deb_dockerfile=${runtime_dockerfiles[deb]}\n" >> .env
|
||||
printf "rocr_src_dockerfile=${runtime_dockerfiles[src]}\n" >> .env
|
||||
printf "hcc_lc_deb_dockerfile=${hcc_lc_dockerfiles[deb]}\n" >> .env
|
||||
printf "hcc_lc_src_dockerfile=${hcc_lc_dockerfiles[src]}\n" >> .env
|
||||
|
||||
# cat rock/rock-deb-dockerfile.template | envsubst '${repo_branch}:${rock_volume}' > rock/Dockerfile
|
||||
cat roct/${thunk_dockerfiles[deb-template]} | envsubst '${ubuntu_version}' > roct/${thunk_dockerfiles[deb]}
|
||||
cat roct/${thunk_dockerfiles[src-template]} | envsubst '${ubuntu_version}:${tag}:${build_config}:${roct_cleanup}:${roct_volume}:${lib64_install_dir}' > roct/${thunk_dockerfiles[src]}
|
||||
cat rocr/${runtime_dockerfiles[deb-template]} | envsubst '${roct_image_name_deb}' > rocr/${runtime_dockerfiles[deb]}
|
||||
cat rocr/${runtime_dockerfiles[src-template]} | envsubst '${roct_image_name_src}:${tag}:${build_config}:${rocr_cleanup}:${rocm_volume}:${roct_volume}:${rocr_volume}:${lib64_install_dir}' > rocr/${runtime_dockerfiles[src]}
|
||||
cat hcc-lc/${hcc_lc_dockerfiles[deb-template]} | envsubst '${rocr_image_name_deb}' > hcc-lc/${hcc_lc_dockerfiles[deb]}
|
||||
cat hcc-lc/${hcc_lc_dockerfiles[src-template]} | envsubst '${rocr_image_name_src}:${tag}:${build_config}:${rocr_cleanup}:${rocm_volume}:${roct_volume}:${rocr_volume}:${lib64_install_dir}' > hcc-lc/${hcc_lc_dockerfiles[src]}
|
||||
|
||||
Reference in New Issue
Block a user