This document is relevant for: Inf1

Dockerfile with Application and Runtime in different Container#

 1# Example pytorch neuron container
 2# To build:
 3#    docker build . -f Dockerfile.pt -t neuron-container:pytorch
 4# To run on EC2 Inf1 instances with AWS DLAMI:
 5#    sudo service neuron-rtd stop
 6#    docker run -it --device=/dev/neuron0 -v /run/:/run --cap-add IPC_LOCK neuron-container:pytorch
 7
 8FROM ubuntu:18.04
 9
10LABEL maintainer=" "
11
12RUN apt-get update -y \
13 && apt-get install -y --no-install-recommends \
14 wget \
15 gnupg2 \
16 python3-pip \
17 python3-setuptools \
18 && cd /usr/local/bin \
19 && pip3 --no-cache-dir install --upgrade pip \
20 && rm -rf /var/lib/apt/lists/* \
21 && apt-get clean
22
23RUN echo "deb https://apt.repos.neuron.amazonaws.com bionic main" > /etc/apt/sources.list.d/neuron.list
24RUN wget -qO - https://apt.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB | apt-key add -
25
26# Include framework tensorflow-neuron or torch-neuron and compiler (compiler not needed for inference)
27RUN pip3 install \
28    torch-neuron \
29    --extra-index-url=https://pip.repos.neuron.amazonaws.com
30
31# Include your APP dependencies here.
32# RUN/ENTRYPOINT/CMD ...
33

This document is relevant for: Inf1