This is an automated email from the ASF dual-hosted git repository.

areusch pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git


The following commit(s) were added to refs/heads/main by this push:
     new 4c47676  [CI][Caffe Frontend] Change the caffe deps into SSD 
distribution (#9060)
4c47676 is described below

commit 4c47676d1caa1fca0a2a791d7f43c156aa402cf6
Author: Masahiro Hiramori <[email protected]>
AuthorDate: Tue Jan 4 08:19:33 2022 +0900

    [CI][Caffe Frontend] Change the caffe deps into SSD distribution (#9060)
    
    * Change the caffe deps into SSD distribution
    
    * update make flag
    
    * remove `rm -rf /var/lib/apt/lists/*`
    
    * install all python packages in one pip command
    
    * install latest package version
    
    * add caffe-frontend dependencies
---
 docker/install/ubuntu_install_caffe.sh | 39 +++++++++++++++++++++++++++-------
 python/gen_requirements.py             | 15 +++++++++++++
 2 files changed, 46 insertions(+), 8 deletions(-)

diff --git a/docker/install/ubuntu_install_caffe.sh 
b/docker/install/ubuntu_install_caffe.sh
index 21f7d09..b26f339 100644
--- a/docker/install/ubuntu_install_caffe.sh
+++ b/docker/install/ubuntu_install_caffe.sh
@@ -22,13 +22,36 @@ set -o pipefail
 
 apt-get update --fix-missing
 
-# The precompiled caffe dependents on tzdata.
-# While installing tzdata in docker, we need set the time zone manually,
-# which will cause the container to hang during installation.
-# So in order to avoid manually selecting the time zone, set as following:
-export DEBIAN_FRONTEND=noninteractive
-apt-get install -y tzdata
+# Install dependencies
+apt-get install -y --no-install-recommends libboost-filesystem-dev 
libboost-python-dev \
+    libboost-system-dev libboost-thread-dev libboost-regex-dev 
protobuf-compiler \
+    libprotobuf-dev libhdf5-serial-dev libopenblas-dev libgflags-dev 
libgoogle-glog-dev
 
-apt-get install caffe-cpu -y
+# install python packages
+pip install "numpy" "protobuf" "scikit-image" "six"
 
-pip3 install --upgrade scikit-image
+# Build the Caffe and the python wrapper
+echo "Downloading Caffe"
+CAFFE_HOME="/opt/caffe"
+git clone --branch=ssd --depth 1 https://github.com/weiliu89/caffe /caffe_src
+cd /caffe_src
+
+echo "Building Caffe"
+mkdir /caffe_src/build && cd /caffe_src/build
+cmake .. -DCMAKE_INSTALL_PREFIX=${CAFFE_HOME} -DCMAKE_BUILD_TYPE=Release 
-DCPU_ONLY=1 \
+    -Dpython_version=3 -DUSE_OPENCV=OFF -DUSE_LEVELDB=OFF -DUSE_LMDB=OFF 
-DBUILD_docs=OFF -DBLAS=open
+make all -j$(expr $(nproc) - 1)
+make pycaffe -j$(expr $(nproc) - 1)
+make test -j$(expr $(nproc) - 1)
+make runtest -j$(expr $(nproc) - 1)
+make pytest -j$(expr $(nproc) - 1)
+
+echo "Installing Caffe to /opt/caffe"
+make install
+
+echo "Removing build directory"
+cd / && rm -rf /caffe_src
+
+PYCAFFE_ROOT=${CAFFE_HOME}/python
+echo "${CAFFE_HOME}/lib" >> /etc/ld.so.conf.d/caffe.conf && ldconfig
+ln -s ${PYCAFFE_ROOT}/caffe /usr/local/lib/python3.6/dist-packages/caffe
diff --git a/python/gen_requirements.py b/python/gen_requirements.py
index bcd8ccd..6cb9292 100755
--- a/python/gen_requirements.py
+++ b/python/gen_requirements.py
@@ -87,6 +87,18 @@ REQUIREMENTS_BY_PIECE: RequirementsByPieceType = [
     ),
     # Relay frontends.
     (
+        "importer-caffe",
+        (
+            "Requirements for the Caffe importer",
+            [
+                "numpy",
+                "protobuf",
+                "scikit-image",
+                "six",
+            ],
+        ),
+    ),
+    (
         "importer-caffe2",
         (
             "Requirements for the Caffe2 importer",
@@ -248,9 +260,12 @@ CONSTRAINTS = [
     ("paddlepaddle", None),
     ("pillow", None),
     ("progressbar", None),
+    ("protobuf", None),
     ("psutil", None),
     ("pylint", None),
+    ("scikit-image", None),
     ("scipy", None),
+    ("six", None),
     ("sphinx", None),
     ("sphinx_autodoc_annotation", None),
     ("sphinx_gallery", None),

Reply via email to