Skip to content

Commit

Permalink
Update dockerfile and README.
Browse files Browse the repository at this point in the history
  • Loading branch information
haotian-liu committed May 6, 2021
1 parent 5a18f4a commit 72e57b8
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 113 deletions.
2 changes: 2 additions & 0 deletions README.md
Expand Up @@ -50,6 +50,8 @@ COCO models:

See [INSTALL.md](INSTALL.md).

Optionally, you can use the official [Dockerfile](docker) to set up full enivronment with one command.

## Getting Started

Follow the [installation instructions](INSTALL.md) to set up required environment for running YolactEdge.
Expand Down
120 changes: 35 additions & 85 deletions docker/Dockerfile
@@ -1,93 +1,43 @@
FROM nvcr.io/nvidia/cuda:11.0.3-cudnn8-devel-ubuntu18.04

#installation settings
ARG APT_INSTALL="apt-get install -y --no-install-recommends"
ARG PIP_INSTALL="python3 -m pip --no-cache-dir install --upgrade --user"
ARG GIT_CLONE="git clone --depth 10"

#user settings
ARG USER=docker
ARG UID=1000
ARG GID=1000
ARG PW=user

# Add user and his password
RUN useradd -m ${USER} --uid=${UID} \
&& echo "${USER}:${PW}" | chpasswd \
&& usermod -s /bin/bash ${USER}

ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update && apt-get install -y \
git wget sudo build-essential \
python3 python3-setuptools python3-pip python3-dev python3-tk \
ffmpeg libsm6 libxext6
RUN ln -svf /usr/bin/python3 /usr/bin/python
RUN python -m pip install --upgrade --force pip

# TensorRT
ARG version="8.0.5.39-1+cuda11.0"
RUN apt-get update && apt-get install -y libcudnn8=${version} libcudnn8-dev=${version} && apt-mark hold libcudnn8 libcudnn8-dev
ARG version="7.2.3-1+cuda11.0"
RUN apt-get update && \
apt-get install -y libnvinfer7=${version} libnvonnxparsers7=${version} libnvparsers7=${version} libnvinfer-plugin7=${version} libnvinfer-dev=${version} libnvonnxparsers-dev=${version} libnvparsers-dev=${version} libnvinfer-plugin-dev=${version} python3-libnvinfer=${version} && \
apt-mark hold libnvinfer7 libnvonnxparsers7 libnvparsers7 libnvinfer-plugin7 libnvinfer-dev libnvonnxparsers-dev libnvparsers-dev libnvinfer-plugin-dev python3-libnvinfer

# create a non-root user
ARG USER_ID=1000
ARG USER=appuser
RUN useradd -m --no-log-init --system --uid ${USER_ID} ${USER} -g sudo
RUN echo '%sudo ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers
USER ${USER}
WORKDIR /home/${USER}
ENV PATH="/home/${USER}/.local/bin:${PATH}"

#tools
RUN apt-get update && $APT_INSTALL \
nano \
git \
python3 \
python3-setuptools \
python3-pip \
python3-dev \
build-essential \
ffmpeg \
libsm6 \
libxext6 && \
pip3 install --upgrade pip

RUN $PIP_INSTALL \
cython \
opencv-python \
pillow \
matplotlib \
GitPython \
termcolor \
tensorboard

RUN $PIP_INSTALL git+https://github.com/haotian-liu/cocoapi.git#"egg=pycocotools&subdirectory=PythonAPI"

#pytorch
RUN $PIP_INSTALL torch==1.7.1+cu110 \
torchvision==0.8.2+cu110 \
-f https://download.pytorch.org/whl/torch_stable.html

#install TensorRT packages
ENV version="8.0.5.39-1+cuda11.0"
RUN apt-get update && $APT_INSTALL \
libcudnn8=${version} \
libcudnn8-dev=${version} && \
apt-mark hold libcudnn8 libcudnn8-dev

ENV version="7.2.3-1+cuda11.0"
RUN apt-get update && $APT_INSTALL \
libnvinfer7=${version} \
libnvonnxparsers7=${version} \
libnvparsers7=${version} \
libnvinfer-plugin7=${version} \
libnvinfer-dev=${version} \
libnvonnxparsers-dev=${version} \
libnvparsers-dev=${version} \
libnvinfer-plugin-dev=${version} \
python-libnvinfer=${version} \
python3-libnvinfer=${version} && \
apt-mark hold libnvinfer7 \
libnvonnxparsers7 \
libnvparsers7 \
libnvinfer-plugin7 \
libnvinfer-dev \
libnvonnxparsers-dev \
libnvparsers-dev \
libnvinfer-plugin-dev \
python-libnvinfer \
python3-libnvinfer

#clone and compile torch2trt
RUN $GIT_CLONE https://github.com/NVIDIA-AI-IOT/torch2trt
# # Install dependencies
RUN pip install --user cython opencv-python pillow matplotlib GitPython termcolor tensorboard
RUN pip install --user git+https://github.com/haotian-liu/cocoapi.git#"egg=pycocotools&subdirectory=PythonAPI"
RUN pip install --user torch==1.7.1+cu110 torchvision==0.8.2+cu110 -f https://download.pytorch.org/whl/torch_stable.html

# torch2trt
RUN git clone https://github.com/NVIDIA-AI-IOT/torch2trt
WORKDIR /home/${USER}/torch2trt
RUN python3 setup.py install --plugins

#cleaning
RUN apt-get clean && \
apt-get autoremove && \
rm -rf /var/lib/apt/lists/* /tmp/*
RUN python setup.py install --plugins --user

#start path
WORKDIR /home/${USER}
RUN ln -s /yolact_edge
RUN ln -s /datasets
WORKDIR /home/${USER}/yolact_edge

ENV LANG C.UTF-8
19 changes: 8 additions & 11 deletions docker/README.md
@@ -1,14 +1,11 @@
Each step starts from the `yolact_edge` folder:
- Build:
## Use the container

`cd docker`
```Shell
cd docker/

`./build.sh`
- Start work:
``./docker/start.sh `pwd` <path to dataset on your computer>`` (dataset will be available inside the container in a /datasets folder)
# Build:
docker build --build-arg USER_ID=$UID -t yolact_edge_image .


Connect to runnig container (if you need more than one terminal to the container):
`./docker/into.sh`

Container uses `yolact_edge` folder as docker volume, so all your modifications will be save after closing session.
# Launch (with GPUs):
./start.sh /path/to/yolact_edge /path/to/datasets
```
5 changes: 0 additions & 5 deletions docker/build.sh

This file was deleted.

3 changes: 0 additions & 3 deletions docker/into.sh

This file was deleted.

15 changes: 6 additions & 9 deletions docker/start.sh
@@ -1,13 +1,10 @@
#!/bin/bash

SOURCE=$1
SOURCE_CODE=$1
DATASETS=$2
#for example from yolact_edge folder ./docker/start.sh `pwd` <path_to_datasets>

docker run --rm \
-ti \
--name yolact_edge \
--gpus all \
-v $SOURCE:/home/docker/yolact_edge/:rw \
-v $DATASETS:/datasets/:ro \
yolact_edge_image
docker run --gpus all -it --name=yolact_edge \
--shm-size=8gb --env="DISPLAY" --volume="/tmp/.X11-unix:/tmp/.X11-unix:rw" \
-v $SOURCE_CODE:/yolact_edge/:rw \
-v $DATASETS:/datasets/:ro \
yolact_edge_image

0 comments on commit 72e57b8

Please sign in to comment.