* Update install dependencies

* Build protobuf from source for Ubuntu 16.04 and Ubuntu 18.04

* Add Ubuntu 20.04 capability

* And numpy dependency

* Add Ubuntu 16.04 and 20.04 dockerfile
This commit is contained in:
siahuat0727 2021-10-27 16:19:27 +08:00 коммит произвёл GitHub
Родитель d63c86c40b
Коммит d9a0dfdb89
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 77 добавлений и 55 удалений

Просмотреть файл

@ -0,0 +1,12 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
FROM ubuntu:16.04
RUN apt update && apt install -y git
RUN git clone https://github.com/microsoft/nnfusion.git /root/nnfusion --branch master --single-branch
# - Install Requirements
RUN bash /root/nnfusion/maint/script/install_dependency.sh
# - Make Install
RUN cd /root/nnfusion/ && mkdir build && cd build && cmake .. && make -j6 && make install
# - Execute command
RUN LD_LIBRARY_PATH=/usr/local/lib nnfusion /root/nnfusion/test/models/tensorflow/frozen_op_graph/frozen_abs_graph.pb

Просмотреть файл

@ -4,11 +4,9 @@
FROM ubuntu:18.04
RUN apt update && apt install -y git
RUN git clone https://github.com/microsoft/nnfusion.git /root/nnfusion --branch master --single-branch
# - Install Requirements
# - Install Requirements
RUN bash /root/nnfusion/maint/script/install_dependency.sh
# - Make Install
RUN cd /root/nnfusion/ && mkdir build && cd build && cmake .. && make -j6 && make install
# - Execute command
RUN LD_LIBRARY_PATH=/usr/local/lib nnfusion /root/nnfusion/test/models/tensorflow/frozen_op_graph/frozen_abs_graph.pb
RUN apt install -y python3 python3-pip
RUN pip3 install numpy

Просмотреть файл

@ -0,0 +1,12 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
FROM ubuntu:20.04
RUN apt update && apt install -y git
RUN git clone https://github.com/microsoft/nnfusion.git /root/nnfusion --branch master --single-branch
# - Install Requirements (set noninteractive to skip time zone setting for tzdata)
RUN DEBIAN_FRONTEND="noninteractive" bash /root/nnfusion/maint/script/install_dependency.sh
# - Make Install
RUN cd /root/nnfusion/ && mkdir build && cd build && cmake .. && make -j6 && make install
# - Execute command
RUN LD_LIBRARY_PATH=/usr/local/lib nnfusion /root/nnfusion/test/models/tensorflow/frozen_op_graph/frozen_abs_graph.pb

Просмотреть файл

