Sign inSign up

hienanh/tflite-env

By hienanh

•Updated over 3 years ago

Image
0

68

hienanh/tflite-env repository overview

⁠Build

docker build -t hienanh/tflite-env:tf-2.4 . -f Dockerfile

⁠Run

docker run -it -d --name tflite-env -v $(pwd):/root/tflite-test hienanh/tflite-env:tf-2.4

⁠Dockerfile

Click to expand
FROM ubuntu:focal
ENV DEBIAN_FRONTEND noninteractive

# Install necessary library
RUN apt update && \
    apt upgrade -y && \
    apt install --assume-yes python3-pip && \    
    apt install --assume-yes software-properties-common git cmake g++ zlib* wget libssl1* libssl-dev curl tmux nano -y

# install Gstreamer
RUN apt update && \
    apt upgrade --assume-yes && \
    apt install --assume-yes libgstreamer1.0-dev \
        libgstreamer-plugins-base1.0-dev \
        libgstreamer-plugins-bad1.0-dev \
        gstreamer1.0-plugins-base \
        gstreamer1.0-plugins-good \
        gstreamer1.0-plugins-bad \
        gstreamer1.0-plugins-ugly \
        gstreamer1.0-libav \
        gstreamer1.0-doc \
        gstreamer1.0-tools \
        gstreamer1.0-x \
        gstreamer1.0-alsa \
        gstreamer1.0-gl \
        gstreamer1.0-gtk3 \
        gstreamer1.0-qt5 \
        gstreamer1.0-pulseaudio

# Install Gstreamer RTSP plugin and OpenSSL
RUN apt install gstreamer1.0-rtsp libgstrtspserver-1.0-dev libssl1* -y

# install opencv
ARG OPENCV_VERSION="4.5.5"
RUN apt install --assume-yes build-essential cmake git pkg-config libgtk-3-dev \
    libavcodec-dev libavformat-dev libswscale-dev libv4l-dev \
    libxvidcore-dev libx264-dev libjpeg-dev libpng-dev libtiff-dev \
    gfortran openexr libatlas-base-dev python3-dev python3-numpy \
    libtbb2 libtbb-dev libdc1394-22-dev libopenexr-dev \
    libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev && \
    cd /root && \
    git clone --depth 1 --branch ${OPENCV_VERSION} https://github.com/opencv/opencv.git && mkdir -p opencv/build && \
    git clone --depth 1 --branch ${OPENCV_VERSION} https://github.com/opencv/opencv_contrib.git && \
    cd /root/opencv/build && \
    cmake -D CMAKE_BUILD_TYPE=RELEASE \
        -D CMAKE_C_COMPILER=/usr/bin/gcc \
        -D CMAKE_INSTALL_PREFIX=/usr/local \
        -D INSTALL_C_EXAMPLES=OFF \
        -D INSTALL_PYTHON_EXAMPLES=OFF \
        -D BUILD_EXAMPLES=OFF \
        -D BUILD_opencv_python2=OFF \
        -D WITH_GSTREAMER=ON \
        -D OPENCV_GENERATE_PKGCONFIG=ON \
        -D OPENCV_PC_FILE_NAME=opencv.pc \
        -D BUILD_SHARED_LIBS=ON \
        -D OPENCV_EXTRA_MODULES_PATH=/root/opencv_contrib/modules .. && \
    cd /root/opencv/build && make -j$(nproc) && \
    make install && \
    ldconfig && \
    pkg-config --modversion opencv && \
    cd /root && \
    rm -rf /root/opencv*

# Install TensorflowLite
RUN apt update && \
    apt install curl && \
    curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg && \
    mv bazel.gpg /etc/apt/trusted.gpg.d/ && \
    echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | tee /etc/apt/sources.list.d/bazel.list && \
    apt update && apt install bazel-3.1.0 && ln -s /usr/bin/bazel-3.1.0 /usr/bin/bazel
    
RUN apt install python3-dev python3-pip && \
    python3 -m pip install -U --user pip numpy wheel packaging requests opt_einsum && \
    python3 -m pip install -U --user keras_preprocessing --no-deps

RUN cd /root && git clone https://github.com/tensorflow/tensorflow.git && \
    cd tensorflow && git checkout r2.4 && \
    cd /usr/bin && ln -sf python3 python && ln -sf pip3 pip && cd - && \
    cd /root/tensorflow && export PYTHON_BIN_PATH=/usr/bin/python3 && \
    echo "\nN\nN\nN\n\nN\n" | python3 ./configure.py && \
    bazel build -c opt //tensorflow/lite:libtensorflowlite.so
#    bazel build //tensorflow/tools/pip_package:build_pip_package

# Install Cmake 3.22.0
RUN cd /root && \
    git clone https://github.com/Kitware/CMake.git && \
    cd CMake && \
    ./bootstrap && make -j$(nproc) && make install && \
    cd /root && rm -rf CMake

# Install g++-9
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && \
    apt update && \
    apt install --assume-yes gcc-9 g++-9 clang-format && \
    ln -sf /usr/bin/x86_64-linux-gnu-g++-9 /usr/bin/g++

WORKDIR /root

Tag summary

Content type

Image

Digest

sha256:39f5ce5bb…

Size

2.1 GB

Last updated

over 3 years ago

docker pull hienanh/tflite-env:tf-2.4