From ea69b21fd09195275f6ba781bc257a1816fa2370 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 10:55:11 -0700 Subject: [PATCH 01/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 3b2e55cd..d85875d7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -39,7 +39,8 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ apt-transport-https \ ca-certificates \ gnupg \ - software-properties-common && \ + software-properties-common \ + python3-pip && \ wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \ echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ @@ -74,7 +75,14 @@ RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Mini /opt/conda/bin/conda install -y python=${PYTHON_VERSION} mkl mkl-include conda-build pyyaml numpy ipython && \ /opt/conda/bin/conda install -y -c conda-forge libpython-static=${PYTHON_VERSION} && \ /opt/conda/bin/conda install -y pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch-nightly && \ - /opt/conda/bin/conda clean -ya + /opt/conda/bin/conda clean -ya && \ + git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ + export PYENV_ROOT="~/.pyenv" && \ + export PATH="$PYENV_ROOT/bin:$PATH" && \ + pyenv install --list && \ + pip3 install virtualenv && \ + pyenv install --force 3.7.10 && \ + virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 # Build/Install pytorch with post-cxx11 ABI From fcfc9eb68cc83a43141c8a97181a36210fadf539 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 11:07:39 -0700 Subject: [PATCH 02/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index d85875d7..f703aa80 100644 --- a/Dockerfile +++ b/Dockerfile @@ -58,12 +58,12 @@ COPY . . RUN git submodule update --init --recursive --jobs 0 # install pyenv -FROM dev-base as pyenv-install -RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ - export PYENV_ROOT="~/.pyenv" && \ - export PATH="$PYENV_ROOT/bin:$PATH" -# dummy cmd to verify installation. -RUN pyenv install --list +# FROM dev-base as pyenv-install +# RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ +# export PYENV_ROOT="~/.pyenv" && \ +# export PATH="$PYENV_ROOT/bin:$PATH" +# # dummy cmd to verify installation. +# RUN pyenv install --list # Install conda + neccessary python dependencies FROM dev-base as conda @@ -76,11 +76,12 @@ RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Mini /opt/conda/bin/conda install -y -c conda-forge libpython-static=${PYTHON_VERSION} && \ /opt/conda/bin/conda install -y pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch-nightly && \ /opt/conda/bin/conda clean -ya && \ + pip3 install virtualenv && \ git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ export PYENV_ROOT="~/.pyenv" && \ - export PATH="$PYENV_ROOT/bin:$PATH" && \ - pyenv install --list && \ - pip3 install virtualenv && \ + export PATH="$PYENV_ROOT/bin:$PATH" + # exec shell ? +RUN export CFLAGS="-fPIC -g" && \ pyenv install --force 3.7.10 && \ virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 From 159893d35c2e4633429641e68dc456e30bf2af09 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 11:18:19 -0700 Subject: [PATCH 03/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index f703aa80..720ff521 100644 --- a/Dockerfile +++ b/Dockerfile @@ -78,11 +78,12 @@ RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Mini /opt/conda/bin/conda clean -ya && \ pip3 install virtualenv && \ git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ - export PYENV_ROOT="~/.pyenv" && \ - export PATH="$PYENV_ROOT/bin:$PATH" + # export PYENV_ROOT="~/.pyenv" && \ + # export PATH="$PYENV_ROOT/bin:$PATH" # exec shell ? +ENV PATH ~/.pyenv/bin:$PATH RUN export CFLAGS="-fPIC -g" && \ - pyenv install --force 3.7.10 && \ + ~/.pyenv/bin/pyenv install --force 3.7.10 && \ virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 From 6889445728a2fbe01dc84e77cac21429631b1679 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 11:26:33 -0700 Subject: [PATCH 04/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 720ff521..14c0befc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,13 +77,13 @@ RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Mini /opt/conda/bin/conda install -y pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch-nightly && \ /opt/conda/bin/conda clean -ya && \ pip3 install virtualenv && \ - git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ + git clone https://github.com/pyenv/pyenv.git ~/.pyenv # export PYENV_ROOT="~/.pyenv" && \ # export PATH="$PYENV_ROOT/bin:$PATH" # exec shell ? ENV PATH ~/.pyenv/bin:$PATH RUN export CFLAGS="-fPIC -g" && \ - ~/.pyenv/bin/pyenv install --force 3.7.10 && \ + pyenv install --force 3.7.10 && \ virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 From 6dfec4c39303b64940822de1c7a8be735555d82c Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 11:34:30 -0700 Subject: [PATCH 05/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 14c0befc..8e7d0303 100644 --- a/Dockerfile +++ b/Dockerfile @@ -77,14 +77,16 @@ RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Mini /opt/conda/bin/conda install -y pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch-nightly && \ /opt/conda/bin/conda clean -ya && \ pip3 install virtualenv && \ - git clone https://github.com/pyenv/pyenv.git ~/.pyenv + git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ + export CFLAGS="-fPIC -g" && \ + ~/.pyenv/bin/pyenv install --force 3.7.10 # export PYENV_ROOT="~/.pyenv" && \ # export PATH="$PYENV_ROOT/bin:$PATH" # exec shell ? -ENV PATH ~/.pyenv/bin:$PATH -RUN export CFLAGS="-fPIC -g" && \ - pyenv install --force 3.7.10 && \ - virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 +#ENV PATH ~/.pyenv/bin:$PATH +# RUN export CFLAGS="-fPIC -g" && \ +# pyenv install --force 3.7.10 && \ +# virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 # Build/Install pytorch with post-cxx11 ABI From bfd5b6969451a66750ab67b7850f5563dba6004f Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 11:47:28 -0700 Subject: [PATCH 06/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8e7d0303..c8ab9c62 100644 --- a/Dockerfile +++ b/Dockerfile @@ -79,7 +79,10 @@ RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Mini pip3 install virtualenv && \ git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ export CFLAGS="-fPIC -g" && \ - ~/.pyenv/bin/pyenv install --force 3.7.10 + ~/.pyenv/bin/pyenv install --force 3.7.10 && \ + virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 && \ + source ~/venvs/multipy_3_7_10/bin/activate && \ + pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113 # export PYENV_ROOT="~/.pyenv" && \ # export PATH="$PYENV_ROOT/bin:$PATH" # exec shell ? From a697e7c7115f83bf5f250c7fdb693e92ec6f88e7 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 12:07:26 -0700 Subject: [PATCH 07/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index c8ab9c62..6ceca30e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,8 @@ ARG BASE_IMAGE=nvidia/cuda:11.3.1-devel-ubuntu18.04 FROM ${BASE_IMAGE} as dev-base +SHELL ["/bin/bash", "-c"] + # Install system dependencies RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ apt update && DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends \ From 45e00fd497c48930837563cfd68409975d485c6c Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 12:27:58 -0700 Subject: [PATCH 08/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Dockerfile b/Dockerfile index 6ceca30e..38c7af8a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -105,6 +105,8 @@ WORKDIR /opt/multipy # Build Multipy RUN mkdir multipy/runtime/build && \ cd multipy/runtime/build && \ + export CC=/usr/bin/gcc-7 && \ + export CXX=/usr/bin/g++-7 && \ cmake .. && \ cmake --build . --config Release && \ cmake --install . --prefix "." From 9377eff278f3b1d61df01e6a82e5603c8157c2d8 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 12:45:41 -0700 Subject: [PATCH 09/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 38c7af8a..4ad2039b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,15 +70,15 @@ RUN git submodule update --init --recursive --jobs 0 # Install conda + neccessary python dependencies FROM dev-base as conda ARG PYTHON_VERSION=3.8 -RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ - chmod +x ~/miniconda.sh && \ - ~/miniconda.sh -b -p /opt/conda && \ - rm ~/miniconda.sh && \ - /opt/conda/bin/conda install -y python=${PYTHON_VERSION} mkl mkl-include conda-build pyyaml numpy ipython && \ - /opt/conda/bin/conda install -y -c conda-forge libpython-static=${PYTHON_VERSION} && \ - /opt/conda/bin/conda install -y pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch-nightly && \ - /opt/conda/bin/conda clean -ya && \ - pip3 install virtualenv && \ +# RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ +# chmod +x ~/miniconda.sh && \ +# ~/miniconda.sh -b -p /opt/conda && \ +# rm ~/miniconda.sh && \ +# /opt/conda/bin/conda install -y python=${PYTHON_VERSION} mkl mkl-include conda-build pyyaml numpy ipython && \ +# /opt/conda/bin/conda install -y -c conda-forge libpython-static=${PYTHON_VERSION} && \ +# /opt/conda/bin/conda install -y pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch-nightly && \ +# /opt/conda/bin/conda clean -ya && \ +RUN pip3 install virtualenv && \ git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ export CFLAGS="-fPIC -g" && \ ~/.pyenv/bin/pyenv install --force 3.7.10 && \ From 51ab43cd9432b898702337583d9e92d5ca6ea9c7 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 12:48:27 -0700 Subject: [PATCH 10/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 4ad2039b..e7e04125 100644 --- a/Dockerfile +++ b/Dockerfile @@ -80,7 +80,6 @@ ARG PYTHON_VERSION=3.8 # /opt/conda/bin/conda clean -ya && \ RUN pip3 install virtualenv && \ git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ - export CFLAGS="-fPIC -g" && \ ~/.pyenv/bin/pyenv install --force 3.7.10 && \ virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 && \ source ~/venvs/multipy_3_7_10/bin/activate && \ @@ -107,6 +106,7 @@ RUN mkdir multipy/runtime/build && \ cd multipy/runtime/build && \ export CC=/usr/bin/gcc-7 && \ export CXX=/usr/bin/g++-7 && \ + export CFLAGS="-fPIC -g" && \ cmake .. && \ cmake --build . --config Release && \ cmake --install . --prefix "." From 7b58b687e757383570b487f5c3e9aa0bde5d7d71 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 12:56:40 -0700 Subject: [PATCH 11/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index e7e04125..e41b20bc 100644 --- a/Dockerfile +++ b/Dockerfile @@ -96,7 +96,7 @@ RUN pip3 install virtualenv && \ # Build/Install pytorch with post-cxx11 ABI FROM conda as build WORKDIR /opt/multipy/multipy/runtime/third-party/pytorch -COPY --from=conda /opt/conda /opt/conda +# COPY --from=conda /opt/conda /opt/conda COPY --from=submodule-update /opt/multipy /opt/multipy WORKDIR /opt/multipy From 3c12d23b6eec14d08b2fcb470463498ea9d456d7 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 13:12:08 -0700 Subject: [PATCH 12/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index e41b20bc..baf6df7f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -81,9 +81,7 @@ ARG PYTHON_VERSION=3.8 RUN pip3 install virtualenv && \ git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ ~/.pyenv/bin/pyenv install --force 3.7.10 && \ - virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 && \ - source ~/venvs/multipy_3_7_10/bin/activate && \ - pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113 + virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 # export PYENV_ROOT="~/.pyenv" && \ # export PATH="$PYENV_ROOT/bin:$PATH" # exec shell ? @@ -102,10 +100,10 @@ COPY --from=submodule-update /opt/multipy /opt/multipy WORKDIR /opt/multipy # Build Multipy -RUN mkdir multipy/runtime/build && \ +RUN source ~/venvs/multipy_3_7_10/bin/activate && \ + pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113 + mkdir multipy/runtime/build && \ cd multipy/runtime/build && \ - export CC=/usr/bin/gcc-7 && \ - export CXX=/usr/bin/g++-7 && \ export CFLAGS="-fPIC -g" && \ cmake .. && \ cmake --build . --config Release && \ From fbf0b3fb778497cfbb75c80ace01fd24a09d45d1 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 13:13:46 -0700 Subject: [PATCH 13/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index baf6df7f..833d791c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -101,7 +101,7 @@ WORKDIR /opt/multipy # Build Multipy RUN source ~/venvs/multipy_3_7_10/bin/activate && \ - pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113 + pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113 && \ mkdir multipy/runtime/build && \ cd multipy/runtime/build && \ export CFLAGS="-fPIC -g" && \ From 3187745791556cf3001f2fac5c23edb7b3791c04 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 17:59:22 -0700 Subject: [PATCH 14/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 9 ++++++++- multipy/runtime/interpreter/CMakeLists.txt | 7 +++++++ multipy/runtime/interpreter/interpreter_impl.cpp | 7 +++++++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 833d791c..cf3df866 100644 --- a/Dockerfile +++ b/Dockerfile @@ -70,6 +70,8 @@ RUN git submodule update --init --recursive --jobs 0 # Install conda + neccessary python dependencies FROM dev-base as conda ARG PYTHON_VERSION=3.8 +ARG PY_MINOR=7 +ENV PY_MINOR=${PY_MINOR} # RUN curl -fsSL -v -o ~/miniconda.sh -O https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh && \ # chmod +x ~/miniconda.sh && \ # ~/miniconda.sh -b -p /opt/conda && \ @@ -105,7 +107,12 @@ RUN source ~/venvs/multipy_3_7_10/bin/activate && \ mkdir multipy/runtime/build && \ cd multipy/runtime/build && \ export CFLAGS="-fPIC -g" && \ - cmake .. && \ + if [[ ${PYTHON_MINOR_VERSION} -lt 8 ]]; then \ + export FLAG=1; \ + else \ + export FLAG=0; \ + fi && \ + cmake .. -DLEGACY_PYTHON_PRE_3_8=${FLAG} && \ cmake --build . --config Release && \ cmake --install . --prefix "." diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index c55e9f3d..438ec316 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -13,6 +13,8 @@ include_directories(BEFORE "${PYTORCH_ROOT}/torch/include") include_directories(BEFORE "${PYTORCH_ROOT}/torch/include/torch/csrc/api/include/") SET(MULTIPY_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../../utils") +SET(LEGACY_PYTHON_PRE_3_8 0) + find_package (Python3 COMPONENTS Interpreter Development) message(STATUS "Python3_EXECUTABLE - ${Python3_EXECUTABLE}" ) @@ -32,6 +34,11 @@ link_directories(BEFORE "${Python3_SITELIB}/torch/lib") include_directories(BEFORE "${Python3_INCLUDE_DIRS}") include_directories(BEFORE ${CMAKE_SOURCE_DIR}/../..) +if (${LEGACY_PYTHON_PRE_3_8} EQUAL 1) + message(STATUS "LEGACY_PYTHON_PRE_3_8 set") + add_compile_definitions(LEGACY_PYTHON_PRE_3_8) +endif() + # add gtest dependency include(FetchContent) FetchContent_Declare( diff --git a/multipy/runtime/interpreter/interpreter_impl.cpp b/multipy/runtime/interpreter/interpreter_impl.cpp index 37011545..50fa788f 100644 --- a/multipy/runtime/interpreter/interpreter_impl.cpp +++ b/multipy/runtime/interpreter/interpreter_impl.cpp @@ -244,6 +244,8 @@ ConcreteInterpreterImplConstructorCommon( const std::vector& extra_python_paths, const std::vector& plugin_paths) { BuiltinRegistry::runPreInitialization(); + + #ifndef LEGACY_PYTHON_PRE_3_8 PyPreConfig preconfig; PyPreConfig_InitIsolatedConfig(&preconfig); PyStatus status = Py_PreInitialize(&preconfig); @@ -280,6 +282,11 @@ ConcreteInterpreterImplConstructorCommon( status = Py_InitializeFromConfig(&config); PyConfig_Clear(&config); TORCH_INTERNAL_ASSERT(!PyStatus_Exception(status)) + +#else + Py_InitializeEx(1); + TORCH_INTERNAL_ASSERT(Py_IsInitialized); +#endif #ifdef FBCODE_CAFFE2 auto sys_path = global_impl("sys", "path"); for (const auto& entry : extra_python_paths) { From 534cfbcb3ee71953a2bef41e7cdd85a10a21f11c Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 18:10:37 -0700 Subject: [PATCH 15/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 8 ++++---- multipy/runtime/interpreter/CMakeLists.txt | 7 +++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index cf3df866..445c3b92 100644 --- a/Dockerfile +++ b/Dockerfile @@ -107,12 +107,12 @@ RUN source ~/venvs/multipy_3_7_10/bin/activate && \ mkdir multipy/runtime/build && \ cd multipy/runtime/build && \ export CFLAGS="-fPIC -g" && \ - if [[ ${PYTHON_MINOR_VERSION} -lt 8 ]]; then \ - export FLAG=1; \ + if [[ ${PY_MINOR} -lt 8 ]]; then \ + cmake -DLEGACY_PYTHON_PRE_3_8=ON .. && \ else \ - export FLAG=0; \ + cmake -DLEGACY_PYTHON_PRE_3_8=OFF .. && \ fi && \ - cmake .. -DLEGACY_PYTHON_PRE_3_8=${FLAG} && \ + # cmake -DLEGACY_PYTHON_PRE_3_8=${FLAG} .. && \ cmake --build . --config Release && \ cmake --install . --prefix "." diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index 438ec316..85b30609 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -13,7 +13,8 @@ include_directories(BEFORE "${PYTORCH_ROOT}/torch/include") include_directories(BEFORE "${PYTORCH_ROOT}/torch/include/torch/csrc/api/include/") SET(MULTIPY_UTILS "${CMAKE_CURRENT_SOURCE_DIR}/../../utils") -SET(LEGACY_PYTHON_PRE_3_8 0) +#SET(LEGACY_PYTHON_PRE_3_8 0) +OPTION(LEGACY_PYTHON_PRE_3_8 "fancy description" OFF) find_package (Python3 COMPONENTS Interpreter Development) @@ -34,7 +35,7 @@ link_directories(BEFORE "${Python3_SITELIB}/torch/lib") include_directories(BEFORE "${Python3_INCLUDE_DIRS}") include_directories(BEFORE ${CMAKE_SOURCE_DIR}/../..) -if (${LEGACY_PYTHON_PRE_3_8} EQUAL 1) +if (${LEGACY_PYTHON_PRE_3_8}) message(STATUS "LEGACY_PYTHON_PRE_3_8 set") add_compile_definitions(LEGACY_PYTHON_PRE_3_8) endif() @@ -87,3 +88,5 @@ target_link_libraries(torch_deployinterpreter PRIVATE fmt::fmt-header-only) target_link_libraries(torch_deployinterpreter PRIVATE torch_python) target_link_libraries(torch_deployinterpreter PRIVATE gtest) target_link_libraries(torch_deployinterpreter PRIVATE multipy_torch) + +unset(LEGACY_PYTHON_PRE_3_8) From 3baa11bc168cbc5165cc545dd581c77804e9a28b Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 18:16:13 -0700 Subject: [PATCH 16/60] tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 445c3b92..10f8e17c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -108,9 +108,9 @@ RUN source ~/venvs/multipy_3_7_10/bin/activate && \ cd multipy/runtime/build && \ export CFLAGS="-fPIC -g" && \ if [[ ${PY_MINOR} -lt 8 ]]; then \ - cmake -DLEGACY_PYTHON_PRE_3_8=ON .. && \ + cmake -DLEGACY_PYTHON_PRE_3_8=ON ..; \ else \ - cmake -DLEGACY_PYTHON_PRE_3_8=OFF .. && \ + cmake -DLEGACY_PYTHON_PRE_3_8=OFF ..; \ fi && \ # cmake -DLEGACY_PYTHON_PRE_3_8=${FLAG} .. && \ cmake --build . --config Release && \ From e1d4b9e24ee15fe080edb62b3eb89d50539533e1 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 18:28:58 -0700 Subject: [PATCH 17/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 10f8e17c..8154b405 100644 --- a/Dockerfile +++ b/Dockerfile @@ -108,9 +108,9 @@ RUN source ~/venvs/multipy_3_7_10/bin/activate && \ cd multipy/runtime/build && \ export CFLAGS="-fPIC -g" && \ if [[ ${PY_MINOR} -lt 8 ]]; then \ - cmake -DLEGACY_PYTHON_PRE_3_8=ON ..; \ + cmake -DCMAKE_CXX_FLAGS=${CFLAGS} -DCMAKE_C_FLAGS=${CFLAGS} -DLEGACY_PYTHON_PRE_3_8=ON ..; \ else \ - cmake -DLEGACY_PYTHON_PRE_3_8=OFF ..; \ + cmake -DCMAKE_CXX_FLAGS=${CFLAGS} -DCMAKE_C_FLAGS=${CFLAGS} -DLEGACY_PYTHON_PRE_3_8=OFF ..; \ fi && \ # cmake -DLEGACY_PYTHON_PRE_3_8=${FLAG} .. && \ cmake --build . --config Release && \ From cc9f45c84da61f52b9bb2780b6202ef529db59fb Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 18:37:47 -0700 Subject: [PATCH 18/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8154b405..6159b2ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -106,11 +106,11 @@ RUN source ~/venvs/multipy_3_7_10/bin/activate && \ pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113 && \ mkdir multipy/runtime/build && \ cd multipy/runtime/build && \ - export CFLAGS="-fPIC -g" && \ + # export CFLAGS="-fPIC -g" && \ if [[ ${PY_MINOR} -lt 8 ]]; then \ - cmake -DCMAKE_CXX_FLAGS=${CFLAGS} -DCMAKE_C_FLAGS=${CFLAGS} -DLEGACY_PYTHON_PRE_3_8=ON ..; \ + cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLEGACY_PYTHON_PRE_3_8=ON ..; \ else \ - cmake -DCMAKE_CXX_FLAGS=${CFLAGS} -DCMAKE_C_FLAGS=${CFLAGS} -DLEGACY_PYTHON_PRE_3_8=OFF ..; \ + cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLEGACY_PYTHON_PRE_3_8=OFF ..; \ fi && \ # cmake -DLEGACY_PYTHON_PRE_3_8=${FLAG} .. && \ cmake --build . --config Release && \ From cd073b4500f7314ba7b3040093853537a78ab4c8 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 18:41:54 -0700 Subject: [PATCH 19/60] TSt. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 2 +- multipy/runtime/interpreter/CMakeLists.txt | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 6159b2ed..30cb8d4b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -110,7 +110,7 @@ RUN source ~/venvs/multipy_3_7_10/bin/activate && \ if [[ ${PY_MINOR} -lt 8 ]]; then \ cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLEGACY_PYTHON_PRE_3_8=ON ..; \ else \ - cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLEGACY_PYTHON_PRE_3_8=OFF ..; \ + cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON reebvugkjlkjjettvtfdfjigbnrjdbgj-DLEGACY_PYTHON_PRE_3_8=OFF ..; \ fi && \ # cmake -DLEGACY_PYTHON_PRE_3_8=${FLAG} .. && \ cmake --build . --config Release && \ diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index 85b30609..c3fd9626 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -40,6 +40,8 @@ if (${LEGACY_PYTHON_PRE_3_8}) add_compile_definitions(LEGACY_PYTHON_PRE_3_8) endif() +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + # add gtest dependency include(FetchContent) FetchContent_Declare( From 413f3f8fbfbbe09d24cdad895438d0d14b92295f Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 8 Sep 2022 23:47:34 -0700 Subject: [PATCH 20/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 2 +- multipy/runtime/interpreter/CMakeLists.txt | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 30cb8d4b..6159b2ed 100644 --- a/Dockerfile +++ b/Dockerfile @@ -110,7 +110,7 @@ RUN source ~/venvs/multipy_3_7_10/bin/activate && \ if [[ ${PY_MINOR} -lt 8 ]]; then \ cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLEGACY_PYTHON_PRE_3_8=ON ..; \ else \ - cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON reebvugkjlkjjettvtfdfjigbnrjdbgj-DLEGACY_PYTHON_PRE_3_8=OFF ..; \ + cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLEGACY_PYTHON_PRE_3_8=OFF ..; \ fi && \ # cmake -DLEGACY_PYTHON_PRE_3_8=${FLAG} .. && \ cmake --build . --config Release && \ diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index c3fd9626..7b38ef0d 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -4,6 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. +set(CMAKE_POSITION_INDEPENDENT_CODE ON) SET(INTERPRETER_DIR "${DEPLOY_DIR}/interpreter" ) SET(INTERPRETER_DIR "${DEPLOY_DIR}/interpreter" PARENT_SCOPE) @@ -40,8 +41,6 @@ if (${LEGACY_PYTHON_PRE_3_8}) add_compile_definitions(LEGACY_PYTHON_PRE_3_8) endif() -set(CMAKE_POSITION_INDEPENDENT_CODE ON) - # add gtest dependency include(FetchContent) FetchContent_Declare( From 5b90c8e7d942c5c43113ff137e7c1279ab9560f0 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 00:17:40 -0700 Subject: [PATCH 21/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/interpreter/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index 7b38ef0d..bda8213a 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -4,7 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -set(CMAKE_POSITION_INDEPENDENT_CODE ON) +# set(CMAKE_POSITION_INDEPENDENT_CODE ON) SET(INTERPRETER_DIR "${DEPLOY_DIR}/interpreter" ) SET(INTERPRETER_DIR "${DEPLOY_DIR}/interpreter" PARENT_SCOPE) @@ -70,6 +70,7 @@ set(INTERPRETER_LIB_SOURCES ${LINKER_SCRIPT} ) add_library(torch_deployinterpreter SHARED ${INTERPRETER_LIB_SOURCES} ${LINKER_SCRIPT}) +set_property(TARGET torch_deployinterpreter PROPERTY POSITION_INDEPENDENT_CODE ON) add_library(multipy_torch SHARED plugin_torch.cpp) From 5f299bade21af7505134ea9748ba66b4760d1dbe Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 01:04:21 -0700 Subject: [PATCH 22/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 3 ++- multipy/runtime/CMakeLists.txt | 8 +++++++- multipy/runtime/interpreter/builtin_registry.cpp | 15 +++++++++++++++ multipy/runtime/interpreter/interpreter_impl.cpp | 2 +- multipy/runtime/test_deploy.cpp | 2 ++ 5 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 6159b2ed..50394390 100644 --- a/Dockerfile +++ b/Dockerfile @@ -46,8 +46,9 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \ echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ + apt-add-repository ppa:ubuntu-toolchain-r/test && \ apt update && \ - apt install -y binutils cmake && \ + apt install -y binutils cmake gcc-8 && \ rm -rf /var/lib/apt/lists/* RUN /usr/sbin/update-ccache-symlinks RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache diff --git a/multipy/runtime/CMakeLists.txt b/multipy/runtime/CMakeLists.txt index c878be2a..0d196d66 100644 --- a/multipy/runtime/CMakeLists.txt +++ b/multipy/runtime/CMakeLists.txt @@ -12,6 +12,8 @@ project(MultipyRuntime) option(ABI_EQUALS_1 "Set ABI value to 1, by default it is set to 0. Pytorch by default builds with ABI set to 1." OFF) option(BUILD_CUDA_TESTS "Set to ON in order to build cuda tests. By default we do not" OFF) +OPTION(LEGACY_PYTHON_PRE_3_8 "fancy description" OFF) + if(ABI_EQUALS_1) set(ABI_VALUE 1) else() @@ -105,7 +107,11 @@ set(INTERPRETER_TEST_SOURCES_GPU LINK_DIRECTORIES("${PYTORCH_ROOT}/torch/lib") add_executable(test_deploy ${INTERPRETER_TEST_SOURCES}) -target_compile_definitions(test_deploy PUBLIC TEST_CUSTOM_LIBRARY) +# target_compile_definitions(test_deploy PUBLIC TEST_CUSTOM_LIBRARY) +if (${LEGACY_PYTHON_PRE_3_8}) + message(STATUS "LEGACY_PYTHON_PRE_3_8 set in parent cmakefile.") + target_compile_definitions(test_deploy PUBLIC LEGACY_PYTHON_PRE_3_8) +endif() target_include_directories(test_deploy PRIVATE ${PYTORCH_ROOT}/torch) target_link_libraries(test_deploy PUBLIC "-Wl,--no-as-needed -rdynamic" gtest dl torch_deploy_interface c10 torch_cpu diff --git a/multipy/runtime/interpreter/builtin_registry.cpp b/multipy/runtime/interpreter/builtin_registry.cpp index 5faa189a..2b44750d 100644 --- a/multipy/runtime/interpreter/builtin_registry.cpp +++ b/multipy/runtime/interpreter/builtin_registry.cpp @@ -63,6 +63,7 @@ void BuiltinRegistry::runPreInitialization() { appendCPythonInittab(); } +#ifndef LEGACY_PYTHON_PRE_3_8 const char* metaPathSetupTemplate = R"PYTHON( import sys from importlib.metadata import DistributionFinder, Distribution @@ -106,6 +107,20 @@ class DummyDistribution(Distribution): sys.meta_path.insert(0, F()) )PYTHON"; +#else +const char* metaPathSetupTemplate = R"PYTHON( +import sys +class F: + MODULES = set({<<>>}) + def find_spec(self, fullname, path, target=None): + if fullname in self.MODULES: + # Load this module using `BuiltinImporter`, but set `path` to None + # in order to trick it into loading our module. + return sys.meta_path[1].find_spec(fullname, path=None, target=None) + return None +sys.meta_path.insert(0, F()) +)PYTHON"; +#endif void BuiltinRegistry::runPostInitialization() { TORCH_INTERNAL_ASSERT(Py_IsInitialized()); diff --git a/multipy/runtime/interpreter/interpreter_impl.cpp b/multipy/runtime/interpreter/interpreter_impl.cpp index 50fa788f..fa6ba09f 100644 --- a/multipy/runtime/interpreter/interpreter_impl.cpp +++ b/multipy/runtime/interpreter/interpreter_impl.cpp @@ -245,7 +245,7 @@ ConcreteInterpreterImplConstructorCommon( const std::vector& plugin_paths) { BuiltinRegistry::runPreInitialization(); - #ifndef LEGACY_PYTHON_PRE_3_8 +#ifndef LEGACY_PYTHON_PRE_3_8 PyPreConfig preconfig; PyPreConfig_InitIsolatedConfig(&preconfig); PyStatus status = Py_PreInitialize(&preconfig); diff --git a/multipy/runtime/test_deploy.cpp b/multipy/runtime/test_deploy.cpp index e6a78e86..b945109d 100644 --- a/multipy/runtime/test_deploy.cpp +++ b/multipy/runtime/test_deploy.cpp @@ -458,6 +458,7 @@ result = torch.Tensor([1,2,3]) EXPECT_TRUE(w_grad0.equal(w_grad1)); } +#ifndef LEGACY_PYTHON_PRE_3_8 TEST(TorchpyTest, ImportlibMetadata) { torch::deploy::InterpreterManager m(1); m.registerModuleSource("importlib_test", R"PYTHON( @@ -469,6 +470,7 @@ result = version("torch") auto ver = I.global("importlib_test", "result").toIValue().toString(); ASSERT_EQ(ver->string(), "0.0.1+fake_multipy"); } +#endif // OSS build does not have bultin numpy support yet. Use this flag to guard the // test case. From 9c4faf2d79e5a7ff54b272dae51f1a986b213ce3 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 01:22:21 -0700 Subject: [PATCH 23/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/interpreter/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index bda8213a..cf42fda7 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -5,6 +5,8 @@ # LICENSE file in the root directory of this source tree. # set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic") SET(INTERPRETER_DIR "${DEPLOY_DIR}/interpreter" ) SET(INTERPRETER_DIR "${DEPLOY_DIR}/interpreter" PARENT_SCOPE) From 36686468a6d2bab2ab4692942897ab911b876a04 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 01:40:53 -0700 Subject: [PATCH 24/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 50394390..abaca77a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,7 +48,8 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ apt-add-repository ppa:ubuntu-toolchain-r/test && \ apt update && \ - apt install -y binutils cmake gcc-8 && \ + apt install -y binutils cmake gcc-8 g++-8 && \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 && \ rm -rf /var/lib/apt/lists/* RUN /usr/sbin/update-ccache-symlinks RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache From 5503b454bddb3eaf30f93bb1d1f079253de14f95 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 01:53:00 -0700 Subject: [PATCH 25/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index abaca77a..e786b2ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,8 +48,8 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ apt-add-repository ppa:ubuntu-toolchain-r/test && \ apt update && \ - apt install -y binutils cmake gcc-8 g++-8 && \ - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 && \ + apt install -y binutils cmake gcc-9 g++-9 && \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 && \ rm -rf /var/lib/apt/lists/* RUN /usr/sbin/update-ccache-symlinks RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache From 1e9cae5d0089a59ac15f7b535439fe8bdad8d40b Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 01:56:53 -0700 Subject: [PATCH 26/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index e786b2ea..bfdddc3c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,8 +48,8 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ apt-add-repository ppa:ubuntu-toolchain-r/test && \ apt update && \ - apt install -y binutils cmake gcc-9 g++-9 && \ - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 90 --slave /usr/bin/g++ g++ /usr/bin/g++-9 && \ + apt install -y binutils cmake gcc-8.5 g++-8.5 && \ + update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8.5 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8.5 && \ rm -rf /var/lib/apt/lists/* RUN /usr/sbin/update-ccache-symlinks RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache From 88ee09755b7759ea755592dd1ed4240b8545e22b Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 02:03:08 -0700 Subject: [PATCH 27/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index bfdddc3c..b87215aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG BASE_IMAGE=nvidia/cuda:11.3.1-devel-ubuntu18.04 +ARG BASE_IMAGE=nvidia/cuda:11.7.1-devel-ubuntu22.04 FROM ${BASE_IMAGE} as dev-base @@ -48,8 +48,9 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ apt-add-repository ppa:ubuntu-toolchain-r/test && \ apt update && \ - apt install -y binutils cmake gcc-8.5 g++-8.5 && \ - update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8.5 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8.5 && \ + apt install -y binutils cmake && \ + # apt install -y binutils cmake gcc-8 g++-8 && \ + # update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 && \ rm -rf /var/lib/apt/lists/* RUN /usr/sbin/update-ccache-symlinks RUN mkdir /opt/ccache && ccache --set-config=cache_dir=/opt/ccache From 4946be97c438c5799023d953ee7f5bda65302d9b Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 02:06:31 -0700 Subject: [PATCH 28/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index b87215aa..0954e3f3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,15 +37,15 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ libsqlite3-dev \ zlib1g-dev \ llvm \ - python-openssl \ - apt-transport-https \ - ca-certificates \ - gnupg \ + # python-openssl \ + # apt-transport-https \ + # ca-certificates \ + # gnupg \ software-properties-common \ python3-pip && \ - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ - apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \ - echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ + # wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ + # apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \ + # echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ apt-add-repository ppa:ubuntu-toolchain-r/test && \ apt update && \ apt install -y binutils cmake && \ From 0fb8cb58ff8f6568e7a8155b80bf086bade38775 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 02:17:18 -0700 Subject: [PATCH 29/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/interpreter/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index cf42fda7..9114ba24 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -61,6 +61,7 @@ add_custom_command( COMMAND "${CMAKE_OBJCOPY}" --weaken-symbol=_PyImport_FindSharedFuncptr libpython_multipy.a ) add_custom_target(libpython_multipy DEPENDS libpython_multipy.a) +set_property(TARGET libpython_multipy PROPERTY POSITION_INDEPENDENT_CODE ON) # Build the interpreter lib, designed to be standalone and dlopened # We bake the python and torch_python binding objs into libinterpreter From 7342559c803514a98368bf57da72121ed3110bb9 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 02:32:19 -0700 Subject: [PATCH 30/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 2 +- multipy/runtime/interpreter/CMakeLists.txt | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0954e3f3..fdb9b228 100644 --- a/Dockerfile +++ b/Dockerfile @@ -109,7 +109,7 @@ RUN source ~/venvs/multipy_3_7_10/bin/activate && \ pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113 && \ mkdir multipy/runtime/build && \ cd multipy/runtime/build && \ - # export CFLAGS="-fPIC -g" && \ + export CFLAGS="-fPIC" && \ if [[ ${PY_MINOR} -lt 8 ]]; then \ cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLEGACY_PYTHON_PRE_3_8=ON ..; \ else \ diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index 9114ba24..e211b397 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -5,8 +5,8 @@ # LICENSE file in the root directory of this source tree. # set(CMAKE_POSITION_INDEPENDENT_CODE ON) -set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fpic") -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpic") +# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") +# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") SET(INTERPRETER_DIR "${DEPLOY_DIR}/interpreter" ) SET(INTERPRETER_DIR "${DEPLOY_DIR}/interpreter" PARENT_SCOPE) From 16d06386c6f757a3a8c4d2a35ae1ebb686fcc62c Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 09:17:25 -0700 Subject: [PATCH 31/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 6 +++--- multipy/runtime/interpreter/CMakeLists.txt | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index fdb9b228..d8ac2f48 100644 --- a/Dockerfile +++ b/Dockerfile @@ -109,11 +109,11 @@ RUN source ~/venvs/multipy_3_7_10/bin/activate && \ pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113 && \ mkdir multipy/runtime/build && \ cd multipy/runtime/build && \ - export CFLAGS="-fPIC" && \ + # export CFLAGS="-fPIC" && \ if [[ ${PY_MINOR} -lt 8 ]]; then \ - cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLEGACY_PYTHON_PRE_3_8=ON ..; \ + cmake -DLEGACY_PYTHON_PRE_3_8=ON ..; \ else \ - cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DLEGACY_PYTHON_PRE_3_8=OFF ..; \ + cmake -DLEGACY_PYTHON_PRE_3_8=OFF ..; \ fi && \ # cmake -DLEGACY_PYTHON_PRE_3_8=${FLAG} .. && \ cmake --build . --config Release && \ diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index e211b397..ec9e09e2 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -86,6 +86,8 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") target_compile_options(torch_deployinterpreter PRIVATE -fno-gnu-unique) endif() +target_compile_options(torch_deployinterpreter PRIVATE -fpic -fpie) + target_include_directories(torch_deployinterpreter PRIVATE ${INTERPRETER_DIR}) target_include_directories(torch_deployinterpreter BEFORE PUBLIC ${Python3_INCLUDE_DIRS}) From 2b56900bb63bb32937653dfad6557d789afbd0d5 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 09:27:40 -0700 Subject: [PATCH 32/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/interpreter/CMakeLists.txt | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index ec9e09e2..855d3b4f 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -73,9 +73,10 @@ set(INTERPRETER_LIB_SOURCES ${LINKER_SCRIPT} ) add_library(torch_deployinterpreter SHARED ${INTERPRETER_LIB_SOURCES} ${LINKER_SCRIPT}) -set_property(TARGET torch_deployinterpreter PROPERTY POSITION_INDEPENDENT_CODE ON) +target_compile_options(torch_deployinterpreter PRIVATE -fpic -fpie) add_library(multipy_torch SHARED plugin_torch.cpp) +target_compile_options(multipy_torch PRIVATE -fpic -fpie) add_dependencies(torch_deployinterpreter libpython_multipy) target_link_libraries(torch_deployinterpreter PRIVATE "-Wl,--no-as-needed -rdynamic" ${CMAKE_CURRENT_BINARY_DIR}/libpython_multipy.a) @@ -96,4 +97,6 @@ target_link_libraries(torch_deployinterpreter PRIVATE torch_python) target_link_libraries(torch_deployinterpreter PRIVATE gtest) target_link_libraries(torch_deployinterpreter PRIVATE multipy_torch) +target_compile_options(torch_deployinterpreter PRIVATE -fpic -fpie) + unset(LEGACY_PYTHON_PRE_3_8) From 17ff12eab6eb305f6a675bd3e6e947847f0f080e Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 09:37:30 -0700 Subject: [PATCH 33/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/multipy/runtime/CMakeLists.txt b/multipy/runtime/CMakeLists.txt index 0d196d66..fb78167d 100644 --- a/multipy/runtime/CMakeLists.txt +++ b/multipy/runtime/CMakeLists.txt @@ -87,6 +87,7 @@ add_library(torch_deploy STATIC ${DEPLOY_DIR}/path_environment.cpp ${DEPLOY_DIR}/elf_file.cpp ) +target_compile_options(torch_deploy PRIVATE -fpic -fpie) target_link_libraries(torch_deploy PRIVATE crypt pthread dl util m z ffi lzma readline nsl ncursesw panelw) # for python builtins target_link_libraries(torch_deploy PUBLIC shm torch fmt::fmt-header-only) target_include_directories(torch_deploy PRIVATE ${CMAKE_SOURCE_DIR}/../..) From b62643f22b840677bd1b8697ec1d861da4fd4300 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 09:52:49 -0700 Subject: [PATCH 34/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/CMakeLists.txt | 2 +- multipy/runtime/interpreter/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/multipy/runtime/CMakeLists.txt b/multipy/runtime/CMakeLists.txt index fb78167d..59faf3ef 100644 --- a/multipy/runtime/CMakeLists.txt +++ b/multipy/runtime/CMakeLists.txt @@ -87,7 +87,7 @@ add_library(torch_deploy STATIC ${DEPLOY_DIR}/path_environment.cpp ${DEPLOY_DIR}/elf_file.cpp ) -target_compile_options(torch_deploy PRIVATE -fpic -fpie) +target_compile_options(torch_deploy PUBLIC -fpic -fpie) target_link_libraries(torch_deploy PRIVATE crypt pthread dl util m z ffi lzma readline nsl ncursesw panelw) # for python builtins target_link_libraries(torch_deploy PUBLIC shm torch fmt::fmt-header-only) target_include_directories(torch_deploy PRIVATE ${CMAKE_SOURCE_DIR}/../..) diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index 855d3b4f..6604c2c3 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -76,7 +76,7 @@ add_library(torch_deployinterpreter SHARED ${INTERPRETER_LIB_SOURCES} ${LINKER_S target_compile_options(torch_deployinterpreter PRIVATE -fpic -fpie) add_library(multipy_torch SHARED plugin_torch.cpp) -target_compile_options(multipy_torch PRIVATE -fpic -fpie) +target_compile_options(multipy_torch PUBLIC -fpic -fpie) add_dependencies(torch_deployinterpreter libpython_multipy) target_link_libraries(torch_deployinterpreter PRIVATE "-Wl,--no-as-needed -rdynamic" ${CMAKE_CURRENT_BINARY_DIR}/libpython_multipy.a) From 9ab470b52b3a587cfb877a10effed6e6a6ffedfe Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 10:01:16 -0700 Subject: [PATCH 35/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/interpreter/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index 6604c2c3..68857b91 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -61,7 +61,8 @@ add_custom_command( COMMAND "${CMAKE_OBJCOPY}" --weaken-symbol=_PyImport_FindSharedFuncptr libpython_multipy.a ) add_custom_target(libpython_multipy DEPENDS libpython_multipy.a) -set_property(TARGET libpython_multipy PROPERTY POSITION_INDEPENDENT_CODE ON) +target_compile_options(libpython_multipy PUBLIC -fpic -fpie) +# set_property(TARGET libpython_multipy PROPERTY POSITION_INDEPENDENT_CODE ON) # Build the interpreter lib, designed to be standalone and dlopened # We bake the python and torch_python binding objs into libinterpreter @@ -73,7 +74,7 @@ set(INTERPRETER_LIB_SOURCES ${LINKER_SCRIPT} ) add_library(torch_deployinterpreter SHARED ${INTERPRETER_LIB_SOURCES} ${LINKER_SCRIPT}) -target_compile_options(torch_deployinterpreter PRIVATE -fpic -fpie) +target_compile_options(torch_deployinterpreter PUBLIC -fpic -fpie) add_library(multipy_torch SHARED plugin_torch.cpp) target_compile_options(multipy_torch PUBLIC -fpic -fpie) @@ -87,7 +88,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") target_compile_options(torch_deployinterpreter PRIVATE -fno-gnu-unique) endif() -target_compile_options(torch_deployinterpreter PRIVATE -fpic -fpie) +target_compile_options(torch_deployinterpreter PUBLIC -fpic -fpie) target_include_directories(torch_deployinterpreter PRIVATE ${INTERPRETER_DIR}) target_include_directories(torch_deployinterpreter BEFORE PUBLIC ${Python3_INCLUDE_DIRS}) @@ -96,7 +97,6 @@ target_link_libraries(torch_deployinterpreter PRIVATE fmt::fmt-header-only) target_link_libraries(torch_deployinterpreter PRIVATE torch_python) target_link_libraries(torch_deployinterpreter PRIVATE gtest) target_link_libraries(torch_deployinterpreter PRIVATE multipy_torch) - -target_compile_options(torch_deployinterpreter PRIVATE -fpic -fpie) +target_compile_options(torch_deployinterpreter PUBLIC -fpic -fpie) unset(LEGACY_PYTHON_PRE_3_8) From 3ed48708df60b8472407ea39d6bc35795804cdc2 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 10:09:59 -0700 Subject: [PATCH 36/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/interpreter/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index 68857b91..3e6767c7 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -61,8 +61,8 @@ add_custom_command( COMMAND "${CMAKE_OBJCOPY}" --weaken-symbol=_PyImport_FindSharedFuncptr libpython_multipy.a ) add_custom_target(libpython_multipy DEPENDS libpython_multipy.a) -target_compile_options(libpython_multipy PUBLIC -fpic -fpie) -# set_property(TARGET libpython_multipy PROPERTY POSITION_INDEPENDENT_CODE ON) +#target_compile_options(libpython_multipy PUBLIC -fpic -fpie) +set_property(TARGET libpython_multipy PROPERTY POSITION_INDEPENDENT_CODE ON) # Build the interpreter lib, designed to be standalone and dlopened # We bake the python and torch_python binding objs into libinterpreter From d62689420fe74182db89fe4df2689c6b12c4ea62 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 10:17:27 -0700 Subject: [PATCH 37/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d8ac2f48..646685ef 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG BASE_IMAGE=nvidia/cuda:11.7.1-devel-ubuntu22.04 +ARG BASE_IMAGE=nvidia/cuda:11.3.1-devel-ubuntu18.04 FROM ${BASE_IMAGE} as dev-base From 4cd838f210bb5b09dff2ae635d702e5486a6ece6 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 10:24:31 -0700 Subject: [PATCH 38/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 14 +++++++------- multipy/runtime/interpreter/CMakeLists.txt | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 646685ef..f51ee1c0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -37,15 +37,15 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ libsqlite3-dev \ zlib1g-dev \ llvm \ - # python-openssl \ - # apt-transport-https \ - # ca-certificates \ - # gnupg \ + python-openssl \ + apt-transport-https \ + ca-certificates \ + gnupg \ software-properties-common \ python3-pip && \ - # wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ - # apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \ - # echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ + wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ + apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \ + echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ apt-add-repository ppa:ubuntu-toolchain-r/test && \ apt update && \ apt install -y binutils cmake && \ diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index 3e6767c7..e7ca4172 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -4,7 +4,7 @@ # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. -# set(CMAKE_POSITION_INDEPENDENT_CODE ON) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) # set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC") # set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") From 546edad8dd0f876da6cb802e82c7666b396ce071 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 10:44:40 -0700 Subject: [PATCH 39/60] Works locally. Summary: Explicit fpic fpie causes linker issues with plugin_torch; example error "/usr/bin/ld: CMakeFiles/multipy_torch.dir/plugin_torch.cpp.o: relocation R_X86_64_TPOFF32 against hidden symbol `_ZZN8pybind116handle15inc_ref_counterEmE7counter' can not be used when making a shared object". Using global "set(CMAKE_POSITION_INDEPENDENT_CODE ON)" works locally. Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/CMakeLists.txt | 4 +++- multipy/runtime/interpreter/CMakeLists.txt | 12 +++++++----- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/multipy/runtime/CMakeLists.txt b/multipy/runtime/CMakeLists.txt index 59faf3ef..32449653 100644 --- a/multipy/runtime/CMakeLists.txt +++ b/multipy/runtime/CMakeLists.txt @@ -7,6 +7,8 @@ cmake_minimum_required(VERSION 3.19) project(MultipyRuntime) +set(CMAKE_POSITION_INDEPENDENT_CODE ON) + # set ABI by default to 0 option(ABI_EQUALS_1 "Set ABI value to 1, by default it is set to 0. Pytorch by default builds with ABI set to 1." OFF) @@ -87,7 +89,7 @@ add_library(torch_deploy STATIC ${DEPLOY_DIR}/path_environment.cpp ${DEPLOY_DIR}/elf_file.cpp ) -target_compile_options(torch_deploy PUBLIC -fpic -fpie) +# target_compile_options(torch_deploy PUBLIC -fpic -fpie) target_link_libraries(torch_deploy PRIVATE crypt pthread dl util m z ffi lzma readline nsl ncursesw panelw) # for python builtins target_link_libraries(torch_deploy PUBLIC shm torch fmt::fmt-header-only) target_include_directories(torch_deploy PRIVATE ${CMAKE_SOURCE_DIR}/../..) diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index e7ca4172..d5e27bb1 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -61,7 +61,7 @@ add_custom_command( COMMAND "${CMAKE_OBJCOPY}" --weaken-symbol=_PyImport_FindSharedFuncptr libpython_multipy.a ) add_custom_target(libpython_multipy DEPENDS libpython_multipy.a) -#target_compile_options(libpython_multipy PUBLIC -fpic -fpie) +# target_compile_options(libpython_multipy PUBLIC -fpic -fpie) set_property(TARGET libpython_multipy PROPERTY POSITION_INDEPENDENT_CODE ON) # Build the interpreter lib, designed to be standalone and dlopened @@ -74,10 +74,12 @@ set(INTERPRETER_LIB_SOURCES ${LINKER_SCRIPT} ) add_library(torch_deployinterpreter SHARED ${INTERPRETER_LIB_SOURCES} ${LINKER_SCRIPT}) -target_compile_options(torch_deployinterpreter PUBLIC -fpic -fpie) +# target_compile_options(torch_deployinterpreter PUBLIC -fpic -fpie) add_library(multipy_torch SHARED plugin_torch.cpp) -target_compile_options(multipy_torch PUBLIC -fpic -fpie) +set_property(TARGET multipy_torch PROPERTY POSITION_INDEPENDENT_CODE ON) +# target_compile_options(multipy_torch PUBLIC -fpic -fpie) + add_dependencies(torch_deployinterpreter libpython_multipy) target_link_libraries(torch_deployinterpreter PRIVATE "-Wl,--no-as-needed -rdynamic" ${CMAKE_CURRENT_BINARY_DIR}/libpython_multipy.a) @@ -88,7 +90,7 @@ if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") target_compile_options(torch_deployinterpreter PRIVATE -fno-gnu-unique) endif() -target_compile_options(torch_deployinterpreter PUBLIC -fpic -fpie) +# target_compile_options(torch_deployinterpreter PUBLIC -fpic -fpie) target_include_directories(torch_deployinterpreter PRIVATE ${INTERPRETER_DIR}) target_include_directories(torch_deployinterpreter BEFORE PUBLIC ${Python3_INCLUDE_DIRS}) @@ -97,6 +99,6 @@ target_link_libraries(torch_deployinterpreter PRIVATE fmt::fmt-header-only) target_link_libraries(torch_deployinterpreter PRIVATE torch_python) target_link_libraries(torch_deployinterpreter PRIVATE gtest) target_link_libraries(torch_deployinterpreter PRIVATE multipy_torch) -target_compile_options(torch_deployinterpreter PUBLIC -fpic -fpie) +# target_compile_options(torch_deployinterpreter PUBLIC -fpic -fpie) unset(LEGACY_PYTHON_PRE_3_8) From 41de0dfc4e86cc60444ec1835b6c3ef6df27c6cf Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 11:01:31 -0700 Subject: [PATCH 40/60] Try turning off --weaken-symbol=. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/interpreter/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index d5e27bb1..422fa6ec 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -58,7 +58,8 @@ add_custom_command( OUTPUT libpython_multipy.a COMMAND cp ${Python3_STATIC_LIBRARIES} libpython_multipy.a COMMAND chmod +w libpython_multipy.a - COMMAND "${CMAKE_OBJCOPY}" --weaken-symbol=_PyImport_FindSharedFuncptr libpython_multipy.a + COMMAND "${CMAKE_OBJCOPY}" libpython_multipy.a + # COMMAND "${CMAKE_OBJCOPY}" --weaken-symbol=_PyImport_FindSharedFuncptr libpython_multipy.a ) add_custom_target(libpython_multipy DEPENDS libpython_multipy.a) # target_compile_options(libpython_multipy PUBLIC -fpic -fpie) From 6047ea000c57e3a43fdfa5356e628686068188ba Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 11:13:12 -0700 Subject: [PATCH 41/60] Add PROPERTY POSITION_INDEPENDENT_CODE ON after linking with libpython_multipy. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/interpreter/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multipy/runtime/interpreter/CMakeLists.txt b/multipy/runtime/interpreter/CMakeLists.txt index 422fa6ec..1fec61d8 100644 --- a/multipy/runtime/interpreter/CMakeLists.txt +++ b/multipy/runtime/interpreter/CMakeLists.txt @@ -58,8 +58,7 @@ add_custom_command( OUTPUT libpython_multipy.a COMMAND cp ${Python3_STATIC_LIBRARIES} libpython_multipy.a COMMAND chmod +w libpython_multipy.a - COMMAND "${CMAKE_OBJCOPY}" libpython_multipy.a - # COMMAND "${CMAKE_OBJCOPY}" --weaken-symbol=_PyImport_FindSharedFuncptr libpython_multipy.a + COMMAND "${CMAKE_OBJCOPY}" --weaken-symbol=_PyImport_FindSharedFuncptr libpython_multipy.a ) add_custom_target(libpython_multipy DEPENDS libpython_multipy.a) # target_compile_options(libpython_multipy PUBLIC -fpic -fpie) @@ -84,6 +83,7 @@ set_property(TARGET multipy_torch PROPERTY POSITION_INDEPENDENT_CODE ON) add_dependencies(torch_deployinterpreter libpython_multipy) target_link_libraries(torch_deployinterpreter PRIVATE "-Wl,--no-as-needed -rdynamic" ${CMAKE_CURRENT_BINARY_DIR}/libpython_multipy.a) +set_property(TARGET torch_deployinterpreter PROPERTY POSITION_INDEPENDENT_CODE ON) # need to ensure headers are present before any .cpp in interpreter are compiled, # but cpp themselves don't clearly depend on cpython so there is a race otherwise From 26493a4b76d28b47302a2f010a899671366fde8f Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 14:08:17 -0700 Subject: [PATCH 42/60] fpic before py install. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index f51ee1c0..86cbc27c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -85,6 +85,7 @@ ENV PY_MINOR=${PY_MINOR} # /opt/conda/bin/conda clean -ya && \ RUN pip3 install virtualenv && \ git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ + export CFLAGS="-fPIC -g" && \ ~/.pyenv/bin/pyenv install --force 3.7.10 && \ virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 # export PYENV_ROOT="~/.pyenv" && \ From 24b25df3019c4387f7d4a04e98f7544ee8e3fa81 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 14:24:38 -0700 Subject: [PATCH 43/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 86cbc27c..9b7bba1f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -118,9 +118,9 @@ RUN source ~/venvs/multipy_3_7_10/bin/activate && \ fi && \ # cmake -DLEGACY_PYTHON_PRE_3_8=${FLAG} .. && \ cmake --build . --config Release && \ - cmake --install . --prefix "." + cmake --install . --prefix "." && \ + cd multipy/runtime/example && python generate_examples.py -RUN cd multipy/runtime/example && python generate_examples.py ENV PYTHONPATH=. LIBTEST_DEPLOY_LIB=multipy/runtime/build/libtest_deploy_lib.so RUN mkdir /opt/dist && cp -r multipy/runtime/build/dist/* /opt/dist/ From ae391a585f727b73c05da66c8940d01ee00f44fa Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 14:39:17 -0700 Subject: [PATCH 44/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- .github/workflows/runtime_tests.yaml | 2 +- Dockerfile | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/.github/workflows/runtime_tests.yaml b/.github/workflows/runtime_tests.yaml index 0e2b5632..60cd891a 100644 --- a/.github/workflows/runtime_tests.yaml +++ b/.github/workflows/runtime_tests.yaml @@ -32,7 +32,7 @@ jobs: - name: Test run: | - docker run --rm multipy multipy/runtime/build/test_deploy + docker run --rm multipy bash -c "source ~/venvs/multipy/bin/activate && multipy/runtime/build/test_deploy" - name: Compat Tests run: | diff --git a/Dockerfile b/Dockerfile index 9b7bba1f..7ee88be6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -87,14 +87,14 @@ RUN pip3 install virtualenv && \ git clone https://github.com/pyenv/pyenv.git ~/.pyenv && \ export CFLAGS="-fPIC -g" && \ ~/.pyenv/bin/pyenv install --force 3.7.10 && \ - virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 + virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy # export PYENV_ROOT="~/.pyenv" && \ # export PATH="$PYENV_ROOT/bin:$PATH" # exec shell ? #ENV PATH ~/.pyenv/bin:$PATH # RUN export CFLAGS="-fPIC -g" && \ # pyenv install --force 3.7.10 && \ -# virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy_3_7_10 +# virtualenv -p ~/.pyenv/versions/3.7.10/bin/python3 ~/venvs/multipy # Build/Install pytorch with post-cxx11 ABI @@ -106,20 +106,18 @@ COPY --from=submodule-update /opt/multipy /opt/multipy WORKDIR /opt/multipy # Build Multipy -RUN source ~/venvs/multipy_3_7_10/bin/activate && \ +RUN source ~/venvs/multipy/bin/activate && \ pip3 install --pre torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/nightly/cu113 && \ mkdir multipy/runtime/build && \ cd multipy/runtime/build && \ - # export CFLAGS="-fPIC" && \ if [[ ${PY_MINOR} -lt 8 ]]; then \ cmake -DLEGACY_PYTHON_PRE_3_8=ON ..; \ else \ cmake -DLEGACY_PYTHON_PRE_3_8=OFF ..; \ fi && \ - # cmake -DLEGACY_PYTHON_PRE_3_8=${FLAG} .. && \ cmake --build . --config Release && \ cmake --install . --prefix "." && \ - cd multipy/runtime/example && python generate_examples.py + cd ../example && python generate_examples.py ENV PYTHONPATH=. LIBTEST_DEPLOY_LIB=multipy/runtime/build/libtest_deploy_lib.so From 0b6b4d6f7aa05a33f8cd6338b2b4c0f2b6b85dda Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 14:53:52 -0700 Subject: [PATCH 45/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- .github/workflows/runtime_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/runtime_tests.yaml b/.github/workflows/runtime_tests.yaml index 60cd891a..0adbeb94 100644 --- a/.github/workflows/runtime_tests.yaml +++ b/.github/workflows/runtime_tests.yaml @@ -36,4 +36,4 @@ jobs: - name: Compat Tests run: | - docker run --rm multipy bash -c "pip install -r compat-requirements.txt && multipy/runtime/build/interactive_embedded_interpreter --pyscript multipy/runtime/test_compat.py" + docker run --rm multipy bash -c "pip3 install -r compat-requirements.txt && multipy/runtime/build/interactive_embedded_interpreter --pyscript multipy/runtime/test_compat.py" From 4b5348aeaf5e5b92c11fccff90909cc0df504d62 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 15:09:27 -0700 Subject: [PATCH 46/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- .github/workflows/runtime_tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/runtime_tests.yaml b/.github/workflows/runtime_tests.yaml index 0adbeb94..e3031e20 100644 --- a/.github/workflows/runtime_tests.yaml +++ b/.github/workflows/runtime_tests.yaml @@ -32,8 +32,8 @@ jobs: - name: Test run: | - docker run --rm multipy bash -c "source ~/venvs/multipy/bin/activate && multipy/runtime/build/test_deploy" + docker run --rm multipy bash -c "source ~/venvs/multipy/bin/activate && multipy/runtime/build/test_deploy && deactivate" - name: Compat Tests run: | - docker run --rm multipy bash -c "pip3 install -r compat-requirements.txt && multipy/runtime/build/interactive_embedded_interpreter --pyscript multipy/runtime/test_compat.py" + docker run --rm multipy bash -c "pip install -r compat-requirements.txt && multipy/runtime/build/interactive_embedded_interpreter --pyscript multipy/runtime/test_compat.py" From 5438f349b6b43cfc5da4b62e993fc3471a6f9650 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 15:28:20 -0700 Subject: [PATCH 47/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- .github/workflows/runtime_tests.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/runtime_tests.yaml b/.github/workflows/runtime_tests.yaml index e3031e20..0e2b5632 100644 --- a/.github/workflows/runtime_tests.yaml +++ b/.github/workflows/runtime_tests.yaml @@ -32,7 +32,7 @@ jobs: - name: Test run: | - docker run --rm multipy bash -c "source ~/venvs/multipy/bin/activate && multipy/runtime/build/test_deploy && deactivate" + docker run --rm multipy multipy/runtime/build/test_deploy - name: Compat Tests run: | From 8d44126544f5db99e949ddf80bb3ee9c6782591a Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 15:41:25 -0700 Subject: [PATCH 48/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- .github/workflows/runtime_tests.yaml | 4 ++-- Dockerfile | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/runtime_tests.yaml b/.github/workflows/runtime_tests.yaml index 0e2b5632..33c3f1cd 100644 --- a/.github/workflows/runtime_tests.yaml +++ b/.github/workflows/runtime_tests.yaml @@ -32,8 +32,8 @@ jobs: - name: Test run: | - docker run --rm multipy multipy/runtime/build/test_deploy + docker run --rm multipy bash -c "source ~/venvs/multipy/bin/activate && multipy/runtime/build/test_deploy && deactivate" - name: Compat Tests run: | - docker run --rm multipy bash -c "pip install -r compat-requirements.txt && multipy/runtime/build/interactive_embedded_interpreter --pyscript multipy/runtime/test_compat.py" + docker run --rm multipy bash -c "source ~/venvs/multipy/bin/activate && pip install -r compat-requirements.txt && multipy/runtime/build/interactive_embedded_interpreter --pyscript multipy/runtime/test_compat.py && deactivate" diff --git a/Dockerfile b/Dockerfile index 7ee88be6..91975420 100644 --- a/Dockerfile +++ b/Dockerfile @@ -42,6 +42,7 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ ca-certificates \ gnupg \ software-properties-common \ + python-pip \ python3-pip && \ wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \ From c23522369483641e95cff86236c55031e1f40b5a Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Fri, 9 Sep 2022 16:32:37 -0700 Subject: [PATCH 49/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- .github/workflows/runtime_tests.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/runtime_tests.yaml b/.github/workflows/runtime_tests.yaml index 33c3f1cd..e59e08fe 100644 --- a/.github/workflows/runtime_tests.yaml +++ b/.github/workflows/runtime_tests.yaml @@ -11,6 +11,7 @@ jobs: strategy: matrix: python-version: [3.8, 3.9, '3.10'] + py-minor: [7] platform: [ubuntu-18.04] fail-fast: false runs-on: ${{ matrix.platform }} @@ -32,8 +33,8 @@ jobs: - name: Test run: | - docker run --rm multipy bash -c "source ~/venvs/multipy/bin/activate && multipy/runtime/build/test_deploy && deactivate" + docker run --rm multipy bash -c "if [[ ${{ matrix.py-minor }} -lt 8 ]]; then source ~/venvs/multipy/bin/activate; fi && multipy/runtime/build/test_deploy" - name: Compat Tests run: | - docker run --rm multipy bash -c "source ~/venvs/multipy/bin/activate && pip install -r compat-requirements.txt && multipy/runtime/build/interactive_embedded_interpreter --pyscript multipy/runtime/test_compat.py && deactivate" + docker run --rm multipy bash -c "if [[ ${{ matrix.py-minor }} -lt 8 ]]; then source ~/venvs/multipy/bin/activate; fi && pip install -r compat-requirements.txt && multipy/runtime/build/interactive_embedded_interpreter --pyscript multipy/runtime/test_compat.py" From 8436b3e87b789ee2c9b1f5980d7a138839f1b4c1 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Mon, 12 Sep 2022 15:50:56 -0700 Subject: [PATCH 50/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- compat-requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compat-requirements.txt b/compat-requirements.txt index 53e33707..b0cf1f6d 100644 --- a/compat-requirements.txt +++ b/compat-requirements.txt @@ -3,4 +3,4 @@ torchaudio torchvision git+https://github.com/facebookresearch/pytorch3d.git git+https://github.com/pytorch/torchdynamo.git -git+https://github.com/pytorch/pytorch.git#subdirectory=functorch +git+https://github.com/pytorch/functorch.git From 3c9c4f413efe28af4efff0883f53b6639231ab94 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Wed, 14 Sep 2022 10:32:01 -0700 Subject: [PATCH 51/60] Tst compat-req spec functorch commit. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- compat-requirements.txt | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/compat-requirements.txt b/compat-requirements.txt index b0cf1f6d..c7b872f3 100644 --- a/compat-requirements.txt +++ b/compat-requirements.txt @@ -1,6 +1,2 @@ -tokenizers -torchaudio -torchvision -git+https://github.com/facebookresearch/pytorch3d.git +git+https://github.com/pytorch/functorch.git@074592e307519a6cc49f7ebef6706a1a481f7d7a git+https://github.com/pytorch/torchdynamo.git -git+https://github.com/pytorch/functorch.git From c5235a43ffe91e1c77f092092f0eabd53438b629 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Wed, 14 Sep 2022 10:49:31 -0700 Subject: [PATCH 52/60] Tst commit from aug 30. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- compat-requirements.txt | 2 +- multipy/runtime/test_compat.py | 16 ++++++++-------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/compat-requirements.txt b/compat-requirements.txt index c7b872f3..ea4a1a40 100644 --- a/compat-requirements.txt +++ b/compat-requirements.txt @@ -1,2 +1,2 @@ -git+https://github.com/pytorch/functorch.git@074592e307519a6cc49f7ebef6706a1a481f7d7a +git+https://github.com/pytorch/functorch.git@7a4f00945706293d6ea997e832a5c32139ea552e git+https://github.com/pytorch/torchdynamo.git diff --git a/multipy/runtime/test_compat.py b/multipy/runtime/test_compat.py index 4120c3b7..d7e1ca25 100644 --- a/multipy/runtime/test_compat.py +++ b/multipy/runtime/test_compat.py @@ -10,17 +10,17 @@ class TestCompat(unittest.TestCase): - def test_torchvision(self): - import torchvision # noqa: F401 + # def test_torchvision(self): + # import torchvision # noqa: F401 - def test_torchaudio(self): - import torchaudio # noqa: F401 + # def test_torchaudio(self): + # import torchaudio # noqa: F401 - def test_pytorch3d(self): - import pytorch3d # noqa: F401 + # def test_pytorch3d(self): + # import pytorch3d # noqa: F401 - def test_hf_tokenizers(self): - import tokenizers # noqa: F401 + # def test_hf_tokenizers(self): + # import tokenizers # noqa: F401 def test_torchdynamo_eager(self): import torchdynamo From a801e2a5ae53552df0d55b3ebd6dc4889e320810 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Wed, 14 Sep 2022 12:22:44 -0700 Subject: [PATCH 53/60] Tst compats. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- compat-requirements.txt | 5 ++-- multipy/runtime/test_compat.py | 50 +++++++++++++++++----------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/compat-requirements.txt b/compat-requirements.txt index ea4a1a40..6236105e 100644 --- a/compat-requirements.txt +++ b/compat-requirements.txt @@ -1,2 +1,3 @@ -git+https://github.com/pytorch/functorch.git@7a4f00945706293d6ea997e832a5c32139ea552e -git+https://github.com/pytorch/torchdynamo.git +torchaudio +torchvision +git+https://github.com/facebookresearch/pytorch3d.git diff --git a/multipy/runtime/test_compat.py b/multipy/runtime/test_compat.py index d7e1ca25..782312fd 100644 --- a/multipy/runtime/test_compat.py +++ b/multipy/runtime/test_compat.py @@ -10,41 +10,41 @@ class TestCompat(unittest.TestCase): - # def test_torchvision(self): - # import torchvision # noqa: F401 + def test_torchvision(self): + import torchvision # noqa: F401 - # def test_torchaudio(self): - # import torchaudio # noqa: F401 + def test_torchaudio(self): + import torchaudio # noqa: F401 - # def test_pytorch3d(self): - # import pytorch3d # noqa: F401 + def test_pytorch3d(self): + import pytorch3d # noqa: F401 - # def test_hf_tokenizers(self): - # import tokenizers # noqa: F401 + def test_hf_tokenizers(self): + import tokenizers # noqa: F401 - def test_torchdynamo_eager(self): - import torchdynamo + # def test_torchdynamo_eager(self): + # import torchdynamo - @torchdynamo.optimize("eager") - def fn(x, y): - a = torch.cos(x) - b = torch.sin(y) - return a + b + # @torchdynamo.optimize("eager") + # def fn(x, y): + # a = torch.cos(x) + # b = torch.sin(y) + # return a + b - fn(torch.randn(10), torch.randn(10)) + # fn(torch.randn(10), torch.randn(10)) - def test_torchdynamo_ofi(self): - import torchdynamo + # def test_torchdynamo_ofi(self): + # import torchdynamo - torchdynamo.reset() + # torchdynamo.reset() - @torchdynamo.optimize("ofi") - def fn(x, y): - a = torch.cos(x) - b = torch.sin(y) - return a + b + # @torchdynamo.optimize("ofi") + # def fn(x, y): + # a = torch.cos(x) + # b = torch.sin(y) + # return a + b - fn(torch.randn(10), torch.randn(10)) + # fn(torch.randn(10), torch.randn(10)) if __name__ == "__main__": From 69abf98d85c952555406b95ae34592aa792ca15e Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Wed, 14 Sep 2022 13:00:17 -0700 Subject: [PATCH 54/60] tst compat vision only. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- compat-requirements.txt | 3 +++ multipy/runtime/test_compat.py | 46 +++++++++++++++++----------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/compat-requirements.txt b/compat-requirements.txt index 6236105e..53e33707 100644 --- a/compat-requirements.txt +++ b/compat-requirements.txt @@ -1,3 +1,6 @@ +tokenizers torchaudio torchvision git+https://github.com/facebookresearch/pytorch3d.git +git+https://github.com/pytorch/torchdynamo.git +git+https://github.com/pytorch/pytorch.git#subdirectory=functorch diff --git a/multipy/runtime/test_compat.py b/multipy/runtime/test_compat.py index 782312fd..50e70083 100644 --- a/multipy/runtime/test_compat.py +++ b/multipy/runtime/test_compat.py @@ -13,38 +13,38 @@ class TestCompat(unittest.TestCase): def test_torchvision(self): import torchvision # noqa: F401 - def test_torchaudio(self): - import torchaudio # noqa: F401 + # def test_torchaudio(self): + # import torchaudio # noqa: F401 - def test_pytorch3d(self): - import pytorch3d # noqa: F401 + # def test_pytorch3d(self): + # import pytorch3d # noqa: F401 - def test_hf_tokenizers(self): - import tokenizers # noqa: F401 + # def test_hf_tokenizers(self): + # import tokenizers # noqa: F401 - # def test_torchdynamo_eager(self): - # import torchdynamo + def test_torchdynamo_eager(self): + import torchdynamo - # @torchdynamo.optimize("eager") - # def fn(x, y): - # a = torch.cos(x) - # b = torch.sin(y) - # return a + b + @torchdynamo.optimize("eager") + def fn(x, y): + a = torch.cos(x) + b = torch.sin(y) + return a + b - # fn(torch.randn(10), torch.randn(10)) + fn(torch.randn(10), torch.randn(10)) - # def test_torchdynamo_ofi(self): - # import torchdynamo + def test_torchdynamo_ofi(self): + import torchdynamo - # torchdynamo.reset() + torchdynamo.reset() - # @torchdynamo.optimize("ofi") - # def fn(x, y): - # a = torch.cos(x) - # b = torch.sin(y) - # return a + b + @torchdynamo.optimize("ofi") + def fn(x, y): + a = torch.cos(x) + b = torch.sin(y) + return a + b - # fn(torch.randn(10), torch.randn(10)) + fn(torch.randn(10), torch.randn(10)) if __name__ == "__main__": From f5e1d5f4227d2f7d93d5c0ae3a910fb4043138a8 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Wed, 14 Sep 2022 13:00:42 -0700 Subject: [PATCH 55/60] Tst audio only. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/test_compat.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/multipy/runtime/test_compat.py b/multipy/runtime/test_compat.py index 50e70083..cec7eafd 100644 --- a/multipy/runtime/test_compat.py +++ b/multipy/runtime/test_compat.py @@ -10,11 +10,11 @@ class TestCompat(unittest.TestCase): - def test_torchvision(self): - import torchvision # noqa: F401 + # def test_torchvision(self): + # import torchvision # noqa: F401 - # def test_torchaudio(self): - # import torchaudio # noqa: F401 + def test_torchaudio(self): + import torchaudio # noqa: F401 # def test_pytorch3d(self): # import pytorch3d # noqa: F401 From 49721042bd1e1160c954590927f31306ec1f5983 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Wed, 14 Sep 2022 13:01:05 -0700 Subject: [PATCH 56/60] Tst pt3d only. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/test_compat.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/multipy/runtime/test_compat.py b/multipy/runtime/test_compat.py index cec7eafd..fc29b12d 100644 --- a/multipy/runtime/test_compat.py +++ b/multipy/runtime/test_compat.py @@ -13,11 +13,11 @@ class TestCompat(unittest.TestCase): # def test_torchvision(self): # import torchvision # noqa: F401 - def test_torchaudio(self): - import torchaudio # noqa: F401 + # def test_torchaudio(self): + # import torchaudio # noqa: F401 - # def test_pytorch3d(self): - # import pytorch3d # noqa: F401 + def test_pytorch3d(self): + import pytorch3d # noqa: F401 # def test_hf_tokenizers(self): # import tokenizers # noqa: F401 From 9af1263815b959cbd13910c05279c9c9ea10390e Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Wed, 14 Sep 2022 13:01:27 -0700 Subject: [PATCH 57/60] tst tokenz only. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- multipy/runtime/test_compat.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/multipy/runtime/test_compat.py b/multipy/runtime/test_compat.py index fc29b12d..5618c30d 100644 --- a/multipy/runtime/test_compat.py +++ b/multipy/runtime/test_compat.py @@ -16,11 +16,11 @@ class TestCompat(unittest.TestCase): # def test_torchaudio(self): # import torchaudio # noqa: F401 - def test_pytorch3d(self): - import pytorch3d # noqa: F401 + # def test_pytorch3d(self): + # import pytorch3d # noqa: F401 - # def test_hf_tokenizers(self): - # import tokenizers # noqa: F401 + def test_hf_tokenizers(self): + import tokenizers # noqa: F401 def test_torchdynamo_eager(self): import torchdynamo From 9f30cff6cbe6bab735a630480336a77daf1e8f64 Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Thu, 15 Sep 2022 14:08:27 -0700 Subject: [PATCH 58/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- .github/workflows/runtime_tests.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.github/workflows/runtime_tests.yaml b/.github/workflows/runtime_tests.yaml index e59e08fe..3201350f 100644 --- a/.github/workflows/runtime_tests.yaml +++ b/.github/workflows/runtime_tests.yaml @@ -11,6 +11,7 @@ jobs: strategy: matrix: python-version: [3.8, 3.9, '3.10'] + py-major: [3] py-minor: [7] platform: [ubuntu-18.04] fail-fast: false @@ -31,6 +32,14 @@ jobs: DOCKER_BUILDKIT: 1 run: docker build -t multipy --progress=plain --build-arg PYTHON_VERSION=${{ matrix.python-version }} . + - name: Set Python Version + run: | + echo "ppython-version=${{ matrix.py-major }}.${{ matrix.py-minor }}" >> $GITHUB_ENV + + - name: Print Python version + run: | + echo "ppython version = ${{ env.ppython-version }}" + - name: Test run: | docker run --rm multipy bash -c "if [[ ${{ matrix.py-minor }} -lt 8 ]]; then source ~/venvs/multipy/bin/activate; fi && multipy/runtime/build/test_deploy" From 4254c246342df426dfc9238359d843784485bbbf Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Wed, 28 Sep 2022 11:23:11 -0700 Subject: [PATCH 59/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index c10809a7..eaa16e14 100644 --- a/Dockerfile +++ b/Dockerfile @@ -44,12 +44,13 @@ RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ software-properties-common \ python-pip \ python3-pip && \ - wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ - apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \ - echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ - apt-add-repository ppa:ubuntu-toolchain-r/test && \ + # wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | apt-key add - && \ + # apt-add-repository 'deb https://apt.kitware.com/ubuntu/ bionic main' && \ + # echo "deb http://security.ubuntu.com/ubuntu focal-security main" >> /etc/apt/sources.list && \ + # apt-add-repository ppa:ubuntu-toolchain-r/test && \ apt update && \ - apt install -y binutils cmake && \ + apt install -y binutils && \ + # cmake && \ # apt install -y binutils cmake gcc-8 g++-8 && \ # update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-8 80 --slave /usr/bin/g++ g++ /usr/bin/g++-8 && \ rm -rf /var/lib/apt/lists/* From d98354708b90fcea6e7eaafee708014bfd096c5c Mon Sep 17 00:00:00 2001 From: Anirban Roychowdhury Date: Wed, 28 Sep 2022 11:34:47 -0700 Subject: [PATCH 60/60] Tst. Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index eaa16e14..0d3eb722 100644 --- a/Dockerfile +++ b/Dockerfile @@ -8,6 +8,7 @@ SHELL ["/bin/bash", "-c"] RUN --mount=type=cache,id=apt-dev,target=/var/cache/apt \ apt update && DEBIAN_FRONTEND=noninteractive apt install -yq --no-install-recommends \ build-essential \ + cmake \ ca-certificates \ ccache \ curl \