-
Notifications
You must be signed in to change notification settings - Fork 393
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Joel Polizzi <[email protected]>
- Loading branch information
1 parent
184dbf4
commit d8096c9
Showing
2 changed files
with
530 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,256 @@ | ||
# ============================================================================= | ||
# @@-COPYRIGHT-START-@@ | ||
# | ||
# Copyright (c) 2021-2023, Qualcomm Innovation Center, Inc. All rights reserved. | ||
# | ||
# Redistribution and use in source and binary forms, with or without | ||
# modification, are permitted provided that the following conditions are met: | ||
# | ||
# 1. Redistributions of source code must retain the above copyright notice, | ||
# this list of conditions and the following disclaimer. | ||
# | ||
# 2. Redistributions in binary form must reproduce the above copyright notice, | ||
# this list of conditions and the following disclaimer in the documentation | ||
# and/or other materials provided with the distribution. | ||
# | ||
# 3. Neither the name of the copyright holder nor the names of its contributors | ||
# may be used to endorse or promote products derived from this software | ||
# without specific prior written permission. | ||
# | ||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" | ||
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | ||
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | ||
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE | ||
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | ||
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | ||
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | ||
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | ||
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | ||
# POSSIBILITY OF SUCH DAMAGE. | ||
# | ||
# SPDX-License-Identifier: BSD-3-Clause | ||
# | ||
# @@-COPYRIGHT-END-@@ | ||
# ============================================================================= | ||
|
||
# Docker image file to build and test AIMET for PyTorch in a CPU environment | ||
|
||
ARG REGISTRY | ||
FROM ${REGISTRY}ubuntu:focal | ||
|
||
ARG DEBIAN_FRONTEND=noninteractive | ||
|
||
RUN apt-get update > /dev/null && \ | ||
apt-get install --no-install-recommends -y \ | ||
# Bare minimum Packages | ||
ca-certificates \ | ||
git \ | ||
ssh \ | ||
sudo \ | ||
wget \ | ||
xterm \ | ||
xauth > /dev/null && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Install certificates | ||
RUN sudo update-ca-certificates | ||
|
||
# Modified version of bash.bashrc that adjusts the prompt | ||
### COPY bash.bashrc /etc/ | ||
### RUN chmod 644 /etc/bash.bashrc | ||
|
||
### COPY profile.global /usr/local/etc/ | ||
### RUN chmod 555 /usr/local/etc/profile.global | ||
|
||
# Add sudo support | ||
RUN echo "%users ALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers | ||
|
||
RUN apt-get update -y > /dev/null && \ | ||
apt-get install --no-install-recommends -y \ | ||
# Python | ||
python3.8 \ | ||
python3.8-dev \ | ||
python3.8-venv \ | ||
python3-pip \ | ||
python3-setuptools \ | ||
build-essential \ | ||
# lmdb dependency | ||
libffi-dev && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Register the version in alternatives | ||
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.8 1 | ||
# Set python 3.8 as the default python | ||
RUN update-alternatives --set python3 /usr/bin/python3.8 | ||
|
||
# Upgrade Python3 pip and install some more packages | ||
RUN python3 -m pip --no-cache-dir install --upgrade \ | ||
pip \ | ||
setuptools==41.0.1 \ | ||
wheel==0.33.4 | ||
|
||
# Ubuntu packages for pytorch aimet | ||
RUN dpkg --add-architecture i386 | ||
RUN apt-get update > /dev/null && \ | ||
apt-get install --no-install-recommends -y \ | ||
build-essential \ | ||
emacs \ | ||
environment-modules \ | ||
less \ | ||
libavcodec-dev \ | ||
libavformat-dev \ | ||
libeigen3-dev \ | ||
libgtest-dev \ | ||
libgtk2.0-dev \ | ||
libsox-dev \ | ||
libsox-fmt-all \ | ||
libstdc++6:i386 \ | ||
libswscale-dev \ | ||
libxtst6 \ | ||
lsb-release \ | ||
meld \ | ||
nano \ | ||
pandoc \ | ||
pkg-config \ | ||
python3-tk \ | ||
sox \ | ||
tree \ | ||
vim && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Python3 Packages | ||
RUN python3 -m pip --no-cache-dir install \ | ||
astroid==2.5.3 \ | ||
attrs==19.1.0 \ | ||
behave==1.2.6 \ | ||
blosc==1.10.1 \ | ||
cffi==1.12.3 \ | ||
click \ | ||
cumm==0.2.8 \ | ||
cython==0.29.12 \ | ||
dataclasses \ | ||
Deprecated \ | ||
docutils==0.16 \ | ||
grpcio \ | ||
grpcio-tools \ | ||
h5py==2.10.0 \ | ||
ipykernel \ | ||
ipython \ | ||
Jinja2==3.0.3 \ | ||
jupyter \ | ||
keras==2.2.4 \ | ||
lmdb==1.2.1 \ | ||
matplotlib>=3 \ | ||
mock \ | ||
nbsphinx==0.8.12 \ | ||
'numpy<1.24,>=1.16.6' \ | ||
onnx==1.11.0 \ | ||
onnxsim \ | ||
onnxruntime==1.11.0 \ | ||
onnxruntime-extensions \ | ||
opencv-python \ | ||
Pillow==9.3.0 \ | ||
pluggy==0.12.0 \ | ||
progressbar2 \ | ||
protobuf==3.20.1 \ | ||
psutil \ | ||
ptflops \ | ||
pybind11 \ | ||
pyDOE2 \ | ||
pylint==2.3.1 \ | ||
pymoo==0.4.1 \ | ||
pytest==4.6.5 \ | ||
pytest-cov==2.6.1 \ | ||
pytorch-ignite \ | ||
PyYAML \ | ||
scikit-learn==1.1.3 \ | ||
scipy==1.8.1 \ | ||
spconv==2.1.20 \ | ||
sphinx==2.1.1 \ | ||
sphinx-autodoc-typehints==1.6.0 \ | ||
sphinx-jinja==1.1.1 \ | ||
sphinx-rtd-theme \ | ||
tensorboard==2.4.0 \ | ||
tensorboardX==2.4 \ | ||
timm==0.4.12 \ | ||
torch==1.9.1+cpu -f https://download.pytorch.org/whl/torch_stable.html \ | ||
torchaudio==0.9.1 -f https://download.pytorch.org/whl/torch_stable.html \ | ||
torchtext==0.10.1 \ | ||
torchvision==0.10.1+cpu -f https://download.pytorch.org/whl/torch_stable.html \ | ||
tqdm \ | ||
transformers==4.11.3 \ | ||
wget && \ | ||
python3 -m ipykernel.kernelspec | ||
|
||
# Install cmake | ||
RUN mkdir -p /opt/cmake && \ | ||
wget -P /tmp https://github.com/Kitware/CMake/releases/download/v3.19.3/cmake-3.19.3-Linux-x86_64.sh && \ | ||
sh /tmp/cmake-3.19.3-Linux-x86_64.sh --prefix=/opt/cmake --skip-license && \ | ||
rm -f /tmp/cmake-3.19.3-Linux-x86_64.sh && \ | ||
ln -fs /opt/cmake/bin/cmake /usr/local/bin/cmake && \ | ||
ln -fs /opt/cmake/bin/ctest /usr/local/bin/ctest && \ | ||
ln -fs /opt/cmake/bin/cpack /usr/local/bin/cpack | ||
|
||
# Onnxruntime C/C++ package needed to create custom C++ onnx ops for quantsim | ||
RUN mkdir /opt/onnxruntime && \ | ||
export ONNXRUNTIME_VER=$(python3 -c 'import onnxruntime; print(onnxruntime.__version__)') && \ | ||
wget -qO- "https://github.com/microsoft/onnxruntime/releases/download/v${ONNXRUNTIME_VER}/onnxruntime-linux-x64-${ONNXRUNTIME_VER}.tgz" | tar xvz --strip-components 1 -C /opt/onnxruntime && \ | ||
ln -s /opt/onnxruntime /usr/local/bin/onnxruntime_headers | ||
|
||
ENV PATH=/usr/local/bin:$PATH | ||
|
||
# Opencv | ||
# Ref: https://docs.opencv.org/3.2.0/d7/d9f/tutorial_linux_install.html | ||
COPY opencv_320_python38.patch /tmp | ||
RUN wget -q https://github.com/Itseez/opencv/archive/3.2.0.tar.gz -O /tmp/3.2.0.tar.gz > /dev/null && \ | ||
tar -C /tmp -xvf /tmp/3.2.0.tar.gz > /dev/null && \ | ||
patch /tmp/opencv-3.2.0/modules/python/src2/cv2.cpp /tmp/opencv_320_python38.patch && \ | ||
cd /tmp/opencv-3.2.0 && mkdir release && cd release && \ | ||
cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=release -DWITH_FFMPEG=OFF -DBUILD_TESTS=OFF -DWITH_CUDA=OFF -DBUILD_PERF_TESTS=OFF -DWITH_IPP=OFF -DENABLE_PRECOMPILED_HEADERS=OFF .. > /dev/null && \ | ||
make -j16 > /dev/null && \ | ||
make -j16 install > /dev/null && \ | ||
rm -rf /tmp/opencv-3.2.0* | ||
|
||
EXPOSE 25000 | ||
RUN apt-get update && apt-get install -y openssh-server && rm -rf /var/lib/apt/lists/* | ||
RUN mkdir /var/run/sshd | ||
|
||
RUN apt-get update && apt-get install -y liblapacke liblapacke-dev && rm -rf /var/lib/apt/lists/* | ||
|
||
RUN apt-get update && apt-get install -y libjpeg8-dev && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Set up symlink to point to the correct python version | ||
RUN ln -sf /usr/bin/python3.8 /usr/bin/python | ||
RUN ln -s /usr/lib/x86_64-linux-gnu/libjpeg.so /usr/lib | ||
|
||
RUN sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config && \ | ||
sed -i 's/Port 22/Port 25000/' /etc/ssh/sshd_config | ||
|
||
# SSH login fix. Otherwise user is kicked off after login | ||
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd | ||
|
||
RUN python3 -m pip install git-pylint-commit-hook osqp | ||
|
||
# NOTE: We need to pin the holoviews version to this since the latest version has a circular dependency on bokeh 2.0.0 through the panel package | ||
RUN python3 -m pip install holoviews==1.12.7 netron jsonschema pandas==1.5.3 | ||
|
||
# Note: bokeh requires Pillow while we need to use Pillow-SIMD for performance reasons. | ||
RUN python3 -m pip install bokeh==1.2.0 hvplot==0.4.0 | ||
|
||
# Remove existing Pillow & Pillow-SIMD and replace with correct version of Pillow-SIMD. | ||
RUN python3 -m pip uninstall -y Pillow Pillow-SIMD | ||
RUN python3 -m pip --no-cache-dir install Pillow-SIMD==9.0.0.post1 | ||
|
||
RUN apt-get update && apt-get install -y gnupg2 | ||
# Downloaded from https://apt.llvm.org/ | ||
RUN wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key|sudo apt-key add - && echo "deb http://apt.llvm.org/focal/ llvm-toolchain-focal-11 main" >> /etc/apt/sources.list | ||
RUN apt-get update --fix-missing -y && apt upgrade -y && apt-get install -y clang-11 clang-format clang-tidy-11 && \ | ||
rm -rf /var/lib/apt/lists/* | ||
|
||
# Create a version-less symbolic link for clang-tidy | ||
RUN ln -s /usr/bin/run-clang-tidy-11.py /usr/bin/run-clang-tidy.py | ||
|
||
# Provide write permission to the python package folder in order to install AIMET in editable mode | ||
RUN chmod o+w /usr/local/lib/python3.8/dist-packages |
Oops, something went wrong.