This document is relevant for: Inf1

Dockerfile for Application 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#    docker run -it --device=/dev/neuron0 neuron-container:pytorch
 6
 7FROM ubuntu:18.04
 8
 9LABEL maintainer=" "
10
11RUN apt-get update -y \
12 && apt-get install -y --no-install-recommends \
13    gnupg2 \
14    wget \
15    python3-pip \
16    python3-setuptools \
17    && cd /usr/local/bin \
18    && pip3 --no-cache-dir install --upgrade pip \
19    && rm -rf /var/lib/apt/lists/* \
20    && apt-get clean
21
22RUN echo "deb https://apt.repos.neuron.amazonaws.com bionic main" > /etc/apt/sources.list.d/neuron.list
23RUN wget -qO - https://apt.repos.neuron.amazonaws.com/GPG-PUB-KEY-AMAZON-AWS-NEURON.PUB | apt-key add -
24
25# Installing Neuron Tools
26RUN apt-get update -y && apt-get install -y \
27    aws-neuronx-tools
28
29# Sets up Path for Neuron tools
30ENV PATH="/opt/bin/:/opt/aws/neuron/bin:${PATH}"
31
32# Include framework tensorflow-neuron or torch-neuronx and compiler (compiler not needed for inference)
33RUN pip3 install \
34    torch-neuronx \
35    --extra-index-url=https://pip.repos.neuron.amazonaws.com
36
37# Include your APP dependencies here.
38# RUN ...
39
40# Define the entrypoint script that has some application code (if needed) and executes the docker run command
41# For example you can use something like below
42# COPY dockerd-libmode-entrypoint.sh /opt/bin/dockerd-entrypoint.sh
43# RUN chmod +x /opt/bin/dockerd-entrypoint.sh
44# ENTRYPOINT ["/opt/bin/dockerd-entrypoint.sh"]
45
46CMD ["neuron-top"]

This document is relevant for: Inf1