@ -4,73 +4,73 @@
# Licensed under the MIT License.
echo "Running NNFusion install_dependency.sh"
DEB_PACKAGES="build-essential cmake clang-3.9 clang-format-3.9 git curl zlib1g zlib1g-dev libtinfo-dev unzip \
autoconf automake libtool ca-certificates gdb sqlite3 libsqlite3-dev libcurl4-openssl-dev libprotobuf-dev \
protobuf-compiler libgflags-dev libgtest-dev"
if [[ "$(whoami)" != "root" ]]; then
SUDO=sudo
fi
DEB_PACKAGES="build-essential cmake git curl zlib1g zlib1g-dev libtinfo-dev unzip \
autoconf automake libtool ca-certificates gdb sqlite3 libsqlite3-dev libcurl4-openssl-dev \
libprotobuf-dev protobuf-compiler libgflags-dev libgtest-dev"
ubuntu_codename=$(. /etc/os-release;echo $UBUNTU_CODENAME)
if [[ $ubuntu_codename != "focal" ]]; then
DEB_PACKAGES="${DEB_PACKAGES} clang-3.9 clang-format-3.9"
fi
if [[ "$(whoami)" != "root" ]]; then
SUDO=sudo
fi
if ! dpkg -L $DEB_PACKAGES >/dev/null 2>&1; then
#Thirdparty deb for ubuntu 18.04(bionic)
$SUDO sh -c "apt update && apt install -y --no-install-recommends software-properties-common apt-transport-https ca-certificates gnupg wget"
$SUDO sh -c "wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null"
$SUDO sh -c "apt-add-repository 'deb https://apt.kitware.com/ubuntu/ $ubuntu_codename main'"
$SUDO sh -c "add-apt-repository ppa:maarten-fonville/protobuf -y"
$SUDO sh -c "wget -O - https://apt.kitware.com/keys/kitware-archive-latest.asc 2>/dev/null | gpg --dearmor - | tee /etc/apt/trusted.gpg.d/kitware.gpg >/dev/null"
$SUDO sh -c "apt-add-repository 'deb https://apt.kitware.com/ubuntu/ $ubuntu_codename main'"
$SUDO sh -c "apt update && apt install -y --no-install-recommends $DEB_PACKAGES"
if [[ $ubuntu_codename != "focal" ]]; then
# Install protobuf 3.6.1 from source
$SUDO sh -c "wget https://github.com/protocolbuffers/protobuf/releases/download/v3.6.1/protobuf-cpp-3.6.1.tar.gz -P /tmp"
$SUDO sh -c "cd /tmp && tar -xf /tmp/protobuf-cpp-3.6.1.tar.gz && rm /tmp/protobuf-cpp-3.6.1.tar.gz"
$SUDO sh -c "cd /tmp/protobuf-3.6.1/ && ./configure && make && make check && make install && ldconfig && rm -rf /tmp/protobuf-3.6.1/"
fi
fi
if [[ $ubuntu_codename == "focal" ]]; then
# Install clang-format-3.9
$SUDO sh -c "cd /tmp && wget https://releases.llvm.org/3.9.0/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz && tar -xf clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz"
$SUDO sh -c "cp /tmp/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-format /usr/bin/clang-format-3.9 && ln -s /usr/bin/clang-format-3.9 /usr/bin/clang-format"
$SUDO sh -c "rm -rf /tmp/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04/bin/clang-format /tmp/clang+llvm-3.9.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz"
fi
echo "- Dependencies are installed in system."
#Install latest CMake
# if Ubuntu 16.04, we have some dev node using ubuntu 16.04
if [[ $ubuntu_codename == "xenial" ]]; then
echo "- Ubuntu 16.04 detected. Download & install latest protobuf & gtest debs."
if [ ! -f "/usr/lib/libgtest.a" ]; then
# Install protobuf & gtest from bionic version
$SUDO sh -c " \
wget https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf/+files/libprotobuf17_3.6.1-1~maarten0+bionic_amd64.deb -P /tmp && \
wget https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf/+files/libprotoc17_3.6.1-1~maarten0+bionic_amd64.deb -P /tmp && \
wget https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf/+files/libprotoc-dev_3.6.1-1~maarten0+bionic_amd64.deb -P /tmp && \
wget https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf/+files/libprotobuf-lite17_3.6.1-1~maarten0+bionic_amd64.deb -P /tmp && \
wget https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf/+files/libprotobuf-dev_3.6.1-1~maarten0+bionic_amd64.deb -P /tmp && \
wget https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf/+files/protobuf-compiler_3.6.1-1~maarten0+bionic_amd64.deb -P /tmp && \
wget https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf/+files/googletest_1.9.0.20190831-2~202001251824~ubuntu18.04.1_all.deb -P /tmp && \
wget https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf/+files/libgtest-dev_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb -P /tmp && \
wget https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf/+files/google-mock_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb -P /tmp &&\
wget https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf/+files/googletest-tools_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb -P /tmp &&\
wget https://launchpad.net/~maarten-fonville/+archive/ubuntu/protobuf/+files/libgmock-dev_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb -P /tmp\
"
# if Ubuntu 16.04, we have some dev node using ubuntu 16.04
if [[ $ubuntu_codename == "xenial" ]]; then
$SUDO sh -c "mkdir /usr/src/googletest && ln -s /usr/src/gtest /usr/src/googletest/googletest"
fi
$SUDO sh -c "dpkg -i /tmp/libprotobuf17_3.6.1-1~maarten0+bionic_amd64.deb /tmp/libprotoc17_3.6.1-1~maarten0+bionic_amd64.deb \
/tmp/libprotoc-dev_3.6.1-1~maarten0+bionic_amd64.deb /tmp/googletest_1.9.0.20190831-2~202001251824~ubuntu18.04.1_all.deb \
/tmp/libprotobuf-lite17_3.6.1-1~maarten0+bionic_amd64.deb /tmp/libprotobuf-dev_3.6.1-1~maarten0+bionic_amd64.deb \
/tmp/protobuf-compiler_3.6.1-1~maarten0+bionic_amd64.deb /tmp/libgtest-dev_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb \
/tmp/google-mock_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb /tmp/googletest-tools_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb \
/tmp/libgmock-dev_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb"
# Compile gtest
$SUDO sh -c "cd /usr/src/googletest/googletest/ && mkdir -p build && cd build && cmake .. -DCMAKE_CXX_FLAGS=\"-std=c++11\" && make -j"
$SUDO sh -c "rm /tmp/libprotobuf17_3.6.1-1~maarten0+bionic_amd64.deb /tmp/libprotoc17_3.6.1-1~maarten0+bionic_amd64.deb \
/tmp/libprotoc-dev_3.6.1-1~maarten0+bionic_amd64.deb /tmp/googletest_1.9.0.20190831-2~202001251824~ubuntu18.04.1_all.deb \
/tmp/libprotobuf-lite17_3.6.1-1~maarten0+bionic_amd64.deb /tmp/libprotobuf-dev_3.6.1-1~maarten0+bionic_amd64.deb \
/tmp/protobuf-compiler_3.6.1-1~maarten0+bionic_amd64.deb /tmp/libgtest-dev_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb \
/tmp/google-mock_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb /tmp/googletest-tools_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb \
/tmp/libgmock-dev_1.9.0.20190831-2~202001251824~ubuntu18.04.1_amd64.deb"
if [[ $ubuntu_codename == "focal" ]]; then
$SUDO sh -c "cp /usr/src/googletest/googletest/build/lib/libgtest*.a /usr/lib/"
else
$SUDO sh -c "cp /usr/src/googletest/googletest/build/libgtest*.a /usr/lib/"
fi
fi
if [ ! -f "/usr/lib/libgtest.a" ]; then
$SUDO sh -c "cd /usr/src/googletest/googletest && mkdir -p build && cd build && cmake .. -DCMAKE_CXX_FLAGS=\"-std=c++11\" && make -j"
$SUDO sh -c "cp /usr/src/googletest/googletest/build/lib/libgtest* /usr/lib/"
$SUDO sh -c "rm -rf /usr/src/googletest/googletest/build"
$SUDO sh -c "mkdir /usr/local/lib/googletest"
$SUDO sh -c "ln -s /usr/lib/libgtest.a /usr/local/lib/googletest/libgtest.a"
$SUDO sh -c "ln -s /usr/lib/libgtest_main.a /usr/local/lib/googletest/libgtest_main.a"
$SUDO sh -c "rm -rf /usr/src/googletest/googletest/build"
$SUDO sh -c "mkdir /usr/local/lib/googletest"
$SUDO sh -c "ln -s /usr/lib/libgtest.a /usr/local/lib/googletest/libgtest.a"
$SUDO sh -c "ln -s /usr/lib/libgtest_main.a /usr/local/lib/googletest/libgtest_main.a"
fi
echo "- libgtest is installed in system."
$SUDO sh -c "apt install git-lfs"
echo "- git-lfs is installed in system."
# Install numpy
$SUDO sh -c "apt install -y python3 python3-pip"
if [[ $ubuntu_codename == "xenial" ]]; then
$SUDO sh -c "pip3 install numpy==1.18.5"
else
$SUDO sh -c "pip3 install numpy"
fi
echo "- Done."
echo "- Done."