Skip to content

Commit

Permalink
Merge branch 'master' into mxnet_quantization
Browse files Browse the repository at this point in the history
  • Loading branch information
ismukhin committed Oct 8, 2023
2 parents 342836b + 18c10c8 commit a1418d0
Show file tree
Hide file tree
Showing 13 changed files with 628 additions and 444 deletions.
5 changes: 3 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ ARG DEPENDENCIES="apt-utils \
libtool \
libprotobuf-dev \
libgl1-mesa-glx \
nlohmann-json3-dev \
python3-pip \
python3-setuptools \
python3-dev \
Expand Down Expand Up @@ -58,7 +59,7 @@ RUN pip3 install openvino-dev==${OV_SHORT_VERSION}

# Download DLI source code
WORKDIR /tmp/
RUN git clone https://github.com/itlab-vision/dl-benchmark.git --depth 1 && \
RUN git clone --recursive https://github.com/itlab-vision/dl-benchmark.git --depth 1 && \
pip3 install docker PyYAML

# accuracy-check
Expand All @@ -69,6 +70,6 @@ RUN wget -q https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
RUN tar xvf cifar-10-python.tar.gz -C sample

# Download dataset if repository with dataset is set
WORKDIR /tmp/
ARG DATASET_DOWNLOAD_LINK
RUN if [ -z "$DATASET_DOWNLOAD_LINK" ] ; then echo Argument DATASET_DOWNLOAD_LINK not provided ; else git clone $DATASET_DOWNLOAD_LINK ; fi
WORKDIR /tmp/
4 changes: 1 addition & 3 deletions docker/MXNet/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ RUN pip uninstall -y numpy && pip install numpy==1.23.1

