Skip to content

Instantly share code, notes, and snippets.

@atinfinity
Created June 1, 2022 14:54
Show Gist options
  • Save atinfinity/f559aa72ffae84acea4f88058457ff4b to your computer and use it in GitHub Desktop.
Save atinfinity/f559aa72ffae84acea4f88058457ff4b to your computer and use it in GitHub Desktop.
OnnxGraphQt_Docker
FROM ubuntu:20.04
ARG GID=1000
ARG UID=1000
# add new sudo user
ENV USERNAME onnx
ENV HOME /home/$USERNAME
RUN groupadd -f -g ${GID} ${USERNAME}
RUN useradd -m $USERNAME -u ${UID} -g ${GID} && \
echo "$USERNAME:$USERNAME" | chpasswd && \
usermod --shell /bin/bash $USERNAME && \
usermod -aG sudo $USERNAME && \
mkdir /etc/sudoers.d && \
echo "$USERNAME ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers.d/$USERNAME && \
chmod 0440 /etc/sudoers.d/$USERNAME
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -y --no-install-recommends \
sudo \
less \
emacs \
tmux \
bash-completion \
command-not-found \
software-properties-common \
xsel \
xdg-user-dirs \
git \
libpulse-mainloop-glib0 \
python3-pip \
python3-pyqt5 \
&& \
apt-get clean && \
rm -rf /var/lib/apt/lists/*
USER $USERNAME
WORKDIR /home/$USERNAME
SHELL ["/bin/bash", "-c"]
RUN python3 -m pip install nvidia-pyindex
RUN python3 -m pip install onnx-graphsurgeon
RUN python3 -m pip install protobuf==3.20.1
RUN python3 -m pip install onnx-simplifier
RUN python3 -m pip install Qt.py
RUN git clone https://github.com/fateshelled/OnnxGraphQt.git && \
cd OnnxGraphQt && \
python3 -m pip install -U -r requirements.txt
# Set PATH
RUN echo "export PATH=$PATH:$HOME/.local/bin" >> ~/.bashrc
#!/bin/sh
XSOCK=/tmp/.X11-unix
XAUTH=/tmp/.docker.xauth
touch $XAUTH
xauth nlist $DISPLAY | sed -e 's/^..../ffff/' | xauth -f $XAUTH nmerge -
docker run --rm -it \
--volume=$XSOCK:$XSOCK:rw \
--volume=$XAUTH:$XAUTH:rw \
--volume=$HOME:$HOME \
--shm-size=1gb \
--env="XAUTHORITY=${XAUTH}" \
--env="DISPLAY=${DISPLAY}" \
--env=TERM=xterm-256color \
--env=QT_X11_NO_MITSHM=1 \
onnxgraphqt:latest \
bash
@atinfinity
Copy link
Author

Build docker image

docker build -t onnxgraphqt --build-arg GID=$(id -g) --build-arg UID=$(id -u) .

Launch docker container

./launch_container.sh

Use OnnxGraphQt in docker container

cd OnnxGraphQt
python3 onnxgraphqt/main.py onnxgraphqt/data/mobilenetv2-7.onnx

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment