Some users may want to run the OctoML Platform SDK or the Python wheels generated from the OctoML platform in a separate environment. Below are simple Dockerfiles and specific instructions for CPU and GPU-based environments.

CPU:

FROM ubuntu:20.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt update && apt install -y --no-install-recommends apt-utils
RUN apt-get -y install tzdata
RUN apt install wget nano sudo git screen liblzma-dev python3 python3-dev python3-setuptools python3-pip libtinfo-dev zlib1g-dev build-essential libedit-dev libxml2-dev -y

RUN groupadd ubuntu
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g ubuntu -G sudo -u 1000 -p "$(openssl passwd -1 ubuntu)" ubuntu
RUN chown -R ubuntu:ubuntu /home/ubuntu
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

USER ubuntu
WORKDIR /home/ubuntu
RUN echo 'export PATH=$HOME/.local/bin:$PATH:$PATH' >> ~/.bashrc && echo 'export PATH=/usr/local/bin:$PATH:$PATH' >> ~/.bashrc
RUN yes | pip3 install --user numpy
RUN yes | pip3 install octomizer-sdk --user --extra-index-url https://octo.jfrog.io/artifactory/api/pypi/pypi-local/simple

RUN sudo apt clean --yes

CMD ["/bin/bash"]

GPU

  • Users must run python3.8 when working with the OctoML SDK or optimized models in this image. This is because Ubuntu 18.04 only supports python3.6.9 natively and using python3 will point to a Python version unsupported by the OctoML platform. Users must also have NVIDIA docker installed to enable GPUs in their docker containers.

FROM nvidia/cuda:10.2-cudnn8-devel-ubuntu18.04

ENV DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y --no-install-recommends apt-utils
RUN apt-get -y install tzdata
RUN apt install wget nano sudo git screen python3 python3-dev python3-setuptools python3-pip gcc liblzma-dev libtinfo-dev build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev libsqlite3-dev wget libbz2-dev zlib1g-dev libedit-dev cmake libxml2-dev -y
RUN echo 'deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main' >> /etc/apt/sources.list && echo 'deb-src http://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main' >> /etc/apt/sources.list && wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -
RUN apt update && apt install --yes libllvm-12-ocaml-dev libllvm12 llvm-12 llvm-12-dev llvm-12-doc llvm-12-examples llvm-12-runtime && apt-get install --yes clang-12 clang-tools-12 clang-12-doc libclang-common-12-dev libclang-12-dev libclang1-12 clang-format-12 clangd-12


RUN groupadd ubuntu
RUN useradd -rm -d /home/ubuntu -s /bin/bash -g ubuntu -G sudo -u 1000 -p "$(openssl passwd -1 ubuntu)" ubuntu
RUN chown -R ubuntu:ubuntu /home/ubuntu
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

USER ubuntu
WORKDIR /home/ubuntu

RUN wget https://www.python.org/ftp/python/3.8.10/Python-3.8.10.tgz && tar -xf Python-3.8.10.tgz && cd Python-3.8.10 && ./configure --enable-optimizations && make -j $(($(nproc) / 2)) && sudo make altinstall
RUN sudo rm -rf /home/ubuntu/Python-3.8.10 && rm /home/ubuntu/Python-3.8.10.tgz

RUN echo 'export PATH=$HOME/.local/bin:$PATH:$PATH' >> ~/.bashrc && echo 'export PATH=/usr/local/bin:$PATH:$PATH' >> ~/.bashrc
RUN yes | pip3.8 install --user numpy
RUN yes | pip3.8 install octomizer-sdk --user --extra-index-url https://octo.jfrog.io/artifactory/api/pypi/pypi-local/simple

RUN sudo apt clean --yes

CMD ["/bin/bash"]

To build docker images from these dockerfiles, run:

docker build -f <name_of_file> -t <name_you_want_for_image> .

In order to run the images once built, run:

  • CPU: docker run -it <name_you_gave_image>

  • GPU: docker run --gpus all -it <name_you_gave_image>

Did this answer your question?