# Download Accuracy Checker
WORKDIR /tmp/
COPY config.yml config.yml
WORKDIR /tmp/open_model_zoo/tools/accuracy_checker
RUN /bin/bash -c 'accuracy_check -c /tmp/config.yml -m data/test_models -s sample'
RUN /bin/bash -c 'accuracy_check -c /tmp/dl-benchmark/docker/MXNet/config.yml -m data/test_models -s sample'
WORKDIR /tmp/
RUN rm config.yml
4 changes: 1 addition & 3 deletions docker/ONNXRuntime/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ RUN pip install onnxruntime==${ONNX_VERSION} && pip install onnx==${ONNX_VERSION

# accuracy-check
WORKDIR /tmp/open_model_zoo/tools/accuracy_checker
COPY config.yml config.yml
RUN accuracy_check -c config.yml -m data/test_models -s sample
RUN rm config.yml
RUN accuracy_check -c /tmp/dl-benchmark/docker/ONNXRuntime/config.yml -m data/test_models -s sample

WORKDIR /tmp/
78 changes: 78 additions & 0 deletions docker/PyTorch/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
FROM ubuntu_for_dli

WORKDIR /root/

ARG TORCH_VERSION=2.0.1
ARG TORCHVISION_VERSION=0.15.2
ARG OCV_VERSION=4.7.0
ARG CMAKE_VERSION=3.24

# Install cmake
WORKDIR /tmp/
RUN pip3 install --upgrade pip
RUN pip3 install cmake==${CMAKE_VERSION}

# Install OpenCV using C++ build
WORKDIR /tmp/
RUN git clone --recurse-submodules https://github.com/opencv/opencv.git --depth 1 --branch ${OCV_VERSION} --single-branch
ENV OpenCV_BUILD_DIR=/tmp/build-opencv
RUN mkdir $OpenCV_BUILD_DIR
WORKDIR $OpenCV_BUILD_DIR
RUN /bin/bash -c 'cmake -G Ninja \
-D CMAKE_INSTALL_PREFIX=install \
-D CMAKE_BUILD_TYPE=Release \
-D BUILD_EXAMPLES=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_DOCS=OFF \
-D OPENCV_LIB_INSTALL_PATH=lib \
-D OPENCV_CONFIG_INSTALL_PATH=cmake \
-D PYTHON3_PACKAGES_PATH=install/python/python3 \
/tmp/opencv/ && ninja && cmake --install .' && \
rm -r /tmp/opencv
ENV OpenCV_INSTALL_DIR="$OpenCV_BUILD_DIR/install"
ENV OpenCV_DIR="$OpenCV_INSTALL_DIR/cmake"
ENV LD_LIBRARY_PATH="$OpenCV_INSTALL_DIR/lib${LD_LIBRARY_PATH:+:$LD_LIBRARY_PATH}"
ENV PYTHONPATH="$OpenCV_INSTALL_DIR/python/python3/cv2/python-3.8${PYTHONPATH:+:$PYTHONPATH}"

# Install PyTorch using C++ build
WORKDIR /tmp/
RUN git clone --recurse-submodules https://github.com/pytorch/pytorch --depth 1 --branch v${TORCH_VERSION} --single-branch
RUN pip3 install -r ./pytorch/requirements.txt
ENV TORCH_BUILD_DIR=/tmp/build-torch
RUN mkdir $TORCH_BUILD_DIR
WORKDIR $TORCH_BUILD_DIR
RUN cmake \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_BUILD_TYPE=Release \
-DPYTHON_EXECUTABLE=`which python3` \
-DCMAKE_INSTALL_PREFIX=install \
/tmp/pytorch && cmake --build . --target install -- -j$(nproc --all) && rm -r /tmp/pytorch
ENV TORCH_INSTALL_DIR="$TORCH_BUILD_DIR/install"

# Install PyTorch Python
RUN pip3 install torch==${TORCH_VERSION} \
torchvision==${TORCHVISION_VERSION}

# Build Benchmark C++
WORKDIR /tmp/
RUN cd dl-benchmark && git submodule update --init && cd ..
RUN mkdir benchmark_build && cd benchmark_build && \
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_PYTORCH_LAUNCHER=ON \
-DTorch_DIR="$TORCH_INSTALL_DIR/share/cmake/Torch/" \
/tmp/dl-benchmark/src/cpp_dl_benchmark && cmake --build . -- -j$(nproc --all)

# Install Accuracy Checker
ENV ACCURACY_CHECKER_PATH=/tmp/open_model_zoo/tools/accuracy_checker
WORKDIR $ACCURACY_CHECKER_PATH
COPY config.yml config.yml
# make module path relative in config
ARG MODELS_DIR=$ACCURACY_CHECKER_PATH/data/test_models
RUN sed -i 's|MODELS_DIR|'${MODELS_DIR}'|g' config.yml

# please uncomment out when OMZ version will be >=2023.0 (see commit: a89aade)
# RUN python3 setup.py install_core; \
# accuracy_check -c config.yml -m data/test_models -s sample

WORKDIR /tmp/
32 changes: 32 additions & 0 deletions docker/PyTorch/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
models:
- name: SampLeNet
launchers:
- framework: pytorch
device: cpu
module: samplenet.SampLeNet
checkpoint: MODELS_DIR/pytorch_model/samplenet.pth
adapter: classification
batch: 1
python_path: MODELS_DIR/pytorch_model

datasets:
- name: sample_dataset
data_source: sample_dataset/test
annotation_conversion:
converter: cifar
data_batch_file: cifar-10-batches-py/test_batch
convert_images: True
converted_images_dir: sample_dataset/test
num_classes: 10

preprocessing:
- type: resize
size: 32
- type: bgr_to_rgb
- type: normalization
mean: (125.307, 122.961, 113.8575)
std: (51.5865, 50.847, 51.255)

metrics:
- type: accuracy
top_k: 1
7 changes: 2 additions & 5 deletions docker/TensorFlow/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,15 @@ RUN python3 ./open_model_zoo/tools/model_tools/downloader.py --list models.lst
RUN rm models.lst

WORKDIR /tmp/open_model_zoo/tools/accuracy_checker
COPY config_tf2.yml config_tf2.yml
COPY config_intel-tf.yml config_intel-tf.yml

RUN if [ "$FRAMEWORK" = "intel-tensorflow" ] || [ -z "$FRAMEWORK" ] ; then \
pip3 install intel-tensorflow==${TF_VERSION}; \
python3 setup.py install_core; \
accuracy_check -c config_intel-tf.yml -m data/test_models -s sample; \
accuracy_check -c /tmp/dl-benchmark/docker/TensorFlow/config_intel-tf.yml -m data/test_models -s sample; \
elif [ "$FRAMEWORK" = "tensorflow" ] ; then \
pip3 install tensorflow==${TF_VERSION}; \
python3 setup.py install_core; \
accuracy_check -c config_tf2.yml -m data/test_models -s sample; \
accuracy_check -c /tmp/dl-benchmark/docker/TensorFlow/config_tf2.yml -m data/test_models -s sample; \
fi
RUN rm config_tf2.yml && rm config_intel-tf.yml

WORKDIR /tmp/
Loading

0 comments on commit a1418d0

Please sign in to comment.