Skip to content

Commit

Permalink
Fix docker issues (cpu)
Browse files Browse the repository at this point in the history
  • Loading branch information
An-R committed Mar 19, 2024
1 parent 9b336e3 commit c34a39b
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 9 deletions.
2 changes: 1 addition & 1 deletion dev/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ services:
- UWSGI_PROCESSES=${uwsgi_processes:-2}
- UWSGI_THREADS=${uwsgi_threads:-1}
- CUDA_VISIBLE_DEVICES=all ##
#runtime: nvidia
runtime: nvidia
healthcheck:
test: curl --fail http://localhost:3000/healthcheck || exit 1
interval: 10s
Expand Down
37 changes: 33 additions & 4 deletions embedding-calculator/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,13 +1,37 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE:-python:3.8-slim-bullseye}
FROM ${BASE_IMAGE:-nvidia/cuda:12.3.1-base-ubuntu22.04}
#FROM pytorch/pytorch:1.13.1-cuda11.6-cudnn8-runtime

ENV TZ=Europe/Sofia \
DEBIAN_FRONTEND=noninteractive

RUN apt-get update && apt-get install -y build-essential cmake git wget unzip \
curl yasm pkg-config libswscale-dev libtbb2 libtbb-dev libjpeg-dev \
libpng-dev libtiff-dev libavformat-dev libpq-dev libfreeimage3 python3-opencv \
libaec-dev libblosc-dev libbrotli-dev libbz2-dev libgif-dev libopenjp2-7-dev \
liblcms2-dev libcharls-dev libjxr-dev liblz4-dev libcfitsio-dev libpcre3 libpcre3-dev \
libsnappy-dev libwebp-dev libzopfli-dev libzstd-dev \
&& rm -rf /var/lib/apt/lists/*
libsnappy-dev libwebp-dev libzopfli-dev libzstd-dev \
&& rm -rf /var/lib/apt/lists/*



# Update package lists and install necessary dependencies
RUN apt-get update && \
apt-get install -y software-properties-common && \
add-apt-repository -y ppa:deadsnakes/ppa && \
apt-get update && \
apt-get install -y python3.8 python3.8-dev python3-pip python3.8-distutils

# Set symbolic links for python and pip to use Python 3.8 by default
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1

# Remove existing symbolic link for pip3 if it exists
RUN rm -f /usr/bin/pip3

# Create symbolic link for pip3 to use pip3.8
RUN ln -s /usr/bin/pip3.8 /usr/bin/pip3



# Dependencies for imagecodecs
WORKDIR /tmp
Expand Down Expand Up @@ -36,12 +60,16 @@ RUN git clone --depth=1 -b 0.5.5 https://github.com/LLNL/zfp && \
rm -rf /tmp/zfp
# End imagecodecs dependencies



# install common python packages
SHELL ["/bin/bash", "-c"]
WORKDIR /app/ml
COPY requirements.txt .
# Ensure numpy is installed first as imagecodecs doesn't declare dependencies correctly until 2022.9.26,
# which is not compatible with Python 3.7


RUN pip --no-cache-dir install $(grep ^numpy requirements.txt)
RUN pip --no-cache-dir install -r requirements.txt

Expand All @@ -66,7 +94,8 @@ ENV FACE_DETECTION_PLUGIN=$FACE_DETECTION_PLUGIN CALCULATION_PLUGIN=$CALCULATION
EXTRA_PLUGINS=$EXTRA_PLUGINS
COPY src src
COPY srcext srcext
RUN python -m src.services.facescan.plugins.setup
#RUN python -m src.services.facescan.plugins.setup
RUN python3 -m src.services.facescan.plugins.setup

# copy rest of the code
COPY tools tools
Expand Down
2 changes: 1 addition & 1 deletion embedding-calculator/Dockerfile_ver2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG BASE_IMAGE
FROM ${BASE_IMAGE:-nvidia/cuda:12.1.0-cudnn8-runtime-ubi8}
FROM ${BASE_IMAGE:-nvidia/cuda:12.3.1-base-ubuntu22.04}
#FROM pytorch/pytorch:1.13.1-cuda11.6-cudnn8-runtime

RUN apt-get update && apt-get install -y build-essential cmake git wget unzip \
Expand Down
4 changes: 2 additions & 2 deletions embedding-calculator/src/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ class ENV(Constants):

# PyTorch settings
PYTORCH_MODE = get_env_bool('PYTORCH_MODE', True) # True or False
DEVICE = get_env('DEVICE', 'cpu') # 'cpu' or 'cuda:0'
DEVICE = get_env('DEVICE', 'cuda:0') # 'cpu' or 'cuda:0'
RECOGNITION_MODEL = get_env('RECOGNITION_MODEL', 'ir_50')
RECOGNITION_MODEL_PATH = get_env('RECOGNITION_MODEL_PATH', 'src/services/facescan/plugins/adaface/pretrained/adaface_ir50_ms1mv2.ckpt')
DETECTOR_NAME = get_env('DETECTOR_NAME', 'mtcnn') # mtcnn or retinaface
DETECTOR_NAME = get_env('DETECTOR_NAME', 'retinaface') # mtcnn or retinaface
DETECTOR_NETWORK_NAME = get_env('DETECTOR_NETWORK_NAME', 'mobile0.25') # 'mobile0.25' or 'resnet50'
DETECTOR_MODEL_PATH = get_env('DETECTOR_MODEL_PATH', 'src/services/facescan/plugins/pytorch_detector/weights/mobilenet0.25_Final.pth')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, cfg = None, phase = 'train'):
if cfg['name'] == 'mobilenet0.25':
backbone = MobileNetV1()
if cfg['pretrain']:
checkpoint = torch.load("services/facescan/plugins/pytorch_detector/weights/mobilenetV1X0.25_pretrain.tar", map_location=torch.device('cpu'))
checkpoint = torch.load("src/services/facescan/plugins/pytorch_detector/weights/mobilenetV1X0.25_pretrain.tar", map_location=torch.device('cpu'))
from collections import OrderedDict
new_state_dict = OrderedDict()
for k, v in checkpoint['state_dict'].items():
Expand Down

0 comments on commit c34a39b

Please sign in to comment.