Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👷 GPU support with docker #9

Merged
merged 1 commit into from
Feb 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
👷 GPU support with docker
  • Loading branch information
JuInria committed Feb 16, 2022
commit fdcb92a40e99882e55928117d507b88d98bad760
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,25 @@ YOLOv3, YOLOv3-tiny, YOLOv4, YOLOv4-tiny

# Docker

The [Dockerfile](./docker_images/Dockerfile) embeds every requirement of this project.
The [Dockerfiles](./docker_images/) embed every requirement for this project.

## GPU dedicated Dockerfile
The [GPU dedicated Dockerfile](./docker_images/gpu/Dockerfile) relies on a [`BASE_IMAGE`](./docker_images/gpu/Dockerfile#L1) (default: `nvidia/cuda:11.2.2-cudnn8-runtime-ubuntu20.04`) which depends on the NVIDIA GPUs and the CUDA driver which is installed on the Host OS.

**For further details**, please refer to [Installing Docker and The Docker Utility Engine for NVIDIA GPUs](https://docs.nvidia.com/ai-enterprise/deployment-guide/dg-docker.html).


## General
The following parameters have to be used at the docker run:
- `--env=DISPLAY`: Exports DISPLAY env variable for X server
- `--env=QT_X11_NO_MITSHM=1`: Prevents QT-based applications from using X’s shared memory, which Docker isolation blocks.
- `--volume=/tmp/.X11-unix:/tmp/.X11-unix:rw`: Mounts the X11 socket

**Note:** Running `xhost +local:docker` on the Host OS allows docker to access X server.

_Optional_ parameters:
- `--volume=${env:HOME}/.gitconfig:/etc/gitconfig`: Share Git config
- `--gpus all`: Share the GPUs with docker. Should be used only if you plan to use the GPU dedicated docker image.
---

## 0. Please Read Source Code for More Details
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ RUN apt update && apt install --no-install-recommends -y python3-pip &&\
apt-mirror-updater -a -q &&\
rm -rf /var/lib/apt/lists/*

# Install essentials
RUN apt-mirror-updater -a -q &&\
apt install -y build-essential &&\
rm -rf /var/lib/apt/lists/*

# OpenCV
RUN apt-mirror-updater -a -q &&\
apt install --no-install-recommends -y python3-opencv &&\
Expand Down
41 changes: 41 additions & 0 deletions docker_images/gpu/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
ARG BASE_IMAGE=nvidia/cuda:11.2.2-cudnn8-runtime-ubuntu20.04

FROM ${BASE_IMAGE}

ENV DEBIAN_FRONTEND=noninteractive

# Nvidia hardware acceleration
ENV NVIDIA_VISIBLE_DEVICES \
${NVIDIA_VISIBLE_DEVICES:-all}
ENV NVIDIA_DRIVER_CAPABILITIES \
${NVIDIA_DRIVER_CAPABILITIES:+$NVIDIA_DRIVER_CAPABILITIES,}graphics

# Install a tool to find a fast, up-to-date Ubuntu Archive Mirror.
RUN apt update && apt install --no-install-recommends -y python3-pip &&\
pip3 install -U pip &&\
pip3 install apt-mirror-updater &&\
apt-mirror-updater -a -q &&\
rm -rf /var/lib/apt/lists/*

# Tensorflow
RUN pip3 install -U pip &&\
pip3 install -U tensorflow==2.7.0

# OpenCV
RUN apt-mirror-updater -a -q &&\
apt install --no-install-recommends -y python3-opencv &&\
pip3 install -U pip &&\
pip3 install opencv-python &&\
pip3 install pyyaml &&\
rm -rf /var/lib/apt/lists/*

# LabelImg
RUN apt-mirror-updater -a -q &&\
apt install --no-install-recommends -y pyqt5-dev-tools &&\
pip3 install -U pip &&\
pip3 install labelImg

# Model conversion
RUN pip3 install tf2onnx

RUN ldconfig