diff --git a/README.md b/README.md index 4b5c895..621fe62 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This repository contains a framework for building the software layers defined in * `cd ROCm-docker` 3. Build the container * Not using docker-compose - * `docker build -t rocm/rocm-terminal rocm-project` + * `docker build -t rocm/rocm-terminal rocm-terminal` * `docker run -it --rm --device="/dev/kfd" rocm/rocm-terminal` * If using docker-compose * `docker-compose run --rm rocm` @@ -75,8 +75,8 @@ Using docker-compose, a target is provided that will import the data-only contai * `docker-compose run --rm rocm-from-src` ## Creating a custom application/development container -The /rocm-project sub-directory contains a Dockerfile to build an image specifically built for ROCm software development. Useful development tools are pre-installed into the container, and it's meant to serve as a starting point for interested developers to customize a dockerfile for their own projects. To begin, simply: -1. copy the /rocm-project sub-directory into a new directory name, such as /my-rocm-project +The /rocm-terminal sub-directory contains a Dockerfile to build an image specifically built for ROCm software development. Useful development tools are pre-installed into the container, and it's meant to serve as a starting point for interested developers to customize a dockerfile for their own projects. To begin, simply: +1. copy the /rocm-terminal sub-directory into a new directory name, such as /my-rocm-terminal 2. open and customize the Dockerfile; pre-install dependencies and services 3. modify the **docker-compose.yml.template** file and add a new service which prepares a new image - copy the 'rocm' target to build a container using the latest ROCm binary release @@ -106,15 +106,18 @@ new-rocm-app: # docker-compose target name; was 'rocm-fr You run the new container (and its dependencies) with docker-compose. When the container is fully loaded and running, you will be presented with a root prompt within the container. ```bash -docker-compose run --rm +docker-compose run --rm ``` +### Running a ROCm container as root +The dockerfile that serves as the 'terminal' creates a non-root user called `rocm-user`. For most applications, this user should have sufficient permissions to compile and run ROCm applications. If it is necessary to run the ROCm container with root privileges, the easiest way is to override the USER setting by passing the `-u 0` parameter to `docker run`. If that is not sufficient, then it is possible to set the `root` password to a known quantity by directly modifying the `rocm-terminal/Dockerfile` and adding `RUN echo 'account:password' | chpasswd` or OS equivalent directly into your personal dockerfile. + | Docker command reference | | |-----|-----| | docker-compose | docker compose executable| | run | sub-command to bring up interactive container | | --rm | when shutting the container down, delete it | -| my-rocm-project | application service defined in **docker-compose.yml** | +| my-rocm-terminal | application service defined in **docker-compose.yml** | To shut down ROCm dependencies and clean up ```bash diff --git a/docker-compose.yml.template b/docker-compose.yml.template index d584b7e..be1e4e8 100644 --- a/docker-compose.yml.template +++ b/docker-compose.yml.template @@ -53,7 +53,7 @@ services: # These should be run with `docker-compose run --rm ` rocm: build: - context: ./rocm-project + context: ./rocm-terminal dockerfile: Dockerfile devices: - "/dev/kfd" @@ -63,7 +63,7 @@ services: rocm-from-src: build: - context: ./rocm-project + context: ./rocm-terminal dockerfile: Dockerfile devices: - "/dev/kfd" diff --git a/rocm-project/Dockerfile b/rocm-project/Dockerfile deleted file mode 100644 index 3040293..0000000 --- a/rocm-project/Dockerfile +++ /dev/null @@ -1,47 +0,0 @@ -# This dockerfile meant to be personalized for application development. -# Copy this dockerfile into a new build context (directory) and modify to taste. - -# It is recommended to control docker containers through 'docker-compose' https://docs.docker.com/compose/ -# Docker compose depends on a .yml file to control container sets -# rocm-setup.sh can generate a useful docker-compose .yml file -# `docker-compose run --rm ` - -# If running the container manually through the docker command-line, the following is an example -# 'docker run -it --rm -v [host/directory]:[container/directory]:ro /'. - -FROM ubuntu:14.04 -MAINTAINER Kent Knox - -# Default to a login shell -ENTRYPOINT ["/bin/bash"] -CMD ["-l"] - -# Initialize the image to install recommended dev tools and ROCm packages -RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y curl && \ - curl -sL http://packages.amd.com/rocm/apt/debian/rocm.gpg.key | apt-key add - && \ - sh -c 'echo deb [arch=amd64] http://packages.amd.com/rocm/apt/debian/ trusty main > /etc/apt/sources.list.d/rocm.list' && \ - apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ - build-essential \ - rocm-dev \ - clang-3.5 \ - libelf1 \ - git \ - gdb \ - valgrind \ - vim-nox \ - cmake-curses-gui && \ - apt-get clean && \ - rm -rf /var/lib/apt/lists/* - -# This is meant to be an interactive container; create a non-root user -RUN useradd --create-home --shell /bin/bash rocm-user -USER rocm-user -WORKDIR /home/rocm-user - -# The following attempts to create a nice command line developer environment -# 1. Sets up an enhanced command line dev environment within VIM -# 2. Extends PATH to include binaries installed with ROCm -# 3. Aliases GDB to enable native TUI mode by default -RUN curl -sL https://j.mp/spf13-vim3 | bash && \ - echo "\nPATH=${PATH}:/opt/rocm/bin\n" >> ~/.bashrc && \ - echo "alias gdb='gdb --tui'\n" >> ~/.bashrc diff --git a/rocm-terminal/Dockerfile b/rocm-terminal/Dockerfile new file mode 100644 index 0000000..90062af --- /dev/null +++ b/rocm-terminal/Dockerfile @@ -0,0 +1,54 @@ +# This dockerfile is meant to be personalized, and serves as a template and demonstration. +# Modify it directly, but it is recommended to copy this dockerfile into a new build context (directory), +# modify to taste and modify docker-compose.yml.template to build and run it. + +# It is recommended to control docker containers through 'docker-compose' https://docs.docker.com/compose/ +# Docker compose depends on a .yml file to control container sets +# rocm-setup.sh can generate a useful docker-compose .yml file +# `docker-compose run --rm ` + +# If it is desired to run the container manually through the docker command-line, the following is an example +# 'docker run -it --rm -v [host/directory]:[container/directory]:ro /'. + +FROM ubuntu:14.04 +MAINTAINER Kent Knox + +# Default to a login shell +ENTRYPOINT ["/bin/bash"] +CMD ["-l"] + +# Initialize the image +# Modify to pre-install dev tools and ROCm packages +RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y curl && \ + curl -sL http://packages.amd.com/rocm/apt/debian/rocm.gpg.key | apt-key add - && \ + sh -c 'echo deb [arch=amd64] http://packages.amd.com/rocm/apt/debian/ trusty main > /etc/apt/sources.list.d/rocm.list' && \ + apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y \ + build-essential \ + rocm-dev \ + libelf1 \ +# git \ +# clang-3.5 \ +# gdb \ +# valgrind \ +# vim-nox \ + cmake-curses-gui && \ + apt-get clean && \ + rm -rf /var/lib/apt/lists/* + +# This is meant to be used as an interactive container; create a non-root user without a password by default +# If root access is required, it is safest to pass the '-u 0' parameter to 'docker run' +# If that is insufficient, set a password in the commented RUN statement below +RUN useradd --create-home --shell /bin/bash rocm-user +# RUN echo 'account:password' | chpasswd +USER rocm-user +WORKDIR /home/rocm-user + +# Extend PATH to include binaries installed with ROCm +RUN echo "\nPATH=${PATH}:/opt/rocm/bin\n" >> ~/.bashrc + +# The following are optional enhancements for the command-line experience +# Uncomment the following to install a pre-configured vim environment based on http://vim.spf13.com/ +# 1. Sets up an enhanced command line dev environment within VIM +# 2. Aliases GDB to enable TUI mode by default +#RUN curl -sL https://j.mp/spf13-vim3 | bash && \ +# echo "alias gdb='gdb --tui'\n" >> ~/.bashrc