Skip to content

Commit

Permalink
Add gpu_test_ci
Browse files Browse the repository at this point in the history
  • Loading branch information
taoboyang authored and root committed Aug 26, 2024
1 parent 1c023ae commit e3f240d
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 25 deletions.
40 changes: 33 additions & 7 deletions .codebase/pipelines/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ jobs:
- apt-get update
- apt-get install -y protobuf-compiler libgflags-dev libdw-dev libgoogle-glog-dev
- pip3 install --upgrade pip
- pip3 install timeout_decorator onnxruntime requests opencv-python
- pip3 install timeout_decorator onnxruntime==1.18.0 numpy==1.26.4 requests opencv-python
- echo "build finished"
- name: run_test
commands:
Expand Down Expand Up @@ -101,14 +101,14 @@ jobs:
- uses: actions/checkout
inputs:
depth: 1
- uses: actions/setup-proxy
- name: prepare conda environment
commands:
- apt update && apt install -y wget curl bzip2
- curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/1.5.5 | tar -xvj bin/micromamba
- ./bin/micromamba env create -f conda-env.yaml -y
- uses: actions/setup-proxy
- name: build_env
commands:
- ./bin/micromamba env create -f conda-env.yaml -y
- eval "$(./bin/micromamba shell hook -s posix)"
- micromamba activate bmf-test
- ./build.sh non_local
Expand Down Expand Up @@ -169,7 +169,7 @@ jobs:
eval "$(./win_env/vcvarsall.sh x64)"
export INCLUDE="${INCLUDE};C:\\msys64\\usr\\local\\include"
pacman -S unzip ca-certificates --noconfirm
wget https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-03-31-17-28/ffmpeg-n4.4.4-94-g5d07afd482-win64-gpl-shared-4.4.zip
wget https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2024-03-31-17-28/ffmpeg-n4.4.4-94-g5d07afd482-win64-gpl-shared-4.4.zip --no-check-certificate
unzip ffmpeg-n4.4.4-94-g5d07afd482-win64-gpl-shared-4.4.zip
mkdir -p /usr/local
cp -r ffmpeg-n4.4.4-94-g5d07afd482-win64-gpl-shared-4.4/* /usr/local/
Expand All @@ -187,8 +187,8 @@ jobs:
export PATH=$(pwd)/3rd_party/win_rootfs/x64/usr/bin:$(pwd)/3rd_party/win_rootfs/x64/usr/lib:$(pwd)/output/bmf/bin:$(pwd)/output/bmf/lib:${PATH}
./output/bmf/bin/module_manager install python_copy_module python my_module:my_module $(pwd)/output/test/customize_module v0.0.1
./output/bmf/bin/module_manager install cpp_copy_module c++ copy_module:CopyModule $(pwd)/output/test/c_module/lib v0.0.1
(cd output && wget https://github.com/BabitMF/bmf/releases/download/files/files.tar.gz && tar xvf files.tar.gz && rm -rf files.tar.gz)
(cd output && wget https://github.com/BabitMF/bmf/releases/download/files/models.tar.gz && tar xvf models.tar.gz && rm -rf models.tar.gz)
(cd output && wget https://github.com/BabitMF/bmf/releases/download/files/files.tar.gz --no-check-certificate && tar xvf files.tar.gz && rm -rf files.tar.gz)
(cd output && wget https://github.com/BabitMF/bmf/releases/download/files/models.tar.gz --no-check-certificate && tar xvf models.tar.gz && rm -rf models.tar.gz)
cd output/bmf/bin
./test_bmf_module_sdk.exe
./test_bmf_engine.exe --gtest_filter=-go_module.module_loader
Expand All @@ -212,4 +212,30 @@ jobs:
(cd bmf/hml/tests/data && ./gen.sh $(pwd)/../../../../output/files)
(cd bmf/hml/tests && python -m pytest)
'@
- echo $bashCommand | & $bashPath
- echo $bashCommand | & $bashPath

gpu_test_ci:
name: gpu_test_ci
image: babitmf/bmf_runtime:latest
runs-on:
cluster: "gpu_host"
envs:
NVIDIA_VISIBLE_DEVICES: all
NVIDIA_DRIVER_CAPABILITIES: all
steps:
- uses: actions/setup-proxy
- name: build_env
commands:
- rm -rf /root/bmf
- git submodule update --init --recursive
- ./build.sh
- export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:$(pwd)/output/bmf/lib"
- export PYTHONPATH="${PYTHONPATH}:$(pwd)/output/bmf/lib:$(pwd)/output"
- (cd output && wget https://github.com/BabitMF/bmf/releases/download/files/files.tar.gz --no-check-certificate && tar xvf files.tar.gz && rm -rf files.tar.gz)
- (cd output && wget https://github.com/BabitMF/bmf/releases/download/files/models.tar.gz --no-check-certificate && tar xvf models.tar.gz && rm -rf models.tar.gz)
- (cd output/demo/gpu_module && python3 test_gpu_module.py)
- (cd output/demo/video_frame_extraction && cmake . && make -j8 && python3 video_frame_extraction.py)
- (cd output/demo/video_enhance && pip install basicsr==1.4.2 realesrgan && (sed -i '8s/from torchvision.transforms.functional_tensor import rgb_to_grayscale/from torchvision.transforms.functional import rgb_to_grayscale/' /usr/local/lib/python3.8/dist-packages/basicsr/data/degradations.py) && python3 enhance_demo.py)
- (cd output/demo/aesthetic_assessment && pip install onnxruntime && python3 aesthetic_assessment_demo.py)
- (cd output/demo/face_detect && cp ../../models/version-RFB-640.onnx . && trtexec --onnx=version-RFB-640.onnx --buildOnly --saveEngine=version-RFB-640.engine && cp version-RFB-640.engine ../../models && python3 detect_trt_sample.py)
- (cd output/demo/colorization_python && git clone https://github.com/eefengwei/DeOldify.git DeOldify && pip3 install -r ./DeOldify/requirements-colab.txt && pip3 install Ipython && mkdir -p ./DeOldify/models && wget -c https://huggingface.co/spensercai/DeOldify/resolve/main/ColorizeVideo_gen.pth -O ./DeOldify/models/ColorizeVideo_gen.pth && python3 deoldify_demo.py)
2 changes: 1 addition & 1 deletion bmf/demo/aesthetic_assessment/aesthetic_assessment_demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def segment_decode_ticks(video_path,


if __name__ == "__main__":
input_path = "bbb_360_20s.mp4"
input_path = "../../files/big_bunny_1min_30fps.mp4"
outp_path = "res2.json"

option = dict()
Expand Down
2 changes: 1 addition & 1 deletion bmf/demo/colorization_python/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pip3 install -r ./DeOldify/requirements-colab.txt
### 1.3 download the pretrained-weights
```Bash
mkdir -p ./DeOldify/models
wget -c https://data.deepai.org/deoldify/ColorizeVideo_gen.pth -O ./DeOldify/models/ColorizeVideo_gen.pth
wget -c https://huggingface.co/spensercai/DeOldify/resolve/main/ColorizeVideo_gen.pth -O ./DeOldify/models/ColorizeVideo_gen.pth
```

### 1.4 pip install BMF packages
Expand Down
1 change: 0 additions & 1 deletion bmf/demo/colorization_python/deoldify_demo.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import bmf
import py_deoldify_module

# Add the DeOldify folder to the python search path
import sys
Expand Down
2 changes: 1 addition & 1 deletion bmf/demo/gpu_module/test_gpu_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@


def test():
input_video_path = "../../files/demo_JHH.mp4"
input_video_path = "../../files/big_bunny_1min_30fps.mp4"
output_path = "./output.mp4"

graph = bmf.graph()
Expand Down
2 changes: 1 addition & 1 deletion bmf/demo/video_enhance/enhance_demo.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

input_file = "bbb_360_20s.mp4"
input_file = "../../files/big_bunny_10s_30fps.mp4"
output_file = "output.mp4"
output_compose_file = "output_compose.mp4"

Expand Down
2 changes: 1 addition & 1 deletion bmf/demo/video_frame_extraction/video_frame_extraction.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def extract_frame_test():
graph = bmf.graph({'dump_graph': 1})
video = graph.decode({
"input_path": "../../files/demo_JHH.mp4",
"input_path": "../../files/big_bunny_1min_30fps.mp4",
"video_params": {
"hwaccel": "cuda",
"hwaccel_output_format": "cuda",
Expand Down
2 changes: 1 addition & 1 deletion build_win_lite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ git submodule update --init --recursive

if [ ! -d "3rd_party/win_rootfs" ]
then
(cd 3rd_party/ && wget https://github.com/BabitMF/bmf/releases/download/files/win_rootfs.tar.gz && tar zvxf win_rootfs.tar.gz)
(cd 3rd_party/ && wget https://github.com/BabitMF/bmf/releases/download/files/win_rootfs.tar.gz --no-check-certificate && tar zvxf win_rootfs.tar.gz)
fi
source ./version.sh

Expand Down
14 changes: 10 additions & 4 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,15 @@ ARG GITHUB_ACTIONS

ENV GITHUB_ACTIONS=${GITHUB_ACTIONS}
ENV DEBIAN_FRONTEND=noninteractive
# required
ENV NVIDIA_VISIBLE_DEVICES=all \
NVIDIA_DRIVER_CAPABILITIES=all
# # required
RUN apt update \
&& apt install -y ca-certificates make git pkg-config libssl-dev cmake python3 python3-dev python3-pip binutils-dev libgoogle-glog-dev wget gcc g++ yasm nasm apt-utils
&& apt install -y ca-certificates make git pkg-config libssl-dev cmake python3 python3-dev python3-pip binutils-dev libgoogle-glog-dev wget gcc g++ yasm nasm apt-utils \
&& apt autoremove cmake -y \
&& wget https://github.com/Kitware/CMake/releases/download/v3.26.4/cmake-3.26.4-Linux-x86_64.tar.gz && tar -zvxf cmake-3.26.4-Linux-x86_64.tar.gz \
&& rm -rf cmake-3.26.4-linux-x86_64/man && cp -r cmake-3.26.4-linux-x86_64/* /usr/local && rm -rf cmake-*

# optional
# RUN apt install -y libopencv-dev libomp-dev libtorch3-dev

Expand All @@ -20,12 +26,12 @@ COPY ./ /root/bmf/
WORKDIR /root/bmf/
# ffmpeg installed via apt has no development libraries, so we build it from source

RUN ./scripts/build_ffmpeg.sh --device=gpu x264 x265 fdk-aac opus nasm \
RUN ./scripts/build_ffmpeg.sh --device=${DEVICE} x264 x265 fdk-aac opus nasm \
&& rm -rf ffmpeg_source

ARG CMAKE_ARGS="-DBMF_ENABLE_CUDA=OFF -DBMF_ENABLE_BREAKPAD=ON"
RUN ./build.sh && rm -rf .git && ./build.sh clean

ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/bmf/output/bmf/lib:/usr/local/cuda/lib64:/usr/local/TensorRT-8.6.1.6/lib:/usr/local/lib
ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/root/bmf/output/bmf/lib:/usr/local/TensorRT-8.6.1.6/lib:/usr/local/lib:/usr/local/cuda/lib64:/usr/local/cuda/compat
ENV PATH=${PATH}:/root/bmf/output/bmf/bin:/usr/local/cuda/bin:/usr/local/TensorRT-8.6.1.6/bin
ENV PYTHONPATH=$PYTHONPATH:/usr/local/lib/python3.8/dist-packages/nvcv_python:/root/bmf/output
19 changes: 12 additions & 7 deletions scripts/build_ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ function install_cuda_linux() {
dpkg -i cuda-repo-ubuntu2004-12-2-local_12.2.0-535.54.03-1_amd64.deb
cp /var/cuda-repo-ubuntu2004-12-2-local/cuda-*-keyring.gpg /usr/share/keyrings/
apt-get update
apt-get -y install cuda
apt-get -y install cuda-toolkit-12-2 cuda-compat-12-2
rm -rf cuda-repo-ubuntu2004-12-2-local_12.2.0-535.54.03-1_amd64.deb
dpkg -r cuda-repo-ubuntu2004-12-2-local
elif [[ ${NAME} == "Ubuntu" ]] && [[ ${VERSION_ID} == "22.04" ]]
Expand All @@ -200,15 +200,15 @@ function install_cuda_linux() {
wget https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda-repo-ubuntu2204-12-2-local_12.2.0-535.54.03-1_amd64.deb dpkg -i cuda-repo-ubuntu2204-12-2-local_12.2.0-535.54.03-1_amd64.deb
cp /var/cuda-repo-ubuntu2204-11-8-local/cuda-*-keyring.gpg /usr/share/keyrings/
apt-get update
apt-get -y install cuda
apt-get -y install cuda-toolkit-12-2 cuda-compat-12-2
elif [[ ${NAME} =~ "Debian" ]] && [[ ${VERSION_ID} == "11" ]]
then
wget https://developer.download.nvidia.com/compute/cuda/12.2.0/local_installers/cuda-repo-debian11-12-2-local_12.2.0-535.54.03-1_amd64.deb
dpkg -i cuda-repo-debian11-12-2-local_12.2.0-535.54.03-1_amd64.deb
cp /var/cuda-repo-debian11-12-2-local/cuda-*-keyring.gpg /usr/share/keyrings/
add-apt-repository contrib
apt-get update
apt-get -y install cuda
apt-get -y install cuda-toolkit-12-2 cuda-compat-12-2
elif [[ ${NAME} =~ "AlmaLinux" ]] && [[ ${VERSION_ID} == "8.10" ]]
then
original_ld_lib_path=$LD_LIBRARY_PATH
Expand Down Expand Up @@ -290,6 +290,7 @@ function build_ffnvcodec_linux() {
}

function install_cudnn_linux() {
rm /etc/apt/sources.list.d/cuda*
cd $1
mkdir cudnn
cd cudnn
Expand All @@ -301,12 +302,16 @@ function install_cudnn_linux() {
apt-get -y install libcudnn8 libcudnn8-dev
elif [[ ${NAME} == "Ubuntu" ]] && [[ ${VERSION_ID} == "22.04" ]]
then
wget https://developer.nvidia.com/downloads/compute/cudnn/secure/8.9.2/local_installers/12.x/cudnn-local-repo-ubuntu2204-8.9.2.26_1.0-1_amd64.deb
dpkg -i cudnn-local-repo-ubuntu2204-8.9.2.26_1.0-1_amd64.deb
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
dpkg -i cuda-keyring_1.1-1_all.deb
apt-get update
apt-get -y install libcudnn8 libcudnn8-dev
elif [[ ${NAME} =~ "Debian" ]] && [[ ${VERSION_ID} == "11" ]]
then
wget https://developer.nvidia.com/downloads/compute/cudnn/secure/8.9.2/local_installers/12.x/cudnn-local-repo-debian11-8.9.2.26_1.0-1_amd64.deb
dpkg -i cudnn-local-repo-debian11-8.9.2.26_1.0-1_amd64.deb
wget https://developer.download.nvidia.com/compute/cuda/repos/debian11/x86_64/cuda-keyring_1.1-1_all.deb
dpkg -i cuda-keyring_1.1-1_all.deb
apt-get update
apt-get -y install libcudnn8 libcudnn8-dev
fi
cd -
rm -rf cudnn
Expand Down

0 comments on commit e3f240d

Please sign in to comment.