├── .gitignore ├── CODEOWNERS ├── LICENSE ├── README.md ├── add-rocm.sh ├── build_all.sh ├── dev ├── Dockerfile-almalinux-8-complete ├── Dockerfile-centos-7 ├── Dockerfile-centos-7-complete ├── Dockerfile-manylinux2014_x86_64 ├── Dockerfile-ubuntu-20.04 ├── Dockerfile-ubuntu-20.04-complete ├── Dockerfile-ubuntu-22.04 ├── Dockerfile-ubuntu-22.04-complete ├── Dockerfile-ubuntu-24.04 └── Dockerfile-ubuntu-24.04-complete ├── docker-compose.yml ├── framework ├── JAX │ └── JAX.Dockerfile └── ONNX-RUNTIME │ └── onnxruntime.dockerfile ├── push_all.sh ├── quick-start.md ├── rocm-terminal ├── Dockerfile ├── Dockerfile.post-install └── sudo-nopasswd ├── scripts ├── compatibility-check.sh └── install_versioned_rocm.sh └── setup.sh /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # Precompiled Headers 8 | *.gch 9 | *.pch 10 | 11 | # Compiled Dynamic libraries 12 | *.so 13 | *.dylib 14 | *.dll 15 | 16 | # Fortran module files 17 | *.mod 18 | 19 | # Compiled Static libraries 20 | *.lai 21 | *.la 22 | *.a 23 | *.lib 24 | 25 | # Executables 26 | *.exe 27 | *.out 28 | *.app 29 | 30 | # vim tags 31 | tags 32 | .tags 33 | 34 | # Docker files 35 | Dockerfile 36 | *-dockerfile 37 | .env 38 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @sunway513 @okakarpa @kiran-thumma @amd-aakash 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Advanced Micro Devices, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ROCm-docker 2 | 3 | ## Radeon Open Compute Platform for docker 4 | This repository contains a framework for building the software layers defined in the Radeon Open Compute Platform into portable docker images. The following are docker dependencies, which should be installed on the target machine. 5 | 6 | - Docker on [Ubuntu systems](https://docs.docker.com/v1.8/installation/ubuntulinux/) or [Fedora systems](https://docs.docker.com/v1.8/installation/fedora/) 7 | - Highly recommended: [Docker-Compose](https://docs.docker.com/compose/install/) to simplify container management 8 | 9 | # Docker Hub 10 | Looking for an easy start with ROCm + Docker? The rocm/rocm-terminal image is hosted on [Docker Hub](https://hub.docker.com/r/rocm/rocm-terminal/). After the [ROCm kernel is installed](#install-rocm-kernel), pull the image from Docker Hub and create a new instance of a container. 11 | 12 | ```bash 13 | sudo docker pull rocm/rocm-terminal 14 | sudo docker run -it --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video rocm/rocm-terminal 15 | ``` 16 | 17 | ## ROCm-docker set up guide 18 | [Installation instructions](quick-start.md) and asciicasts demos are available to help users quickly get running with rocm-docker. Visit the set up guide to read more. 19 | 20 | ### F.A.Q 21 | When working with the ROCm containers, the following are common and useful docker commands: 22 | * A new docker container typically **does not** house apt repository meta-data. Before trying to install new software using apt, make sure to run `sudo apt update` first 23 | * A message like the following typically means your user does not have permissions to execute docker; use sudo or [add your user](https://docs.docker.com/engine/installation/linux/ubuntulinux/#/create-a-docker-group) to the docker group. 24 | * `Cannot connect to the Docker daemon. Is the docker daemon running on this host?` 25 | * Open another terminal into a running container 26 | * `sudo docker exec -it bash -l` 27 | * Copy files from host machine into running docker container 28 | * `sudo docker cp HOST_PATH :/PATH` 29 | * Copy files from running docker container onto host machine 30 | * `sudo docker cp :/PATH/TO/FILE HOST_PATH` 31 | * If receiving messages about *no space left on device* when pulling images, check the storage driver in use by the docker engine. If its 'device mapper', that means the image size limits imposed by the 'device mapper' storage driver are a problem 32 | * Follow the documentation in the [quick start guide](quick-start.md) for a solution to change to the storage driver 33 | 34 | #### Saving work in a container 35 | Docker containers are typically ephemeral, and are discarded after closing the container with the '**--rm**' flag to `docker run`. However, there are times when it is desirable to close a container that has arbitrary work in it, and serialize it back into a docker image. This may be to to create a checkpoint in a long and complicated series of instructions, or it may be desired to share the image with others through a docker registry, such as docker hub. 36 | 37 | ```bash 38 | sudo docker ps -a # Find container of interest 39 | sudo docker commit 40 | sudo docker images # Confirm existence of a new image 41 | ``` 42 | [![asciicast](https://asciinema.org/a/bka9uj16zuio4qlnsqcr7nv8z.png)](https://asciinema.org/a/bka9uj16zuio4qlnsqcr7nv8z) 43 | 44 | # Details 45 | Docker does not virtualize or package the linux kernel inside of an image or container. This is a design decision of docker to provide lightweight and fast containerization. The implication for this on the ROCm compute stack is that in order for the docker framework to function, **the ROCm kernel and corresponding modules must be installed on the host machine.** Containers share the host kernel, so the ROCm KFD component ROCK-Kernel-Driver[1](#ROCK) functions outside of docker. 46 | 47 | ### Installing ROCK on the host machine. 48 | An [apt-get repository](https://github.com/RadeonOpenCompute/ROCm/wiki#installing-from-amd-rocm-repositories) is available to automate the installation of the required kernel and kernel modules. 49 | 50 | ## Building images 51 | There are two ways to install rocm components: 52 | 1. install from the rocm apt/rpm repository (repo.radeon.com) 53 | 2. build the components from source and run install scripts 54 | 55 | The first method produces docker images with the smallest footprint and best building speed. The footprint is smaller because no developer tools need to be installed in the image, an the images build speed is fastest because typically downloading binaries is much faster than downloading source and then invoking a build process. Of course, building components allows much greater flexibility on install location and the ability to step through the source with debug builds. ROCm-docker supports making images either way, and depends on the flags passed to the setup script. 56 | 57 | The setup script included in this repository is provides some flexibility to how docker containers are constructed. Unfortunately, Dockerfiles do not have a preprocessor or template language, so typically build instructions are hardcoded. However, the setup script allows us to write a primitive 'template', and after running it instantiates baked dockerfiles with environment variables substituted in. For instance, if you wish to build release images and debug images, first run the setup script to generate release dockerfiles and build the images. Then, run the setup script again and specify debug dockerfiles and build new images. The docker images should generate unique image names and not conflict with each other. 58 | 59 | ## setup.sh 60 | Currently, the setup.sh scripts checks to make sure that it is running on an **Ubuntu system**, as it makes a few assumptions about the availability of tools and file locations. If running rocm on a Fedora machine, inspect the source of setup.sh and issue the appropriate commands manually. There are a few parameters to setup.sh of a generic nature that affects all images built after running. If no parameters are given, built images will be based off of Ubuntu 16.04 with rocm components installed from debians downloaded from repo.radeon.com. Supported parameters can be queried with `./setup --help`. 61 | 62 | | setup.sh parameters | parameter [default]| description | 63 | |-----|-----|-----| 64 | | --ubuntu | xx.yy [16.04] | Ubuntu version for to inherit base image | 65 | | --install-docker-compose | | helper to install the docker-compose tool | 66 | 67 | The following parameters are specific to building containers that compile rocm components from source. 68 | 69 | | setup.sh parameters | parameter [default]| description | 70 | |-----|-----|-----| 71 | | --tag | string ['master'] | string representing a git branch name | 72 | | --branch | string ['master'] | alias for tag | 73 | | --debug | | build code with debug flags | 74 | 75 | `./setup` generates finalized Dockerfiles from textual template files ending with the *.template* suffix. Each sub-directory of this repository corresponds to a docker 'build context' responsible for a software layer in the ROCm stack. After running the script, each directory contains generated dockerfiles for building images from debians and from source. 76 | 77 | ### Docker compose 78 | `./setup` prepares an environment to be controlled with [Docker Compose](https://docs.docker.com/compose/). While docker-compose is not necessary for proper operation, it is highly recommended. setup.sh does provide a flag to simplify the installation of this tool. Docker-compose coordinates the relationships between the various ROCm software layers, and it remembers flags that should be passed to docker to expose devices and import volumes. 79 | 80 | #### Example of using docker-compose 81 | docker-compose.yml provides services that build and run containers. YAML is structured data, so it's easy to modify and extend. The *setup.sh* script generates a *.env* file that docker-compose reads to satisfy the definitions of the variables in the .yml file. 82 | * `docker-compose run --rm rocm` -- Run container using rocm packages 83 | * `docker-compose run --rm rocm-from-src` -- Run container with rocm built from source 84 | 85 | 86 | | Docker-compose | description | 87 | |-----|-----| 88 | | docker-compose | docker compose executable| 89 | | run | sub-command to bring up interactive container | 90 | | --rm | when shutting the container down, delete it | 91 | | rocm | application service defined in **docker-compose.yml** | 92 | 93 | ### rocm-user has root privileges by default 94 | The dockerfile that serves as a 'terminal' creates a non-root user called **rocm-user**. This container is meant to serve as a development environment (therefore `apt-get` is likely needed), the user has been added to the linux sudo group. Since it is somewhat difficult to set and change passwords in a container (often requiring a rebuild), the password prompt has been disabled for the sudo group. While this is convenient for development to be able `sudo apt-get install` packages, it does imply *lower security* in the container. 95 | 96 | To increase container security: 97 | 98 | 1. Eliminate the sudo-nopasswd COPY statement in the dockerfile and replace with 99 | 2. Your own password with `RUN echo 'account:password' | chpasswd` 100 | 101 | The docker.ce release 18.02 has known defects working with **rocm-user** account insider docker image. 102 | Please upgrade docker package to the [18.04 build](https://download.docker.com/linux/ubuntu/dists/xenial/pool/nightly/amd64/docker-ce_18.04.0~ce~dev~git20180313.171447.0.6e4307b-0~ubuntu_amd64.deb). 103 | ### Footnotes: 104 | [1] It can be installed into a container, it just doesn't do anything because containers do not go through the traditional boot process. We actually do provide a container for ROCK-Kernel-Driver, but it not used by the rest of the docker images. It does provide isolation and a reproducible environment for kernel development. 105 | -------------------------------------------------------------------------------- /add-rocm.sh: -------------------------------------------------------------------------------- 1 | 2 | #!/bin/bash 3 | # ################################################# 4 | # Copyright (c) 2017 Advanced Micro Devices, Inc. 5 | # ################################################# 6 | # Author: Paul Fultz II 7 | 8 | set -ex 9 | 10 | apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y curl bzip2 apt-utils wget 11 | 12 | function add_repo { 13 | sh -c "echo deb [arch=amd64] $1 xenial main > /etc/apt/sources.list.d/rocm.list" 14 | } 15 | 16 | function add_local_repo { 17 | sh -c "echo deb [trusted=yes] file://$1 xenial main > /etc/apt/sources.list.d/rocm.list" 18 | } 19 | 20 | function download_repo { 21 | mkdir -p /repo/tmp 22 | curl $1 | tar --strip-components=1 -x --bzip2 -C /repo/tmp 23 | # Some archives are in a debian directory 24 | if [ -d "/repo/tmp/debian" ]; then 25 | mv /repo/tmp /repo/radeon 26 | else 27 | mkdir -p /repo/radeon 28 | mv /repo/tmp /repo/radeon/debian 29 | fi 30 | cat /repo/radeon/debian/rocm.gpg.key | apt-key add - 31 | add_local_repo /repo/radeon/debian 32 | } 33 | 34 | 35 | if [ -e /sys/module/amdgpu/version ]; then 36 | KERNEL_VERSION=$(cat /sys/module/amdgpu/version) 37 | KERNEL_SRC_VERSION=$(cat /sys/module/amdgpu/srcversion) 38 | 39 | if [ "$KERNEL_VERSION" == "18.30.2.15" ]; then 40 | download_repo http://repo.radeon.com/rocm/archive/apt_1.9.2.tar.bz2 41 | elif [ "$KERNEL_VERSION" == "19.10.0.418" ]; then 42 | download_repo http://repo.radeon.com/rocm/archive/apt_2.0.0.tar.bz2 43 | elif [ "$KERNEL_VERSION" == "19.10.7.418" ]; then 44 | add_repo http://repo.radeon.com/rocm/apt/2.1 45 | elif [ "$KERNEL_VERSION" == "19.10.8.418" ]; then 46 | add_repo http://repo.radeon.com/rocm/apt/2.2 47 | elif [ "$KERNEL_VERSION" == "5.0.19.20.6" ]; then 48 | add_repo http://repo.radeon.com/rocm/apt/2.3 49 | elif [ "$KERNEL_VERSION" == "5.0.19.20.14" ]; then 50 | add_repo http://repo.radeon.com/rocm/apt/2.4 51 | elif [ "$KERNEL_VERSION" == "19.10.9.418" ]; then 52 | add_repo http://repo.radeon.com/rocm/apt/2.5 53 | elif [ "$KERNEL_VERSION" == "5.0.71" ]; then 54 | add_repo http://repo.radeon.com/rocm/apt/2.6 55 | elif [ "$KERNEL_VERSION" == "5.0.76" ]; then 56 | add_repo http://repo.radeon.com/rocm/apt/2.7 57 | elif [ "$KERNEL_VERSION" == "5.0.79" ]; then 58 | add_repo http://repo.radeon.com/rocm/apt/2.8.0 59 | elif [ "$KERNEL_VERSION" == "5.0.82" ]; then 60 | add_repo http://repo.radeon.com/rocm/apt/2.10.0 61 | elif [ "$KERNEL_VERSION" == "5.2.4" ]; then 62 | add_repo http://repo.radeon.com/rocm/apt/3.0 63 | elif [ "$KERNEL_VERSION" == "5.4.4" ]; then 64 | add_repo http://repo.radeon.com/rocm/apt/3.1 65 | else 66 | add_repo http://repo.radeon.com/rocm/apt/debian/ 67 | fi 68 | 69 | else 70 | add_repo http://repo.radeon.com/rocm/apt/debian/ 71 | fi 72 | 73 | # Install key 74 | wget -O - http://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - 75 | apt-get update 76 | 77 | -------------------------------------------------------------------------------- /build_all.sh: -------------------------------------------------------------------------------- 1 | ROCM_VERSION=6.4.1 2 | AMDGPU_VERSION=6.4.1 3 | 4 | cp -r scripts rocm-terminal 5 | cp -r scripts dev 6 | 7 | # build rocm-terminal 8 | cd rocm-terminal/ 9 | sudo docker build . -f Dockerfile -t rocm/rocm-terminal:$ROCM_VERSION --build-arg=ROCM_VERSION=$ROCM_VERSION --build-arg=AMDGPU_VERSION=$AMDGPU_VERSION --build-arg=APT_PREF="Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600" 10 | sudo docker tag rocm/rocm-terminal:$ROCM_VERSION rocm/rocm-terminal:latest 11 | 12 | # build dev dockers 13 | cd ../dev 14 | 15 | # manylinux2014_x86_64 16 | sudo docker build . -f Dockerfile-manylinux2014_x86_64 -t rocm/dev-manylinux2014_x86_64:$ROCM_VERSION --build-arg=ROCM_VERSION=$ROCM_VERSION --build-arg=AMDGPU_VERSION=$AMDGPU_VERSION 17 | sudo docker tag rocm/dev-manylinux2014_x86_64:$ROCM_VERSION rocm/dev-manylinux2014_x86_64:latest 18 | 19 | # ubuntu20.04 20 | sudo docker build . -f Dockerfile-ubuntu-20.04 -t rocm/dev-ubuntu-20.04:$ROCM_VERSION --build-arg=ROCM_VERSION=$ROCM_VERSION --build-arg=AMDGPU_VERSION=$AMDGPU_VERSION 21 | sudo docker tag rocm/dev-ubuntu-20.04:$ROCM_VERSION rocm/dev-ubuntu-20.04:latest 22 | 23 | # ubuntu20.04 complete 24 | sudo docker build . -f Dockerfile-ubuntu-20.04-complete -t rocm/dev-ubuntu-20.04:$ROCM_VERSION-complete --build-arg=ROCM_VERSION=$ROCM_VERSION --build-arg=AMDGPU_VERSION=$AMDGPU_VERSION 25 | 26 | # ubuntu22.04 27 | sudo docker build . -f Dockerfile-ubuntu-22.04 -t rocm/dev-ubuntu-22.04:$ROCM_VERSION --build-arg=ROCM_VERSION=$ROCM_VERSION --build-arg=AMDGPU_VERSION=$AMDGPU_VERSION --build-arg=APT_PREF="Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600" 28 | sudo docker tag rocm/dev-ubuntu-22.04:$ROCM_VERSION rocm/dev-ubuntu-22.04:latest 29 | 30 | # ubuntu22.04 complete 31 | sudo docker build . -f Dockerfile-ubuntu-22.04-complete -t rocm/dev-ubuntu-22.04:$ROCM_VERSION-complete --build-arg=ROCM_VERSION=$ROCM_VERSION --build-arg=AMDGPU_VERSION=$AMDGPU_VERSION --build-arg=APT_PREF="Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600" 32 | 33 | # almalinux8 complete (for manylinux2_28 builds) 34 | sudo docker build . -f Dockerfile-almalinux-8-complete -t rocm/dev-almalinux-8:$ROCM_VERSION-complete --build-arg=ROCM_VERSION=$ROCM_VERSION --build-arg=AMDGPU_VERSION=$AMDGPU_VERSION 35 | 36 | ## ubuntu24.04 37 | sudo docker build . -f Dockerfile-ubuntu-24.04 -t rocm/dev-ubuntu-24.04:$ROCM_VERSION --build-arg=ROCM_VERSION=$ROCM_VERSION --build-arg=AMDGPU_VERSION=$AMDGPU_VERSION --build-arg=APT_PREF="Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600" 38 | sudo docker tag rocm/dev-ubuntu-24.04:$ROCM_VERSION rocm/dev-ubuntu-24.04:latest 39 | 40 | ## ubuntu24.04 complete 41 | sudo docker build . -f Dockerfile-ubuntu-24.04-complete -t rocm/dev-ubuntu-24.04:$ROCM_VERSION-complete --build-arg=ROCM_VERSION=$ROCM_VERSION --build-arg=AMDGPU_VERSION=$AMDGPU_VERSION --build-arg=APT_PREF="Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600" 42 | -------------------------------------------------------------------------------- /dev/Dockerfile-almalinux-8-complete: -------------------------------------------------------------------------------- 1 | FROM amd64/almalinux:8 2 | LABEL maintainer=dl.mlsedevops@amd.com 3 | 4 | ARG ROCM_VERSION=6.4.1 5 | ARG AMDGPU_VERSION=6.4.1 6 | 7 | # Base 8 | RUN yum -y install git java-1.8.0-openjdk python39; yum clean all 9 | 10 | # Enable epel-release repositories 11 | RUN dnf install -y 'dnf-command(config-manager)' 12 | RUN dnf config-manager --set-enabled powertools 13 | RUN dnf install -y epel-release 14 | 15 | # Install required base build and packaging commands for ROCm 16 | RUN yum -y install \ 17 | ca-certificates \ 18 | bc \ 19 | bridge-utils \ 20 | cmake \ 21 | cmake3 \ 22 | dkms \ 23 | doxygen \ 24 | dpkg \ 25 | dpkg-dev \ 26 | dpkg-perl \ 27 | elfutils-libelf-devel \ 28 | expect \ 29 | file \ 30 | python3-devel \ 31 | python3-pip \ 32 | gettext \ 33 | gcc-c++ \ 34 | libgcc \ 35 | lzma \ 36 | glibc.i686 \ 37 | ncurses \ 38 | ncurses-base \ 39 | ncurses-libs \ 40 | numactl-devel \ 41 | numactl-libs \ 42 | libssh \ 43 | libunwind-devel \ 44 | libunwind \ 45 | llvm \ 46 | llvm-libs \ 47 | make \ 48 | openssl \ 49 | openssl-libs \ 50 | openssh \ 51 | openssh-clients \ 52 | pciutils \ 53 | pciutils-devel \ 54 | pciutils-libs \ 55 | perl \ 56 | pkgconfig \ 57 | qemu-kvm \ 58 | re2c \ 59 | kmod \ 60 | rpm \ 61 | rpm-build \ 62 | subversion \ 63 | wget 64 | 65 | # Enable the epel repository for fakeroot 66 | RUN yum install -y fakeroot 67 | RUN yum clean all 68 | 69 | # Install devtoolset 9 70 | RUN yum install -y gcc-toolset-9 71 | RUN yum install -y gcc-toolset-9-libatomic-devel gcc-toolset-9-elfutils-libelf-devel 72 | 73 | # Install ROCm repo paths 74 | RUN echo -e "[ROCm]\nname=ROCm\nbaseurl=https://repo.radeon.com/rocm/rhel8/$ROCM_VERSION/main\nenabled=1\ngpgcheck=0\npriority=50" >> /etc/yum.repos.d/rocm.repo 75 | RUN echo -e "[amdgpu]\nname=amdgpu\nbaseurl=https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/rhel/8.9/main/x86_64\nenabled=1\ngpgcheck=0\npriority=50" >> /etc/yum.repos.d/amdgpu.repo 76 | 77 | # Install versioned ROCm packages eg. rocm-dev6.4.1.0 to avoid issues with "yum update" pulling really old rocm-dev packages from epel 78 | # COPY scripts/install_versioned_rocm.sh install_versioned_rocm.sh 79 | # RUN bash install_versioned_rocm.sh ${ROCM_VERSION} 80 | # RUN rm install_versioned_rocm.sh 81 | 82 | RUN yum install -y rocm-dev rocm-libs 83 | 84 | # Set ENV to enable devtoolset9 by default 85 | ENV PATH=/opt/rh/gcc-toolset-9/root/usr/bin:/opt/rocm/bin:${PATH:+:${PATH}} 86 | ENV MANPATH=/opt/rh/gcc-toolset-9/root/usr/share/man:${MANPATH} 87 | ENV INFOPATH=/opt/rh/gcc-toolset-9/root/usr/share/info:${INFOPATH:+:${INFOPATH}} 88 | ENV PCP_DIR=/opt/rh/gcc-toolset-9/root 89 | ENV PERL5LIB=/opt/rh/gcc-toolset-9/root/usr/lib64/perl5/vendor_perl 90 | ENV LD_LIBRARY_PATH=/opt/rocm/lib:/usr/local/lib:/opt/rh/gcc-toolset-9/root/lib:/opt/rh/gcc-toolset-9/root/lib64:${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} 91 | 92 | # ENV PYTHONPATH=/opt/rh/gcc-toolset-9/root/ 93 | 94 | ENV LDFLAGS="-Wl,-rpath=/opt/rh/gcc-toolset-9/root/usr/lib64 -Wl,-rpath=/opt/rh/gcc-toolset-9/root/usr/lib" 95 | -------------------------------------------------------------------------------- /dev/Dockerfile-centos-7: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | LABEL maintainer=dl.mlsedevops@amd.com 3 | 4 | ARG ROCM_VERSION=6.2.4 5 | ARG AMDGPU_VERSION=6.2.4 6 | 7 | # Note: This is required patch since CentOS have reached EOL 8 | # otherwise any yum install setup will fail 9 | RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo 10 | RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo 11 | RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo 12 | 13 | # Base 14 | RUN yum -y install git java-1.8.0-openjdk python; yum clean all 15 | 16 | # Enable epel-release repositories 17 | RUN yum --enablerepo=extras install -y epel-release 18 | 19 | # Install required base build and packaging commands for ROCm 20 | RUN yum -y install \ 21 | ca-certificates \ 22 | bc \ 23 | bridge-utils \ 24 | cmake \ 25 | cmake3 \ 26 | devscripts \ 27 | dkms \ 28 | doxygen \ 29 | dpkg \ 30 | dpkg-dev \ 31 | dpkg-perl \ 32 | elfutils-libelf-devel \ 33 | expect \ 34 | file \ 35 | python3-dev \ 36 | python3-pip \ 37 | gettext \ 38 | gcc-c++ \ 39 | libgcc \ 40 | glibc.i686 \ 41 | libcxx-devel \ 42 | ncurses \ 43 | ncurses-base \ 44 | ncurses-libs \ 45 | numactl-devel \ 46 | numactl-libs \ 47 | libssh \ 48 | libunwind-devel \ 49 | libunwind \ 50 | llvm \ 51 | llvm-libs \ 52 | make \ 53 | openssl \ 54 | openssl-libs \ 55 | openssh \ 56 | openssh-clients \ 57 | pciutils \ 58 | pciutils-devel \ 59 | pciutils-libs \ 60 | python \ 61 | python-pip \ 62 | python-devel \ 63 | pkgconfig \ 64 | pth \ 65 | qemu-kvm \ 66 | re2c \ 67 | kmod \ 68 | file \ 69 | rpm \ 70 | rpm-build \ 71 | subversion \ 72 | wget 73 | 74 | # Enable the epel repository for fakeroot 75 | RUN yum --enablerepo=extras install -y fakeroot 76 | RUN yum clean all 77 | 78 | # On CentOS, install package centos-release-scl available in CentOS repository: 79 | RUN yum install -y centos-release-scl 80 | 81 | # Note: This is required patch since CentOS have reached EOL 82 | # otherwise any yum install setup will fail 83 | # Needed here again because above step adds new repo entries 84 | RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo 85 | RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo 86 | RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo 87 | 88 | # # Install the devtoolset-9 collection: 89 | #RUN yum install -y devtoolset-9 90 | #RUN yum install -y devtoolset-9-libatomic-devel devtoolset-9-elfutils-libelf-devel 91 | 92 | # Install the devtoolset-9 collection: 93 | RUN yum install -y devtoolset-9 94 | RUN yum install -y devtoolset-9-libatomic-devel devtoolset-9-elfutils-libelf-devel 95 | 96 | # Install the ROCm rpms 97 | RUN yum clean all 98 | RUN echo -e "[ROCm]\nname=ROCm\nbaseurl=https://repo.radeon.com/rocm/yum/$ROCM_VERSION/main\nenabled=1\ngpgcheck=0" >> /etc/yum.repos.d/rocm.repo 99 | RUN echo -e "[amdgpu]\nname=amdgpu\nbaseurl=https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/rhel/7.9/main/x86_64\nenabled=1\ngpgcheck=0" >> /etc/yum.repos.d/amdgpu.repo 100 | 101 | RUN yum install -y rocm-dev 102 | 103 | # Set ENV to enable devtoolset7 by default 104 | ENV PATH=/opt/rh/devtoolset-9/root/usr/bin:/opt/rocm/hcc/bin:/opt/rocm/hip/bin:/opt/rocm/bin:/opt/rocm/hcc/bin:${PATH:+:${PATH}} 105 | ENV MANPATH=/opt/rh/devtoolset-9/root/usr/share/man:${MANPATH} 106 | ENV INFOPATH=/opt/rh/devtoolset-9/root/usr/share/info${INFOPATH:+:${INFOPATH}} 107 | ENV PCP_DIR=/opt/rh/devtoolset-9/root 108 | ENV PERL5LIB=/opt/rh/devtoolset-9/root//usr/lib64/perl5/vendor_perl:/opt/rh/devtoolset-9/root/usr/lib/perl5:/opt/rh/devtoolset-9/root//usr/share/perl5/ 109 | ENV LD_LIBRARY_PATH=/opt/rocm/lib:/usr/local/lib:/opt/rh/devtoolset-9/root$rpmlibdir$rpmlibdir32${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} 110 | ENV PYTHONPATH=/opt/rh/devtoolset-9/root/usr/lib64/python$pythonvers/site-packages:/opt/rh/devtoolset-9/root/usr/lib/python$pythonvers/ 111 | ENV LDFLAGS="-Wl,-rpath=/opt/rh/devtoolset-9/root/usr/lib64 -Wl,-rpath=/opt/rh/devtoolset-9/root/usr/lib" 112 | -------------------------------------------------------------------------------- /dev/Dockerfile-centos-7-complete: -------------------------------------------------------------------------------- 1 | FROM centos:7 2 | LABEL maintainer=dl.mlsedevops@amd.com 3 | 4 | ARG ROCM_VERSION=6.2.4 5 | ARG AMDGPU_VERSION=6.2.4 6 | 7 | # Note: This is required patch since CentOS have reached EOL 8 | # otherwise any yum install setp will fail 9 | RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo 10 | RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo 11 | RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo 12 | 13 | # Base 14 | RUN yum -y install git java-1.8.0-openjdk python; yum clean all 15 | 16 | # Enable epel-release repositories 17 | RUN yum --enablerepo=extras install -y epel-release 18 | 19 | # Install required base build and packaging commands for ROCm 20 | RUN yum -y install \ 21 | ca-certificates \ 22 | bc \ 23 | bridge-utils \ 24 | cmake \ 25 | cmake3 \ 26 | devscripts \ 27 | dkms \ 28 | doxygen \ 29 | dpkg \ 30 | dpkg-dev \ 31 | dpkg-perl \ 32 | elfutils-libelf-devel \ 33 | expect \ 34 | file \ 35 | python3-dev \ 36 | python3-pip \ 37 | gettext \ 38 | gcc-c++ \ 39 | libgcc \ 40 | glibc.i686 \ 41 | libcxx-devel \ 42 | ncurses \ 43 | ncurses-base \ 44 | ncurses-libs \ 45 | numactl-devel \ 46 | numactl-libs \ 47 | libssh \ 48 | libunwind-devel \ 49 | libunwind \ 50 | llvm \ 51 | llvm-libs \ 52 | make \ 53 | openssl \ 54 | openssl-libs \ 55 | openssh \ 56 | openssh-clients \ 57 | pciutils \ 58 | pciutils-devel \ 59 | pciutils-libs \ 60 | python \ 61 | python-pip \ 62 | python-devel \ 63 | pkgconfig \ 64 | pth \ 65 | qemu-kvm \ 66 | re2c \ 67 | kmod \ 68 | file \ 69 | rpm \ 70 | rpm-build \ 71 | subversion \ 72 | wget 73 | 74 | # Enable the epel repository for fakeroot 75 | RUN yum --enablerepo=extras install -y fakeroot 76 | RUN yum clean all 77 | 78 | # On CentOS, install package centos-release-scl available in CentOS repository: 79 | RUN yum install -y centos-release-scl 80 | 81 | # Note: This is required patch since CentOS have reached EOL 82 | # otherwise any yum install setup will fail 83 | # Needed here again because above step adds new repo entries 84 | RUN sed -i s/mirror.centos.org/vault.centos.org/g /etc/yum.repos.d/*.repo 85 | RUN sed -i s/^#.*baseurl=http/baseurl=http/g /etc/yum.repos.d/*.repo 86 | RUN sed -i s/^mirrorlist=http/#mirrorlist=http/g /etc/yum.repos.d/*.repo 87 | 88 | # Install the devtoolset-7 collection: 89 | RUN yum install -y devtoolset-7 90 | RUN yum install -y devtoolset-7-libatomic-devel devtoolset-7-elfutils-libelf-devel 91 | 92 | # Install the ROCm rpms 93 | RUN yum clean all 94 | RUN echo -e "[ROCm]\nname=ROCm\nbaseurl=https://repo.radeon.com/rocm/yum/$ROCM_VERSION/main\nenabled=1\ngpgcheck=0" >> /etc/yum.repos.d/rocm.repo 95 | RUN echo -e "[amdgpu]\nname=amdgpu\nbaseurl=https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/rhel/7.9/main/x86_64\nenabled=1\ngpgcheck=0" >> /etc/yum.repos.d/amdgpu.repo 96 | 97 | RUN yum install -y rocm-dev rocm-libs 98 | 99 | # Set ENV to enable devtoolset7 by default 100 | ENV PATH=/opt/rh/devtoolset-7/root/usr/bin:/opt/rocm/hcc/bin:/opt/rocm/hip/bin:/opt/rocm/bin:/opt/rocm/hcc/bin:${PATH:+:${PATH}} 101 | ENV MANPATH=/opt/rh/devtoolset-7/root/usr/share/man:${MANPATH} 102 | ENV INFOPATH=/opt/rh/devtoolset-7/root/usr/share/info${INFOPATH:+:${INFOPATH}} 103 | ENV PCP_DIR=/opt/rh/devtoolset-7/root 104 | ENV PERL5LIB=/opt/rh/devtoolset-7/root//usr/lib64/perl5/vendor_perl:/opt/rh/devtoolset-7/root/usr/lib/perl5:/opt/rh/devtoolset-7/root//usr/share/perl5/ 105 | ENV LD_LIBRARY_PATH=/opt/rocm/lib:/usr/local/lib:/opt/rh/devtoolset-7/root$rpmlibdir$rpmlibdir32${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}} 106 | ENV PYTHONPATH=/opt/rh/devtoolset-7/root/usr/lib64/python$pythonvers/site-packages:/opt/rh/devtoolset-7/root/usr/lib/python$pythonvers/ 107 | ENV LDFLAGS="-Wl,-rpath=/opt/rh/devtoolset-7/root/usr/lib64 -Wl,-rpath=/opt/rh/devtoolset-7/root/usr/lib" 108 | -------------------------------------------------------------------------------- /dev/Dockerfile-manylinux2014_x86_64: -------------------------------------------------------------------------------- 1 | FROM quay.io/pypa/manylinux2014_x86_64 2 | LABEL maintainer=dl.mlsedevops@amd.com 3 | 4 | #NOTE: manylinux image already has devtoolset installed 5 | 6 | ARG ROCM_VERSION=6.4.1 7 | ARG AMDGPU_VERSION=6.4.1 8 | 9 | # Install the ROCm rpms 10 | RUN yum clean all 11 | RUN echo -e "[ROCm]\nname=ROCm\nbaseurl=https://repo.radeon.com/rocm/yum/$ROCM_VERSION/main\nenabled=1\ngpgcheck=0" >> /etc/yum.repos.d/rocm.repo 12 | RUN echo -e "[amdgpu]\nname=amdgpu\nbaseurl=https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/rhel/7/main/x86_64\nenabled=1\ngpgcheck=0" >> /etc/yum.repos.d/amdgpu.repo 13 | 14 | RUN yum install -y rocm-dev 15 | -------------------------------------------------------------------------------- /dev/Dockerfile-ubuntu-20.04: -------------------------------------------------------------------------------- 1 | # This dockerfile is meant to serve as a rocm base image. It registers the debian rocm package repository, and 2 | # installs the rocm-dev package. 3 | 4 | FROM ubuntu:20.04 5 | LABEL maintainer=dl.mlsedevops@amd.com 6 | 7 | # Register the ROCM package repository, and install rocm-dev package 8 | ARG ROCM_VERSION=6.4 9 | ARG AMDGPU_VERSION=6.4 10 | 11 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl libnuma-dev gnupg \ 12 | && curl -sL https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - \ 13 | && printf "deb [arch=amd64] https://repo.radeon.com/rocm/apt/$ROCM_VERSION/ ubuntu main" | tee /etc/apt/sources.list.d/rocm.list \ 14 | && printf "deb [arch=amd64] https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/ubuntu focal main" | tee /etc/apt/sources.list.d/amdgpu.list \ 15 | && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ 16 | sudo \ 17 | libelf1 \ 18 | kmod \ 19 | file \ 20 | python3-dev \ 21 | python3-pip \ 22 | rocm-dev \ 23 | build-essential && \ 24 | apt-get clean && \ 25 | rm -rf /var/lib/apt/lists/* 26 | RUN groupadd -g 109 render 27 | -------------------------------------------------------------------------------- /dev/Dockerfile-ubuntu-20.04-complete: -------------------------------------------------------------------------------- 1 | # This dockerfile is meant to serve as a rocm base image. It registers the debian rocm package repository, and 2 | # installs the rocm-dev package. 3 | 4 | FROM ubuntu:20.04 5 | LABEL maintainer=dl.mlsedevops@amd.com 6 | 7 | # Register the ROCM package repository, and install rocm-dev package 8 | ARG ROCM_VERSION=6.4 9 | ARG AMDGPU_VERSION=6.4 10 | 11 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl libnuma-dev gnupg \ 12 | && curl -sL https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - \ 13 | && printf "deb [arch=amd64] https://repo.radeon.com/rocm/apt/$ROCM_VERSION/ ubuntu main" | tee /etc/apt/sources.list.d/rocm.list \ 14 | && printf "deb [arch=amd64] https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/ubuntu focal main" | tee /etc/apt/sources.list.d/amdgpu.list \ 15 | && apt-get update \ 16 | && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ 17 | sudo \ 18 | libelf1 \ 19 | kmod \ 20 | file \ 21 | python3-dev \ 22 | python3-pip \ 23 | rocm-dev \ 24 | rocm-libs \ 25 | build-essential && \ 26 | apt-get clean && \ 27 | rm -rf /var/lib/apt/lists/* 28 | RUN groupadd -g 109 render 29 | -------------------------------------------------------------------------------- /dev/Dockerfile-ubuntu-22.04: -------------------------------------------------------------------------------- 1 | # This dockerfile is meant to serve as a rocm base image. It registers the debian rocm package repository, and 2 | # installs the rocm-dev package. 3 | 4 | FROM ubuntu:22.04 5 | LABEL maintainer=dl.mlsedevops@amd.com 6 | 7 | # Register the ROCM package repository, and install rocm-dev package 8 | ARG ROCM_VERSION=6.4.1 9 | ARG AMDGPU_VERSION=6.4.1 10 | 11 | ARG APT_PREF 12 | RUN echo "$APT_PREF" > /etc/apt/preferences.d/rocm-pin-600 13 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl libnuma-dev gnupg \ 14 | && curl -sL https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - \ 15 | && printf "deb [arch=amd64] https://repo.radeon.com/rocm/apt/$ROCM_VERSION/ jammy main" | tee /etc/apt/sources.list.d/rocm.list \ 16 | && printf "deb [arch=amd64] https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/ubuntu jammy main" | tee /etc/apt/sources.list.d/amdgpu.list \ 17 | && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ 18 | sudo \ 19 | libelf1 \ 20 | kmod \ 21 | file \ 22 | python3-dev \ 23 | python3-pip \ 24 | rocm-dev \ 25 | build-essential && \ 26 | apt-get clean && \ 27 | rm -rf /var/lib/apt/lists/* 28 | 29 | RUN groupadd -g 109 render 30 | -------------------------------------------------------------------------------- /dev/Dockerfile-ubuntu-22.04-complete: -------------------------------------------------------------------------------- 1 | # This dockerfile is meant to serve as a rocm base image. It registers the debian rocm package repository, and 2 | # installs the rocm-dev package. 3 | 4 | FROM ubuntu:22.04 5 | LABEL maintainer=dl.mlsedevops@amd.com 6 | 7 | # Register the ROCM package repository, and install rocm-dev package 8 | ARG ROCM_VERSION=6.4.1 9 | ARG AMDGPU_VERSION=6.4.1 10 | 11 | ARG APT_PREF 12 | RUN echo "$APT_PREF" > /etc/apt/preferences.d/rocm-pin-600 13 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl libnuma-dev gnupg \ 14 | && curl -sL https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - \ 15 | && printf "deb [arch=amd64] https://repo.radeon.com/rocm/apt/$ROCM_VERSION/ jammy main" | tee /etc/apt/sources.list.d/rocm.list \ 16 | && printf "deb [arch=amd64] https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/ubuntu jammy main" | tee /etc/apt/sources.list.d/amdgpu.list \ 17 | && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ 18 | sudo \ 19 | libelf1 \ 20 | kmod \ 21 | file \ 22 | python3-dev \ 23 | python3-pip \ 24 | rocm-dev \ 25 | rocm-libs \ 26 | build-essential && \ 27 | apt-get clean && \ 28 | rm -rf /var/lib/apt/lists/* 29 | 30 | RUN groupadd -g 109 render 31 | -------------------------------------------------------------------------------- /dev/Dockerfile-ubuntu-24.04: -------------------------------------------------------------------------------- 1 | # This dockerfile is meant to serve as a rocm base image. It registers the debian rocm package repository, and 2 | # installs the rocm-dev package. 3 | 4 | FROM ubuntu:24.04 5 | LABEL maintainer=dl.mlsedevops@amd.com 6 | 7 | # Register the ROCM package repository, and install rocm-dev package 8 | ARG ROCM_VERSION=6.4.1 9 | ARG AMDGPU_VERSION=6.4.1 10 | 11 | ARG APT_PREF 12 | RUN echo "$APT_PREF" > /etc/apt/preferences.d/rocm-pin-600 13 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl libnuma-dev gnupg \ 14 | && curl -sL https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - \ 15 | && printf "deb [arch=amd64] https://repo.radeon.com/rocm/apt/$ROCM_VERSION/ noble main" | tee /etc/apt/sources.list.d/rocm.list \ 16 | && printf "deb [arch=amd64] https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/ubuntu noble main" | tee /etc/apt/sources.list.d/amdgpu.list \ 17 | && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ 18 | sudo \ 19 | libelf1 \ 20 | kmod \ 21 | file \ 22 | python3-dev \ 23 | python3-pip \ 24 | rocm-dev \ 25 | build-essential && \ 26 | apt-get clean && \ 27 | rm -rf /var/lib/apt/lists/* 28 | 29 | RUN groupadd -g 109 render 30 | -------------------------------------------------------------------------------- /dev/Dockerfile-ubuntu-24.04-complete: -------------------------------------------------------------------------------- 1 | # This dockerfile is meant to serve as a rocm base image. It registers the debian rocm package repository, and 2 | # installs the rocm-dev package. 3 | 4 | FROM ubuntu:24.04 5 | LABEL maintainer=dl.mlsedevops@amd.com 6 | 7 | # Register the ROCM package repository, and install rocm-dev package 8 | ARG ROCM_VERSION=6.4.1 9 | ARG AMDGPU_VERSION=6.4.1 10 | 11 | ARG APT_PREF 12 | RUN echo "$APT_PREF" > /etc/apt/preferences.d/rocm-pin-600 13 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl libnuma-dev gnupg \ 14 | && curl -sL https://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - \ 15 | && printf "deb [arch=amd64] https://repo.radeon.com/rocm/apt/$ROCM_VERSION/ noble main" | tee --append /etc/apt/sources.list.d/rocm.list \ 16 | && printf "deb [arch=amd64] https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/ubuntu noble main" | tee /etc/apt/sources.list.d/amdgpu.list \ 17 | && apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ 18 | sudo \ 19 | libelf1 \ 20 | kmod \ 21 | file \ 22 | python3-dev \ 23 | python3-pip \ 24 | rocm-dev \ 25 | rocm-libs \ 26 | build-essential && \ 27 | apt-get clean && \ 28 | rm -rf /var/lib/apt/lists/* 29 | 30 | RUN groupadd -g 109 render 31 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '2.1' 2 | 3 | 4 | services: 5 | # The following are images built from debians downloaded from a package repository 6 | roct-deb: 7 | build: 8 | context: ./roct 9 | dockerfile: ${roct_deb_dockerfile} 10 | image: ${roct_image_name_deb} 11 | container_name: roct-deb 12 | 13 | rocr-deb: 14 | depends_on: 15 | - roct-deb 16 | build: 17 | context: ./rocr 18 | dockerfile: ${rocr_deb_dockerfile} 19 | image: ${rocr_image_name_deb} 20 | container_name: rocr-deb 21 | 22 | hcc-lc-deb: 23 | depends_on: 24 | - rocr-deb 25 | build: 26 | context: ./hcc-lc 27 | dockerfile: ${hcc_lc_deb_dockerfile} 28 | image: ${hcc_lc_image_name_deb} 29 | container_name: hcc-lc-deb 30 | 31 | # The following are images built from rocm source 32 | roct-src: 33 | build: 34 | context: ./roct 35 | dockerfile: ${roct_src_dockerfile} 36 | image: ${roct_image_name_src} 37 | container_name: roct-src 38 | volumes: 39 | - ${roct_volume} 40 | 41 | rocr-src: 42 | depends_on: 43 | - roct-src 44 | build: 45 | context: ./rocr 46 | dockerfile: ${rocr_src_dockerfile} 47 | image: ${rocr_image_name_src} 48 | container_name: rocr-src 49 | volumes: 50 | - ${rocr_volume} 51 | 52 | hcc-lc-src: 53 | depends_on: 54 | - rocr-src 55 | build: 56 | context: ./hcc-lc 57 | dockerfile: ${hcc_lc_src_dockerfile} 58 | image: ${hcc_lc_image_name_src} 59 | container_name: hcc-lc-src 60 | 61 | # The following defines application containers, which depend on the data-only 62 | # containers defined above to provide their software layers 63 | # These should be run with `docker-compose run --rm ` 64 | rocm: 65 | build: 66 | context: ./rocm-terminal 67 | dockerfile: Dockerfile 68 | devices: 69 | - "/dev/kfd" 70 | image: rocm/rocm-terminal 71 | volumes: 72 | - ~:/usr/local/src/host-home 73 | 74 | rocm-from-src: 75 | build: 76 | context: ./rocm-terminal 77 | dockerfile: Dockerfile 78 | devices: 79 | - "/dev/kfd" 80 | image: rocm/rocm-terminal 81 | volumes: 82 | - ~:/usr/local/src/host-home 83 | volumes_from: 84 | - roct-src:ro 85 | - rocr-src:ro 86 | - hcc-lc-src:ro 87 | # - hcc-hsail-src:ro 88 | 89 | dev-ubuntu: 90 | build: 91 | context: ./dev 92 | dockerfile: Dockerfile-ubuntu-16.04 93 | devices: 94 | - "/dev/kfd" 95 | image: rocm/dev-ubuntu-16.04 96 | 97 | dev-fedora: 98 | build: 99 | context: ./dev 100 | dockerfile: Dockerfile-fedora-24 101 | devices: 102 | - "/dev/kfd" 103 | image: rocm/dev-fedora-24 104 | -------------------------------------------------------------------------------- /framework/JAX/JAX.Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:24.04 2 | 3 | ARG ROCM_VERSION=6.4 4 | ARG AMDGPU_VERSION=6.4.60400 5 | ARG JAX_VERSION=0.4.35 6 | ARG PYTHON_VERSION=cp312-cp312 7 | 8 | #Prequisite packages 9 | RUN apt update && apt install -y wget gnupg2 software-properties-common python3-pip python3-venv 10 | 11 | #install ROCm 12 | RUN wget https://repo.radeon.com/amdgpu-install/$ROCM_VERSION/ubuntu/noble/amdgpu-install_$AMDGPU_VERSION-1_all.deb 13 | RUN apt install -y ./*.deb 14 | RUN amdgpu-install --usecase=rocm -y && rm *.deb 15 | 16 | #virtual environment 17 | RUN python3 -m venv /opt/venv 18 | 19 | #install JAX 20 | RUN /opt/venv/bin/pip install --upgrade pip 21 | RUN /opt/venv/bin/pip install https://repo.radeon.com/rocm/manylinux/rocm-rel-6.3/jaxlib-0.4.31-cp312-cp312-manylinux_2_28_x86_64.whl 22 | 23 | # Adjust final path 24 | ENV PATH="/opt/venv/bin:$PATH:/opt/rocm/bin/" 25 | 26 | # Set the default shell 27 | SHELL ["/bin/bash", "-c"] 28 | -------------------------------------------------------------------------------- /framework/ONNX-RUNTIME/onnxruntime.dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:22.04 2 | 3 | ARG ROCM_VERSION=6.4 4 | ARG AMDGPU_VERSION=6.4.60400 5 | ARG ONNX_VERSION=1.21.0 6 | ARG triton_version=3.2.0 7 | ARG torchvision_version=0.21.0 8 | ARG torch_version=2.6.0 9 | ARG PYTHON_VERSION=cp310-cp310 10 | ARG PREFIX=/usr/local 11 | 12 | #Prequisite packages to begin getting files 13 | RUN apt update && apt install -y wget 14 | 15 | #Aquire and install ROCm 16 | RUN wget https://repo.radeon.com/amdgpu-install/$ROCM_VERSION/ubuntu/jammy/amdgpu-install_$AMDGPU_VERSION-1_all.deb 17 | RUN apt install -y ./*.deb 18 | RUN amdgpu-install --usecase=rocm -y && rm *.deb 19 | 20 | ##Install MIGraphX from package manager 21 | RUN apt install -y migraphx 22 | 23 | ##Pieces for Onnxruntime for ROCm and MIGraphX Execution Provider Support 24 | 25 | RUN pip3 install https://repo.radeon.com/rocm/manylinux/rocm-rel-$ROCM_VERSION/onnxruntime_rocm-$ONNX_VERSION-$PYTHON_VERSION-linux_x86_64.whl 26 | 27 | ##Pieces for pytorch 28 | RUN pip3 install https://repo.radeon.com/rocm/manylinux/rocm-rel-$ROCM_VERSION/pytorch_triton_rocm-$triton_version%2Brocm$ROCM_VERSION.*-$PYTHON_VERSION-linux_x86_64.whl 29 | RUN pip3 install https://repo.radeon.com/rocm/manylinux/rocm-rel-$ROCM_VERSION/torch-$torch_version+rocm$ROCM_VERSION-$PYTHON_VERSION-linux_x86_64.whl 30 | RUN pip3 install https://repo.radeon.com/rocm/manylinux/rocm-rel-$ROCM_VERSION/torchvision-$torchvision_version+rocm$ROCM_VERSION-PYTHON_VERSION-linux_x86_64.whl 31 | 32 | ##Adjust final path for ability to use rocm components 33 | ENV PATH=$PATH:/opt/rocm/bin/ 34 | 35 | -------------------------------------------------------------------------------- /push_all.sh: -------------------------------------------------------------------------------- 1 | ROCM_VERSION=6.4.1 2 | 3 | # ubuntu 20.04 base 4 | docker push rocm/dev-ubuntu-20.04:$ROCM_VERSION 5 | docker push rocm/dev-ubuntu-20.04:latest 6 | 7 | # ubuntu 22.04 base 8 | docker push rocm/dev-ubuntu-22.04:$ROCM_VERSION 9 | docker push rocm/dev-ubuntu-22.04:latest 10 | 11 | ## ubuntu 24.04 base 12 | docker push rocm/dev-ubuntu-24.04:$ROCM_VERSION 13 | docker push rocm/dev-ubuntu-24.04:latest 14 | 15 | # rocm terminal base 16 | docker push rocm/rocm-terminal:$ROCM_VERSION 17 | docker push rocm/rocm-terminal:latest 18 | 19 | # manylinux2014 base 20 | docker push rocm/dev-manylinux2014_x86_64:$ROCM_VERSION 21 | docker push rocm/dev-manylinux2014_x86_64:latest 22 | 23 | # ubuntu20.04 complete 24 | docker push rocm/dev-ubuntu-20.04:$ROCM_VERSION-complete 25 | 26 | # ubuntu22.04 complete 27 | docker push rocm/dev-ubuntu-22.04:$ROCM_VERSION-complete 28 | 29 | ## ubuntu24.04 complete 30 | docker push rocm/dev-ubuntu-24.04:$ROCM_VERSION-complete 31 | 32 | # almalinux8 complete 33 | docker push rocm/dev-almalinux-8:$ROCM_VERSION-complete 34 | -------------------------------------------------------------------------------- /quick-start.md: -------------------------------------------------------------------------------- 1 | # Preparing a machine to run with ROCm and docker 2 | 3 | The following instructions assume a fresh/blank machine to be prepared for the ROCm + Docker environment; no additional software has been installed other than the typical stock package updating. 4 | 5 | Please refer to the following instructions for full documentation to install the ROCm base support: 6 | * [ROCm Installation Guide](https://docs.amd.com/bundle/ROCm-Installation-Guide-v5.3/page/Introduction_to_ROCm_Installation_Guide_for_Linux.html) 7 | 8 | ### Step 1: Install amdgpu 9 | The following is a sequence of commands to type (or cut-n-paste) into a terminal, make sure your kernel driver is supported [here](https://github.com/RadeonOpenCompute/ROCm#supported-operating-systems): 10 | 11 | ```bash 12 | # Install the ROCm rock-dkms kernel modules, reboot required 13 | sudo apt-get update 14 | wget https://repo.radeon.com/amdgpu-install/5.3/ubuntu/focal/amdgpu-install_5.3.50300-1_all.deb 15 | sudo apt-get install ./amdgpu-install_5.3.50300-1_all.deb 16 | sudo amdgpu-install --usecase=rocm 17 | 18 | # Add user to the render group if you're using Ubuntu20.04 19 | sudo usermod -a -G render $LOGNAME 20 | 21 | # To add future users to the video and render groups, run the following command: 22 | echo 'ADD_EXTRA_GROUPS=1' | sudo tee -a /etc/adduser.conf 23 | echo 'EXTRA_GROUPS=video' | sudo tee -a /etc/adduser.conf 24 | echo 'EXTRA_GROUPS=render' | sudo tee -a /etc/adduser.conf 25 | 26 | ``` 27 | Make sure to reboot the machine after installing the ROCm kernel package to force the new kernel to load on reboot. You can verify the ROCm kernel is loaded by typing the following command at a prompt: 28 | 29 | ```bash 30 | lsmod | grep amdgpu 31 | ``` 32 | 33 | Printed on the screen should be similar as follows: 34 | ```bash 35 | amdgpu 3530752 0 36 | amdttm 94208 1 amdgpu 37 | amd_sched 28672 1 amdgpu 38 | amdkcl 24576 3 amdttm,amdgpu,amd_sched 39 | i2c_algo_bit 16384 2 amdgpu,ast 40 | amd_iommu_v2 20480 1 amdgpu 41 | drm_kms_helper 167936 2 amdgpu,ast 42 | drm 360448 8 amdttm,amdgpu,ast,amdkcl,amd_sched,ttm,drm_kms_helper 43 | ``` 44 | 45 | ### Step 2: Install docker 46 | After verifying the new kernel is running, next install the docker engine. Manual instructions to install docker on various distro's can be found on the [docker website](https://docs.docker.com/engine/installation/linux/), but perhaps the simplest method is to use a bash script available from docker itself. If it's OK in your organization to run a bash script on your machine downloaded from the internet, open a bash prompt and execute the following line: 47 | 48 | ```bash 49 | curl -sSL https://get.docker.com/ | sh 50 | ``` 51 | 52 | The above script looks at the linux distribution and the installed kernel, and installs docker appropriately. The script will output a warning message on a ROCm platform saying that it does not recognize the rocm kernel; this is normal and can be safely ignored. The script does proper docker installation without recognizing the kernel. 53 | 54 | ### Step 3: Verify/Change the docker device storage driver 55 | The docker device storage driver manages how docker accesses images and containers. There are many available, and [documentation and thorough descriptions](https://docs.docker.com/engine/userguide/storagedriver/imagesandcontainers/) on storage driver architecture can be found on the official docker website. It is possible to check which storage driver docker is using by issuing a 56 | 57 | ```bash 58 | sudo docker info 59 | ``` 60 | 61 | command at the command prompt and looking for the *'Storage Driver: '* output. It is hard to predict what storage driver Docker will choose as default on install, and defaults change over time, but in our experience we have run into a problems with the *'devicemapper'* storage driver with large image sizes. The *'devicemapper'* storage driver imposes limitations on the maximum size images and containers can be. If you work in a field of 'big data', such as in DNN applications, the 10 GB default limit of *'devicemapper'* is limiting. There are two options available if you run into this limit: 62 | 63 | 1. Switch to a different storage driver 64 | * **AMD recommends using 'overlay2'**, whose dependencies are met by the ROCm kernel and should be available 65 | * [overlay2](https://docs.docker.com/engine/userguide/storagedriver/overlayfs-driver/) provides for unlimited image size 66 | * If 'overlay2' is not an option, storage drivers can be [chosen at service startup time](https://docs.docker.com/engine/userguide/storagedriver/selectadriver/) with the **--storage-driver=<name>** option 67 | 2. If you must stick with 'devicemapper', pass the 'devicemapper' [configuration variable](https://docs.docker.com/engine/reference/commandline/dockerd/) --dm.basesize on service startup to increase the potential image maximum 68 | 69 | The downside to switching to the 'overlay2' storage driver after creating and working with 'devicemapper' images is that existing images need to be recreated. As such, we recommend verifying that docker be set up using the 'overlay2' storage driver before engaging in significant work. 70 | 71 | ### Step 4a: Build ROCm container using docker CLI 72 | [![asciicast](https://asciinema.org/a/5u0d81txy9tskiitcispluw9v.png)](https://asciinema.org/a/5u0d81txy9tskiitcispluw9v) 73 | 74 | * Clone and build the container 75 | 76 | ```bash 77 | git clone https://github.com/RadeonOpenCompute/ROCm-docker 78 | cd ROCm-docker 79 | sudo docker build -t rocm/rocm-terminal rocm-terminal 80 | sudo docker run -it --device=/dev/kfd --device=/dev/dri --security-opt seccomp=unconfined --group-add video rocm/rocm-terminal 81 | ``` 82 | 83 | ### (optional) Step 4b: Build ROCm container using docker-compose 84 | [![asciicast](https://asciinema.org/a/77cfxjz9ilt2x9ck27r9vanu7.png)](https://asciinema.org/a/77cfxjz9ilt2x9ck27r9vanu7) 85 | 86 | * Clone and build the container using [docker-compose](https://docs.docker.com/compose/install/) 87 | 88 | ```bash 89 | git clone https://github.com/RadeonOpenCompute/ROCm-docker 90 | cd ROCm-docker 91 | sudo docker-compose run --rm rocm 92 | ``` 93 | ### Step 5: Verify successful build of ROCm-docker container 94 | * Verify a working container-based ROCm software stack 95 | * After step #2 or #3, a bash login prompt to a running docker container should be available 96 | * Execute rocminfo script 97 | * `/opt/rocm/bin/rocminfo` 98 | * Text displaying your system AMD GPU System Attributes and enumerate all the visible GPU Agents. 99 | -------------------------------------------------------------------------------- /rocm-terminal/Dockerfile: -------------------------------------------------------------------------------- 1 | # This dockerfile is meant to be personalized, and serves as a template and demonstration. 2 | # Modify it directly, but it is recommended to copy this dockerfile into a new build context (directory), 3 | # modify to taste and modify docker-compose.yml.template to build and run it. 4 | 5 | # It is recommended to control docker containers through 'docker-compose' https://docs.docker.com/compose/ 6 | # Docker compose depends on a .yml file to control container sets 7 | # rocm-setup.sh can generate a useful docker-compose .yml file 8 | # `docker-compose run --rm ` 9 | 10 | # If it is desired to run the container manually through the docker command-line, the following is an example 11 | # 'docker run -it --rm -v [host/directory]:[container/directory]:ro /'. 12 | 13 | FROM ubuntu:22.04 14 | LABEL maintainer=dl.mlsedevops@amd.com 15 | 16 | # Initialize the image 17 | # Modify to pre-install dev tools and ROCm packages 18 | ARG ROCM_VERSION=6.4.1 19 | ARG AMDGPU_VERSION=6.4.1 20 | 21 | ARG APT_PREF 22 | RUN echo "$APT_PREF" > /etc/apt/preferences.d/rocm-pin-600 23 | RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl gnupg && \ 24 | curl -sL http://repo.radeon.com/rocm/rocm.gpg.key | apt-key add - && \ 25 | sh -c 'echo deb [arch=amd64] http://repo.radeon.com/rocm/apt/$ROCM_VERSION/ jammy main > /etc/apt/sources.list.d/rocm.list' && \ 26 | sh -c 'echo deb [arch=amd64] https://repo.radeon.com/amdgpu/$AMDGPU_VERSION/ubuntu jammy main > /etc/apt/sources.list.d/amdgpu.list' && \ 27 | apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \ 28 | sudo \ 29 | libelf1 \ 30 | libnuma-dev \ 31 | build-essential \ 32 | git \ 33 | vim-nox \ 34 | cmake-curses-gui \ 35 | kmod \ 36 | file \ 37 | python3 \ 38 | python3-pip \ 39 | rocm-dev && \ 40 | apt-get clean && \ 41 | rm -rf /var/lib/apt/lists/* 42 | 43 | # Grant members of 'sudo' group passwordless privileges 44 | # Comment out to require sudo 45 | COPY sudo-nopasswd /etc/sudoers.d/sudo-nopasswd 46 | 47 | # This is meant to be used as an interactive developer container 48 | # Create user rocm-user as member of sudo group 49 | # Append /opt/rocm/bin to the system PATH variable 50 | RUN useradd --create-home -G sudo,video --shell /bin/bash rocm-user 51 | # sed --in-place=.rocm-backup 's|^\(PATH=.*\)"$|\1:/opt/rocm/bin"|' /etc/environment 52 | 53 | USER rocm-user 54 | WORKDIR /home/rocm-user 55 | ENV PATH "${PATH}:/opt/rocm/bin" 56 | 57 | # The following are optional enhancements for the command-line experience 58 | # Uncomment the following to install a pre-configured vim environment based on http://vim.spf13.com/ 59 | # 1. Sets up an enhanced command line dev environment within VIM 60 | # 2. Aliases GDB to enable TUI mode by default 61 | #RUN curl -sL https://j.mp/spf13-vim3 | bash && \ 62 | # echo "alias gdb='gdb --tui'\n" >> ~/.bashrc 63 | 64 | # Default to a login shell 65 | CMD ["bash", "-l"] 66 | -------------------------------------------------------------------------------- /rocm-terminal/Dockerfile.post-install: -------------------------------------------------------------------------------- 1 | #| This Dockerfile provides a compatibility check for ROCm docker container. 2 | ARG base_image 3 | FROM ${base_image} 4 | 5 | LABEL maintainer=dl.mlsedevops@amd.com 6 | 7 | COPY scripts/compatibility-check.sh /opt/rocm/bin/rocm-compatibility-test.sh 8 | RUN sudo chmod a+x /opt/rocm/bin/rocm-compatibility-test.sh 9 | ENTRYPOINT ["/opt/rocm/bin/rocm-compatibility-test.sh"] 10 | 11 | # Default to a login shell 12 | CMD ["/bin/bash", "-l"] 13 | -------------------------------------------------------------------------------- /rocm-terminal/sudo-nopasswd: -------------------------------------------------------------------------------- 1 | # This line grants the any members of the sudo group 2 | # passwordless sudo privileges 3 | %sudo ALL=(ALL) NOPASSWD:ALL 4 | -------------------------------------------------------------------------------- /scripts/compatibility-check.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | /opt/rocm/bin/rocminfo 2>&1 | /bin/grep "HSA Error" > /dev/null 4 | if [ $? -eq 0 ] 5 | then 6 | echo "Error: Incompatible ROCm environment." 7 | echo "The Docker container requires the latest kernel driver to operate correctly." 8 | echo "Upgrade the ROCm kernel to v4.1 or newer, or use a container tagged for v4.0.1 or older." 9 | echo "For more information, see" 10 | echo "https://rocmdocs.amd.com/en/latest/Current_Release_Notes/Current-Release-Notes.html#" 11 | exit 1 12 | fi 13 | exec "$@" 14 | -------------------------------------------------------------------------------- /scripts/install_versioned_rocm.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | set -ex 4 | 5 | if [ -z $1 ]; then 6 | echo "Need to provide ROCM_VERSION as first argument" && exit 1 7 | fi 8 | 9 | if [[ $1 =~ ^[0-9]+\.[0-9]+$ ]]; then 10 | ROCM_VERSION=${1}".0" 11 | fi 12 | yum install -y rocm-dev${ROCM_VERSION} rocm-libs${ROCM_VERSION} 13 | -------------------------------------------------------------------------------- /setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # ################################################# 3 | # Copyright (c) 2016 Advanced Micro Devices, Inc. 4 | # ################################################# 5 | # Author: Kent Knox 6 | 7 | # ################################################# 8 | # Pre-requisites check 9 | # ################################################# 10 | if (( ${BASH_VERSION%%.*} < 4 )); then 11 | printf "This script uses associative arrays, requiring Bash 4.x minimum\n" 12 | exit 2 13 | fi 14 | 15 | # check if curl is installed 16 | type curl > /dev/null 17 | if [[ $? -ne 0 ]]; then 18 | printf "This script uses curl to download components; try installing with package manager\n"; 19 | exit 2 20 | fi 21 | 22 | # check if getopt command is installed 23 | type getopt > /dev/null 24 | if [[ $? -ne 0 ]]; then 25 | printf "This script uses getopt to parse arguments; try installing the util-linux package\n"; 26 | exit 2 27 | fi 28 | 29 | # lsb-release file describes the system 30 | if [[ ! -e "/etc/lsb-release" ]]; then 31 | printf "This script depends on the /etc/lsb-release file\n" 32 | exit 2 33 | fi 34 | source /etc/lsb-release 35 | 36 | if [[ ${DISTRIB_CODENAME} != trusty ]] && [[ ${DISTRIB_CODENAME} != xenial ]]; then 37 | printf "This script only validated with Ubuntu trusty [14.04] or xenial [16.04]\n" 38 | exit 2 39 | fi 40 | 41 | # ################################################# 42 | # helper functions 43 | # ################################################# 44 | function display_help() 45 | { 46 | printf "Build ROC docker images from templates\n\n" 47 | printf " [-h|--help] prints this help message\n" 48 | printf " [--ubuntu xx.yy] Ubuntu version for to inherit base image (16.04 / 14.04)\n" 49 | printf " [--tag] String specifying branch or tag in git repository (requires --build)\n" 50 | printf " [--branch] Same as tag; alias\n" 51 | # printf " [--all] Build as many components as you can\n" 52 | # printf " [--roct] Build roct component\n" 53 | # printf " [--rocr] Build rocr component\n" 54 | # printf " [--hcc-lc] Build hcc-lc component\n" 55 | # printf " [--hcc-hsail] Build hcc-hsail component\n" 56 | printf " [--debug] Build debug containers; symbols generated and build tree intact for debugging; (requires --build, exclusive with --release)\n" 57 | printf " [--install-docker-compose] install the docker-compose tool\n" 58 | } 59 | 60 | # ################################################# 61 | # global variables & defaults 62 | # ################################################# 63 | # Array describing what rocm components to build docker images for 64 | rocm_components=() 65 | 66 | # If building components from source, script defaults to master branch if no tag name is explicitely specified 67 | export tag='master' 68 | export ubuntu_version='16.04' 69 | export target_distrib_codename=xenial 70 | 71 | export build_config='Release' 72 | build_release=true 73 | install_compose=false 74 | 75 | # Bash associative arrays 76 | # 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 ) 77 | # 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 ) 78 | # 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 ) 79 | # declare -A hcc_hsail_branch_names=( ['master']=master ['develop']= ['roc-1.0']= ['roc-1.1']= ['roc-1.2']= ['roc-1.3']= ['roc-1.4']= ) 80 | 81 | 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 ) 82 | declare -A runtime_dockerfiles=( ['src-template']=rocr-src-dockerfile.template ['deb-template']=rocr-deb-dockerfile.template ['src']=rocr-src-dockerfile ['deb']=rocr-deb-dockerfile ) 83 | 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) 84 | 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 ) 85 | 86 | # ################################################# 87 | # Parameter parsing 88 | # ################################################# 89 | 90 | # check if we have a modern version of getopt that can handle whitespace and long parameters 91 | getopt -T 92 | if [[ $? -eq 4 ]]; then 93 | # GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,ubuntu:,tag:,branch:,all,roct,rocr,hcc-lc,hcc-hsail,release,debug,install-docker-compose --options h -- "$@") 94 | GETOPT_PARSE=$(getopt --name "${0}" --longoptions help,ubuntu:,tag:,branch:,release,debug,install-docker-compose --options h -- "$@") 95 | else 96 | printf "Legacy getopt not handled" 97 | exit 1 98 | fi 99 | 100 | if [[ $? -ne 0 ]]; then 101 | printf "getopt invocation failed; could not parse the command line\n"; 102 | exit 1 103 | fi 104 | 105 | eval set -- "${GETOPT_PARSE}" 106 | 107 | while true; do 108 | case "${1}" in 109 | -h|--help) 110 | display_help 111 | exit 0 112 | ;; 113 | --ubuntu) 114 | ubuntu_version=${2} 115 | shift 2;; 116 | --tag|--branch) 117 | tag=${2} 118 | shift 2;; 119 | # --all) 120 | # rocm_components=('roct' 'rocr' 'hcc-lc' 'hcc-hsail') 121 | # shift ;; 122 | # --roct) 123 | # rocm_components+=('roct') 124 | # shift ;; 125 | # --rocr) 126 | # rocm_components+=('rocr') 127 | # shift ;; 128 | # --hcc-lc) 129 | # rocm_components+=('hcc-lc') 130 | # shift ;; 131 | # --hcc-hsail) 132 | # rocm_components+=('hcc-hsail') 133 | # shift ;; 134 | --debug) 135 | build_config='Debug' 136 | build_release=false 137 | shift ;; 138 | --install-docker-compose) 139 | install_compose=true 140 | shift ;; 141 | --) shift ; break ;; 142 | *) printf "getopt parsing error"; 143 | exit 2 144 | ;; 145 | esac 146 | done 147 | 148 | # ################################################# 149 | # docker-compose 150 | # Help users install the latest docker-compose on their machine 151 | # ################################################# 152 | if [[ "${install_compose}" == true ]]; then 153 | sudo curl -L $(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep browser_download_url.*-Linux | cut -d\" -f 4) -o /usr/local/bin/docker-compose 154 | sudo chmod +x /usr/local/bin/docker-compose 155 | 156 | 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 157 | fi 158 | 159 | # ################################################# 160 | # Start of main 161 | # ################################################# 162 | 163 | if [[ "${ubuntu_version}" == 14.04 ]]; then 164 | target_distrib_codename=trusty 165 | fi 166 | 167 | printf "== Branch/tag to build: %s\n" ${tag} 168 | if [[ "${build_release}" == true ]]; then 169 | printf "==== Release builds \n" 170 | else 171 | printf "==== Debug builds \n" 172 | fi 173 | 174 | # Keep only the unique rocm_components 175 | # printf "rocm_components count: " ${#rocm_components[@]} 176 | # rocm_components=($(printf "%s\n" "${rocm_components[@]}" | uniq -u)) 177 | # 178 | # if [ ${#rocm_components[@]} -ne 0 ]; then 179 | # printf "== Rocm images to build: " 180 | # 181 | # for key in ${!rocm_components[@]}; do 182 | # if [ -n "${rocm_components[$key]}" ]; then 183 | # printf "${rocm_components[$key]} " 184 | # else 185 | # printf "NULL\n" 186 | # fi 187 | # done 188 | # printf "\n" 189 | # fi 190 | 191 | # export rock_image_name= 192 | organization_prefix="rocm/" 193 | 194 | roct_image_name="${organization_prefix}/roct" 195 | rocr_image_name="${organization_prefix}/rocr" 196 | hcc_lc_image_name="${organization_prefix}/hcc-lc" 197 | hcc_hsail_image_name="${organization_prefix}/hcc-hsail" 198 | 199 | export roct_image_name_deb="${roct_image_name}-ubuntu-${ubuntu_version}:latest" 200 | export rocr_image_name_deb="${rocr_image_name}-ubuntu-${ubuntu_version}:latest" 201 | export hcc_lc_image_name_deb="${hcc_lc_image_name}-ubuntu-${ubuntu_version}:latest" 202 | export hcc_hsail_image_name_deb="${hcc_hsail_image_name}-ubuntu-${ubuntu_version}:latest" 203 | 204 | export roct_image_name_src="${roct_image_name}-src-${build_config,}:${tag}" 205 | export rocr_image_name_src="${rocr_image_name}-src-${build_config,}:${tag}" 206 | export hcc_lc_image_name_src="${hcc_lc_image_name}-src-${build_config,}:${tag}" 207 | export hcc_hsail_image_name_src="${hcc_hsail_image_name}-src-${build_config,}:${tag}" 208 | 209 | export roct_cleanup= 210 | export rocr_cleanup= 211 | export hcc_hsail_cleanup= 212 | export hcc_lc_cleanup= 213 | 214 | if [[ "${build_release}" == true ]]; then 215 | # Custom commands to clean up build directories for each component 216 | # This is to keep release images as small as possible 217 | roct_cleanup='cd ~ && rm -rf ${HSATHK_BUILD_PATH}' 218 | rocr_cleanup='cd ~ && rm -rf ${ROCR_BUILD_PATH}' 219 | hcc_hsail_cleanup='cd ~ && rm -rf ${HCC_BUILD_PATH}' 220 | hcc_lc_cleanup='cd ~ && rm -rf ${HCC_BUILD_PATH}' 221 | fi 222 | 223 | export rocm_volume='/opt/rocm/' 224 | export roct_volume="${rocm_volume}/libhsakmt/" 225 | export rocr_volume="${rocm_volume}/hsa/" 226 | export hcc_hsail_volume="${rocm_volume}/hcc-hsail/" 227 | export hcc_lc_volume="${rocm_volume}/hcc-lc/" 228 | 229 | # /lib/x86_64-linux-gnu is debian/ubuntu style not currently used in rocm 230 | # export lib64_install_dir='/lib/x86_64-linux-gnu' 231 | export lib64_install_dir='/lib' 232 | 233 | # trim duplicate path seperators 234 | roct_image_name_deb=$(echo "${roct_image_name_deb}" | tr -s '/' ) 235 | rocr_image_name_deb=$(echo "${rocr_image_name_deb}" | tr -s '/' ) 236 | hcc_lc_image_name_deb=$(echo "${hcc_lc_image_name_deb}" | tr -s '/' ) 237 | hcc_hsail_image_name_deb=$(echo "${hcc_hsail_image_name_deb}" | tr -s '/' ) 238 | 239 | roct_image_name_src=$(echo "${roct_image_name_src}" | tr -s '/' ) 240 | rocr_image_name_src=$(echo "${rocr_image_name_src}" | tr -s '/' ) 241 | hcc_lc_image_name_src=$(echo "${hcc_lc_image_name_src}" | tr -s '/' ) 242 | hcc_hsail_image_name_src=$(echo "${hcc_hsail_image_name_src}" | tr -s '/' ) 243 | 244 | roct_volume=$(echo "${roct_volume}" | tr -s '/' ) 245 | rocr_volume=$(echo "${rocr_volume}" | tr -s '/' ) 246 | hcc_lc_volume=$(echo "${hcc_lc_volume}" | tr -s '/' ) 247 | hcc_hsail_volume=$(echo "${hcc_hsail_volume}" | tr -s '/' ) 248 | 249 | # Generate the .env file used by the docker-compose tool 250 | printf "HCC_VERSION=4.0\n\n" > .env 251 | printf "roct_image_name_deb=${roct_image_name_deb}\n" >> .env 252 | printf "rocr_image_name_deb=${rocr_image_name_deb}\n" >> .env 253 | printf "hcc_lc_image_name_deb=${hcc_lc_image_name_deb}\n" >> .env 254 | printf "hcc_hsail_image_name_deb=${hcc_hsail_image_name_deb}\n" >> .env 255 | printf "roct_image_name_src=${roct_image_name_src}\n">> .env 256 | printf "rocr_image_name_src=${rocr_image_name_src}\n" >> .env 257 | printf "hcc_lc_image_name_src=${hcc_lc_image_name_src}\n" >> .env 258 | printf "hcc_hsail_image_name_src=${hcc_hsail_image_name_src}\n" >> .env 259 | 260 | printf "\n" >> .env 261 | printf "roct_volume=${roct_volume}\n" >> .env 262 | printf "rocr_volume=${rocr_volume}\n" >> .env 263 | printf "hcc_lc_volume=${hcc_lc_volume}\n" >> .env 264 | 265 | printf "\n" >> .env 266 | printf "roct_deb_dockerfile=${thunk_dockerfiles[deb]}\n" >> .env 267 | printf "roct_src_dockerfile=${thunk_dockerfiles[src]}\n" >> .env 268 | printf "rocr_deb_dockerfile=${runtime_dockerfiles[deb]}\n" >> .env 269 | printf "rocr_src_dockerfile=${runtime_dockerfiles[src]}\n" >> .env 270 | printf "hcc_lc_deb_dockerfile=${hcc_lc_dockerfiles[deb]}\n" >> .env 271 | printf "hcc_lc_src_dockerfile=${hcc_lc_dockerfiles[src]}\n" >> .env 272 | 273 | # cat rock/rock-deb-dockerfile.template | envsubst '${repo_branch}:${rock_volume}' > rock/Dockerfile 274 | cat roct/${thunk_dockerfiles[deb-template]} | envsubst '${ubuntu_version}:${target_distrib_codename}' > roct/${thunk_dockerfiles[deb]} 275 | cat roct/${thunk_dockerfiles[src-template]} | envsubst '${ubuntu_version}:${tag}:${build_config}:${roct_cleanup}:${roct_volume}:${lib64_install_dir}' > roct/${thunk_dockerfiles[src]} 276 | cat rocr/${runtime_dockerfiles[deb-template]} | envsubst '${roct_image_name_deb}' > rocr/${runtime_dockerfiles[deb]} 277 | 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]} 278 | cat hcc-lc/${hcc_lc_dockerfiles[deb-template]} | envsubst '${rocr_image_name_deb}' > hcc-lc/${hcc_lc_dockerfiles[deb]} 279 | cat hcc-lc/${hcc_lc_dockerfiles[src-template]} | envsubst '${rocr_image_name_src}:${tag}:${build_config}:${hcc_lc_cleanup}:${rocm_volume}:${hcc_lc_volume}' > hcc-lc/${hcc_lc_dockerfiles[src]} 280 | --------------------------------------------------------------------------------