From 70d2c99171330393a4c80c0f9db4af45d64a42f5 Mon Sep 17 00:00:00 2001 From: Roman Donchenko Date: Mon, 15 May 2023 01:44:43 +0400 Subject: [PATCH] Fix the CPU HRNet Nuclio function It was broken for two reasons: * Due to some changes on the PyTorch website, the old way of installing the PyTorch packages now installs the ROCm version rather than the CPU version (and it doesn't work doe to a missing dependency). * The newest version of NumPy doesn't work with HRNet due to the latter's usage of `np.int`. Fix these problems, and in addition, rework the build recipe to avoid installing unneeded packages. Altogether, the changes massively shrink the Docker image size (from ~14 GB to ~2 GB). I didn't update the GPU version, because a) the first issue doesn't affect it, b) the second issue is already fixed in it, and c) I don't have a GPU to test it on. --- .../saic-vul/hrnet/nuclio/function.yaml | 46 +++++++------------ 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/serverless/pytorch/saic-vul/hrnet/nuclio/function.yaml b/serverless/pytorch/saic-vul/hrnet/nuclio/function.yaml index 475f8998fafa..38c962d42bdf 100644 --- a/serverless/pytorch/saic-vul/hrnet/nuclio/function.yaml +++ b/serverless/pytorch/saic-vul/hrnet/nuclio/function.yaml @@ -27,40 +27,28 @@ spec: directives: preCopy: - - kind: ENV - value: DEBIAN_FRONTEND=noninteractive - kind: RUN - value: apt-get update && apt-get install software-properties-common -y - - kind: RUN - value: add-apt-repository ppa:deadsnakes/ppa - - kind: RUN - value: apt remove python* -y - - kind: RUN - value: apt-get update && apt-get install -y --no-install-recommends build-essential git curl libglib2.0-0 software-properties-common python3 python3.6-dev python3-pip python3-tk - - kind: RUN - value: ln -s /usr/bin/pip3 /usr/local/bin/pip && ln -s /usr/bin/python3 /usr/bin/python + value: |- + apt-get update \ + && apt-get install -y --no-install-recommends \ + git libgl1-mesa-glx libglib2.0-0 python3 python3-pip python-is-python3 \ + && rm -rf /var/lib/apt/lists/* - kind: RUN value: pip3 install --upgrade pip - - kind: WORKDIR - value: /opt/nuclio - - kind: RUN - value: git clone https://github.com/saic-vul/ritm_interactive_segmentation.git hrnet - - kind: WORKDIR - value: /opt/nuclio/hrnet - - kind: RUN - value: apt-get install -y --no-install-recommends wget - - kind: RUN - value: wget https://github.com/saic-vul/ritm_interactive_segmentation/releases/download/v1.0/coco_lvis_h18_itermask.pth - - kind: RUN - value: pip3 install setuptools - - kind: RUN - value: pip3 install -r requirements.txt - - kind: RUN - value: apt update && apt install -y libgl1-mesa-glx - kind: RUN - value: pip3 uninstall torch torch vision -y + value: git clone https://github.com/saic-vul/ritm_interactive_segmentation.git /opt/nuclio/hrnet + - kind: ADD + value: >- + https://github.com/saic-vul/ritm_interactive_segmentation/releases/download/v1.0/coco_lvis_h18_itermask.pth + /opt/nuclio/hrnet/ - kind: RUN - value: pip install torch==1.8.1 torchvision==0.9.1 torchaudio==0.8.1 -f https://download.pytorch.org/whl/torch_stable.html + # NumPy is capped due to https://github.com/SamsungLabs/ritm_interactive_segmentation/issues/36 + value: |- + pip3 install --no-cache-dir \ + -r /opt/nuclio/hrnet/requirements.txt \ + torch==1.8.1+cpu torchvision==0.9.1+cpu \ + 'numpy<1.24' \ + --extra-index-url=https://download.pytorch.org/whl/cpu - kind: WORKDIR value: /opt/nuclio