Skip to content
Snippets Groups Projects
Commit 788f9b25 authored by Nicolas Pope's avatar Nicolas Pope
Browse files

Dockerfiles and docker dev environment

parent 3af0bb6b
No related branches found
No related tags found
1 merge request!360Dockerfiles and docker dev environment
Showing
with 282 additions and 16 deletions
...@@ -13,4 +13,5 @@ lab-designs/viewer ...@@ -13,4 +13,5 @@ lab-designs/viewer
doc/ doc/
web-service/npm-debug.log web-service/npm-debug.log
web-service/server/npm-debug.log web-service/server/npm-debug.log
gmon.out gmon.out
\ No newline at end of file .devcontainer.json
\ No newline at end of file
...@@ -25,12 +25,7 @@ build: ...@@ -25,12 +25,7 @@ build:
# - apt-get update -qq && apt-get install -y -qq g++ cmake git # - apt-get update -qq && apt-get install -y -qq g++ cmake git
# - apt-get install -y -qq libopencv-dev libgoogle-glog-dev liburiparser-dev libreadline-dev libmsgpack-dev uuid-dev # - apt-get install -y -qq libopencv-dev libgoogle-glog-dev liburiparser-dev libreadline-dev libmsgpack-dev uuid-dev
script: script:
- mkdir build - ./docker/CI/pipeline-script.sh
- cd build
- /snap/bin/cmake .. -GNinja -DCMAKE_CXX_FLAGS="-fdiagnostics-color" -DWITH_OPTFLOW=TRUE -DUSE_CPPCHECK=FALSE -DBUILD_CALIBRATION=TRUE -DWITH_CERES=TRUE -DCMAKE_BUILD_TYPE=Release -DCPACK_GENERATOR=DEB
- ninja
- ninja package
- ctest --output-on-failure
# - cd ../SDK/Python # - cd ../SDK/Python
# - python3 -m unittest discover test # - python3 -m unittest discover test
......
...@@ -49,7 +49,7 @@ MACRO( VERSION_STR_TO_INTS major minor patch version ) ...@@ -49,7 +49,7 @@ MACRO( VERSION_STR_TO_INTS major minor patch version )
ENDMACRO( VERSION_STR_TO_INTS ) ENDMACRO( VERSION_STR_TO_INTS )
if (CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CUDA_HOST_COMPILER gcc-7) set(CMAKE_CUDA_HOST_COMPILER gcc)
endif() endif()
find_package( OpenCV REQUIRED COMPONENTS core imgproc highgui cudaimgproc calib3d imgcodecs videoio aruco cudaarithm cudastereo cudaoptflow face tracking quality xfeatures2d) find_package( OpenCV REQUIRED COMPONENTS core imgproc highgui cudaimgproc calib3d imgcodecs videoio aruco cudaarithm cudastereo cudaoptflow face tracking quality xfeatures2d)
...@@ -290,6 +290,7 @@ enable_language(CUDA) ...@@ -290,6 +290,7 @@ enable_language(CUDA)
if (NOT WIN32) if (NOT WIN32)
set(CMAKE_CUDA_FLAGS "-Xcompiler -fPIC") set(CMAKE_CUDA_FLAGS "-Xcompiler -fPIC")
set(CMAKE_CUDA_STANDARD 14)
endif() endif()
set(CMAKE_CUDA_ARCHITECTURES 61) set(CMAKE_CUDA_ARCHITECTURES 61)
set(CMAKE_CUDA_FLAGS_DEBUG "--gpu-architecture=compute_61 -g -DDEBUG -D_DEBUG") set(CMAKE_CUDA_FLAGS_DEBUG "--gpu-architecture=compute_61 -g -DDEBUG -D_DEBUG")
......
...@@ -32,6 +32,37 @@ found in the `config` folder. The intention is that a web interface will ...@@ -32,6 +32,37 @@ found in the `config` folder. The intention is that a web interface will
eventually enable this configuration to take place online. eventually enable this configuration to take place online.
## Build ## Build
### Container
FTL can be built and developed inside a docker container. To do this, run the
following sequence of commands and create a `.devcontainer.json` file as shown.
Note: A ~3Gb image will be downloaded when running these commands, which
contains all build dependencies and tools.
```bash
cd ./docker/devel
docker build -t ftl-devel --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) .
```
And the `.devcontainer.json` looks similar to this and goes in the repository
root:
```json
{
"image": "ftl-devel",
"runArgs": [
"--runtime=nvidia",
"--device=/dev/snd",
"--device=/dev/bus/usb",
"-e", "DISPLAY=:1",
"-v", "/tmp/.X11-unix:/tmp/.X11-unix",
],
"extensions": []
}
```
### Local
Use the following commands in the root repository directory to build: Use the following commands in the root repository directory to build:
```bash ```bash
......
...@@ -23,7 +23,7 @@ if(WIN32) ...@@ -23,7 +23,7 @@ if(WIN32)
set(OS_LIBS "") set(OS_LIBS "")
else() else()
add_definitions(-DUNIX) add_definitions(-DUNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC -march=native -mfpmath=sse -Wall -Werror=unused-result -Werror=return-type -pthread") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 -fPIC -march=native -mfpmath=sse -Wall -Werror=unused-result -Werror=return-type -pthread")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3") set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3")
set(OS_LIBS "dl") set(OS_LIBS "dl")
......
...@@ -194,7 +194,9 @@ bool DetectAndTrack::track(const Mat &im) { ...@@ -194,7 +194,9 @@ bool DetectAndTrack::track(const Mat &im) {
} }
else { it++; }*/ else { it++; }*/
if (it->fail_count >= max_fail_ || !it->tracker->update(im, it->object)) { cv::Rect rect = it->object;
if (it->fail_count >= max_fail_ || !it->tracker->update(im, rect)) {
it = tracked_.erase(it); it = tracked_.erase(it);
} else { } else {
++it; ++it;
......
...@@ -43,7 +43,7 @@ bool NVOpticalFlow::init() { ...@@ -43,7 +43,7 @@ bool NVOpticalFlow::init() {
return false; return false;
} }
nvof_ = cv::cuda::NvidiaOpticalFlow_1_0::create( nvof_ = cv::cuda::NvidiaOpticalFlow_1_0::create(
size_.width, size_.height, size_,
cv::cuda::NvidiaOpticalFlow_1_0::NV_OF_PERF_LEVEL_SLOW, cv::cuda::NvidiaOpticalFlow_1_0::NV_OF_PERF_LEVEL_SLOW,
true, false, false, 0); true, false, false, 0);
......
...@@ -254,7 +254,7 @@ void StereoVideoSource::updateParameters(ftl::rgbd::Frame &frame) { ...@@ -254,7 +254,7 @@ void StereoVideoSource::updateParameters(ftl::rgbd::Frame &frame) {
return true; return true;
}); });
if (lsrc_->isStereo()) { if (lsrc_->isStereo() && calibration_.enabled) {
Eigen::Matrix4d pose; Eigen::Matrix4d pose;
// NOTE: pose update (new origin/rotation) // NOTE: pose update (new origin/rotation)
cv::cv2eigen(calibration_.origin * rectification_->getPose(Channel::Left), pose); cv::cv2eigen(calibration_.origin * rectification_->getPose(Channel::Left), pose);
......
FROM ftlab/base:1.0-dev
RUN mkdir /opt/ftl
WORKDIR /opt/ftl
COPY ./applications ./applications
COPY ./cmake ./cmake
COPY ./components ./components
COPY ./lib ./lib
COPY ./ext ./ext
COPY ./SDK ./SDK
CMD mkdir build &&\
cd build &&\
cmake .. -GNinja -DCMAKE_CXX_FLAGS="-fdiagnostics-color" -DWITH_OPTFLOW=TRUE -DUSE_CPPCHECK=FALSE -DBUILD_CALIBRATION=TRUE -DWITH_CERES=TRUE -DCMAKE_BUILD_TYPE=Release -DCPACK_GENERATOR=DEB &&\
ninja &&\
ninja package &&\
ctest --output-on-failure
#!/bin/sh
cd /opt/ftl
mkdir build
cd build
cmake .. -DCMAKE_CXX_FLAGS="-fdiagnostics-color" -DWITH_OPTFLOW=TRUE -DUSE_CPPCHECK=FALSE -DBUILD_CALIBRATION=TRUE -DWITH_CERES=TRUE -DCMAKE_BUILD_TYPE=Release -DCPACK_GENERATOR=DEB &&
make -j4 &&
ctest --output-on-failure
#!/bin/sh
docker run \
--runtime=nvidia \
--device=/dev/snd \
--device=/dev/bus/usb \
-e NVIDIA_DRIVER_CAPABILITIES=graphics,compute,utility,video \
-v "${PWD}:/opt/ftl" \
-u $(id -u ${USER}):$(id -g ${USER}) \
ftlab/base:1.0-dev \
/opt/ftl/docker/CI/container-script.sh
\ No newline at end of file
FROM nvidia/cuda:11.4.0-devel-ubuntu20.04 AS devel
ARG OPENCV_VERSION=4.5.3
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/London
ENV NVIDIA_DRIVER_CAPABILITIES graphics,compute,utility,video
RUN apt-get update &&\
# Install build tools, build dependencies and python
apt-get install --no-install-recommends -y \
build-essential \
cmake \
git \
openssh-client \
wget \
unzip \
yasm \
cppcheck \
pkg-config \
libceres-dev \
libreadline-dev \
libopus-dev \
libxtst-dev \
libswscale-dev \
libtbb2 \
libtbb-dev \
libjpeg-dev \
libpng-dev \
libglew-dev \
zlib1g-dev \
libasound-dev \
libavcodec-dev \
libavformat-dev \
libavutil-dev \
libpostproc-dev \
libswscale-dev \
libeigen3-dev \
libgtk2.0-dev \
libxxf86vm-dev \
uuid-dev \
libmsgpack-dev \
liburiparser-dev \
software-properties-common \
&& apt-key adv --keyserver keys.gnupg.net --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE || apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-key F6E65AC044F831AC80A06380C8B3A55A6F3EFCDE && \
add-apt-repository "deb https://librealsense.intel.com/Debian/apt-repo focal main" -u && \
apt-get update && \
apt-get install --no-install-recommends -y \
librealsense2-dev \
&& rm -rf /var/lib/apt/lists/*
COPY ./libnvcuvid.so ./libnvidia-encode.so /usr/lib/x86_64-linux-gnu/
RUN cd /opt/ &&\
# Pylon
wget -O pylon.deb https://seafile.utu.fi/f/b4585f6c84f0462fac04/?dl=1 &&\
apt-get install ./pylon.deb &&\
rm ./pylon.deb &&\
rm -rf /var/lib/apt/lists/* &&\
# Portaudio
cd /opt/ &&\
wget http://files.portaudio.com/archives/pa_stable_v190700_20210406.tgz &&\
tar -xf ./pa_stable_v190700_20210406.tgz &&\
rm ./pa_stable_v190700_20210406.tgz &&\
cd ./portaudio &&\
./configure && make && make install &&\
rm -rf ./portaudio &&\
# Download and unzip OpenCV and opencv_contrib and delte zip files
cd /opt/ &&\
wget https://github.com/opencv/opencv/archive/$OPENCV_VERSION.zip &&\
unzip $OPENCV_VERSION.zip &&\
rm $OPENCV_VERSION.zip &&\
wget https://github.com/opencv/opencv_contrib/archive/$OPENCV_VERSION.zip &&\
unzip ${OPENCV_VERSION}.zip &&\
rm ${OPENCV_VERSION}.zip &&\
# Create build folder and switch to it
mkdir /opt/opencv-${OPENCV_VERSION}/build && cd /opt/opencv-${OPENCV_VERSION}/build &&\
# Cmake configure
cmake \
-DOPENCV_EXTRA_MODULES_PATH=/opt/opencv_contrib-${OPENCV_VERSION}/modules \
-DWITH_CUDA=ON \
-DOPENCV_ENABLE_NONFREE=ON\
-DCUDA_ARCH_BIN="6.1 7.5" \
-DBUILD_TESTS=OFF\
-DBUILD_PERF_TESTS=OFF\
-DBUILD_EXAMPLES=OFF\
-DBUILD_opencv_bioinspired=OFF\
-DBUILD_opencv_cudaobjdetect=OFF\
-DBUILD_opencv_dnn=OFF\
-DBUILD_opencv_dnn_objdetect=OFF\
-DBUILD_opencv_dnn_superres=OFF\
-DBUILD_opencv_fuzzy=OFF\
-DBUILD_opencv_hdf=OFF\
-DBUILD_opencv_hfs=OFF\
-DBUILD_opencv_dpm=OFF\
-DBUILD_opencv_image_hash=OFF\
-DBUILD_opencv_java_bindings_generator=OFF\
-DBUILD_opencv_js=OFF\
-DBUILD_opencv_saliency=OFF\
-DBUILD_opencv_sfm=OFF\
-DBUILD_opencv_stitching=OFF\
-DBUILD_opencv_structured_light=OFF\
-DBUILD_opencv_superres=OFF\
-DBUILD_opencv_surface_matching=OFF\
-DBUILD_opencv_viz=OFF\
-DBUILD_opencv_xobjdetect=OFF\
-DBUILD_opencv_gapi=OFF\
-DBUILD_opencv_videostab=OFF\
-DBUILD_opencv_rgbd=OFF\
-DWITH_CUDNN=OFF\
-DWITH_TIFF=OFF\
-DWITH_WEBP=OFF\
-DWITH_OPENEXR=OFF\
-DWITH_OPENCL=OFF\
-DWITH_PROTOBUF=OFF\
-DCMAKE_BUILD_TYPE=RELEASE \
# Install path will be /usr/local/lib (lib is implicit)
-DCMAKE_INSTALL_PREFIX=/usr/local \
.. &&\
# Make
make -j"$(nproc)" && \
# Install to /usr/local/lib
make install && \
ldconfig &&\
# Remove OpenCV sources and build folder
rm -rf /opt/opencv-${OPENCV_VERSION} && rm -rf /opt/opencv_contrib-${OPENCV_VERSION} &&\
ln -s /usr/local/include/opencv4/opencv2 /usr/local/include/opencv2
FROM nvidia/cuda:11.4.0-base-ubuntu20.04 AS runtime
ARG OPENCV_VERSION=4.5.3
ARG DEBIAN_FRONTEND=noninteractive
ENV TZ=Europe/London
ENV NVIDIA_DRIVER_CAPABILITIES graphics,compute,utility,video
RUN apt-get update && apt-get upgrade -y &&\
# Install build tools, build dependencies and python
apt-get install --no-install-recommends -y \
libceres1 \
libreadline8 \
libopus0 \
libxtst6 \
libtbb2 \
libjpeg8 \
libpng16-16 \
libtiff5 \
libavformat58 \
libpq5 \
libxine2 \
libglew2.1 \
zlib1g \
libasound2 \
libavcodec58 \
libavutil56 \
libpostproc55 \
libswscale5 \
libgtk2.0-0 \
libxxf86vm1 \
uuid \
libmsgpackc2 \
liburiparser1 \
software-properties-common \
&& rm -rf /var/lib/apt/lists/*
COPY --from=devel /usr/local/share /usr/local/share
COPY --from=devel /usr/local/lib /usr/local/lib
COPY --from=devel /opt/pylon /opt/pylon
COPY --from=devel /etc/udev/rules.d/69-basler-cameras.rules /etc/udev/rules.d/
COPY --from=devel /etc/profile.d /etc/profile.d
# FTL Base Docker Image
This image contains all dependencies and build tools for FTL.
* CUDA 11.4.0
* OpenCV 4.5.3
* Pylon 6.1.1
## Image Build
An example build command is given below, just bump the version number.
```
docker build -t ftlab/base:1.0-dev --target=devel .
```
\ No newline at end of file
File added
File added
FROM ftlab/base:1.0-dev
ARG USER_ID
ARG GROUP_ID
RUN addgroup --gid $GROUP_ID user && adduser --disabled-password --gecos '' --uid $USER_ID --gid $GROUP_ID user
USER user
# FTL Developer Docker Image
This is a small wrapper image that should be built locally by the developer. It adds correct user permissions to the image to ensure files are created correctly on the host if volumes are used.
## Image Build
```
docker build -t ftl-devel --build-arg USER_ID=$(id -u) --build-arg GROUP_ID=$(id -g) .
```
...@@ -16,17 +16,18 @@ find_package( Threads REQUIRED ) ...@@ -16,17 +16,18 @@ find_package( Threads REQUIRED )
check_language(CUDA) check_language(CUDA)
enable_language(CUDA) enable_language(CUDA)
set(CMAKE_CXX_CPPCHECK "cppcheck") # set(CMAKE_CXX_CPPCHECK "cppcheck")
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CUDA_STANDARD 14)
set(CMAKE_USE_RELATIVE_PATHS ON) set(CMAKE_USE_RELATIVE_PATHS ON)
set(CMAKE_CXX_FLAGS_RELEASE) set(CMAKE_CXX_FLAGS_RELEASE)
if (CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CUDA_HOST_COMPILER gcc-7) set(CMAKE_CUDA_HOST_COMPILER gcc)
set(CMAKE_CUDA_FLAGS "--gpu-architecture=compute_61 -std=c++14 -Xcompiler -fPIC -Xcompiler ${OpenMP_CXX_FLAGS} --expt-relaxed-constexpr") set(CMAKE_CUDA_FLAGS "--gpu-architecture=compute_61 -Xcompiler -fPIC -Xcompiler ${OpenMP_CXX_FLAGS} --expt-relaxed-constexpr")
set(CMAKE_CUDA_FLAGS_RELEASE "-O3") set(CMAKE_CUDA_FLAGS_RELEASE "-O3")
else() else()
set(CMAKE_CUDA_FLAGS "--gpu-architecture=compute_61 -std=c++14 --expt-relaxed-constexpr") set(CMAKE_CUDA_FLAGS "--gpu-architecture=compute_61 --expt-relaxed-constexpr")
set(CMAKE_CUDA_FLAGS_RELEASE "-O3") set(CMAKE_CUDA_FLAGS_RELEASE "-O3")
endif() endif()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment