Skip to content

Commit ebbf718

Browse files
authored
Refactor docker setup (#478)
* remove poetry and simplify docker file * run docker on self hosted for GPU tests * ensure scikit build * updating README * fix: missing scikit-build * adding trt requirement for local tests * revert pyproject.toml to support skbuild automatically again * remove docker from makefile * good luck * einer geht noch * remove requirements.txt deps * solving how to install torch as buidl req * add some magic * update setuptools * upgrade pip * update readme
1 parent 8731e6a commit ebbf718

18 files changed

+127
-737
lines changed

.github/workflows/build.yml

+3-1
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ jobs:
4242
libavformat-dev \
4343
libavcodec-dev \
4444
libswresample-dev \
45-
libavutil-dev\
45+
libavutil-dev \
46+
python3-testresources\
4647
-y
48+
python -mpip install -U setuptools wheel pip
4749
4850
- name: Install dependencies (Windows)
4951
if: ${{ matrix.os == 'windows-2022' }}

.github/workflows/docker.yml

+12-3
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,20 @@ jobs:
1717
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
1818
# You can convert this to a matrix build if you need cross-platform coverage.
1919
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
20-
runs-on: ubuntu-latest
20+
runs-on: self-hosted
2121

2222
steps:
2323
- uses: actions/checkout@v3
2424
- name: Build docker containers
2525
run: |
26-
make vpf-gpu
27-
make vpf-gpu-all
26+
DOCKER_BUILDKIT=1 docker build -f docker/Dockerfile --tag vpf-gpu --build-arg PIP_INSTALL_EXTRAS=torch .
27+
DOCKER_BUILDKIT=1 docker build -f docker/Dockerfile.tensorrt --build-arg PIP_INSTALL_EXTRAS=samples --tag vpf-gpu-trt .
28+
29+
- name: Run tests
30+
run: |
31+
docker run --gpus all --rm -v $(shell pwd):/cwd --entrypoint "python3" vpf-gpu -m unittest discover /repo/tests
32+
33+
- name: Run samples
34+
run: |
35+
docker run --gpus all --rm -v $(shell pwd):/cwd --entrypoint "make" vpf-gpu-trt run_samples_without_docker
36+

.github/workflows/test.yml

+10-8
Original file line numberDiff line numberDiff line change
@@ -23,26 +23,28 @@ jobs:
2323
cd ~/FFmpeg/
2424
./prepare.sh
2525
26-
- name: Setup Poetry
27-
run: poetry install --extras vpf-samples
28-
26+
- name: Setup pip
27+
run: |
28+
python3 -m venv /tmp/venv_vpf
29+
source /tmp/venv_vpf/bin/activate
30+
2931
- name: Build and Install Package
3032
env:
3133
PKG_CONFIG_PATH: /home/gh-runner/FFmpeg/build_x64_release_shared/lib/pkgconfig
3234
CXX: /usr/lib/ccache/c++
3335
CC: /usr/lib/ccache/cc
3436
SKBUILD_CONFIGURE_OPTIONS: "-DCMAKE_CUDA_COMPILER_LAUNCHER=ccache"
3537
run: |
36-
source $(poetry env info --path)/bin/activate
37-
python3 -mpip install . --verbose
38-
pip install src/PytorchNvCodec --verbose
38+
source /tmp/venv_vpf/bin/activate
39+
python3 -mpip install .[samples] --verbose
40+
python3 -mpip install src/PytorchNvCodec --verbose
3941
4042
- name: Run Tests
4143
run: |
42-
source $(poetry env info --path)/bin/activate
44+
source /tmp/venv_vpf/bin/activate
4345
python3 -munittest discover tests
4446
4547
- name: Run Samples
4648
run: |
47-
source $(poetry env info --path)/bin/activate
49+
source /tmp/venv_vpf/bin/activate
4850
make run_samples_without_docker

.gitignore

-7
Original file line numberDiff line numberDiff line change
@@ -104,13 +104,6 @@ ipython_config.py
104104
# install all needed dependencies.
105105
#Pipfile.lock
106106

107-
# poetry
108-
# Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
109-
# This is especially recommended for binary packages to ensure reproducibility, and is more
110-
# commonly ignored for libraries.
111-
# https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
112-
#poetry.lock
113-
114107
# pdm
115108
# Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
116109
#pdm.lock

Makefile

+4-19
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,9 @@
1-
vpf-gpu:
2-
DOCKER_BUILDKIT=1 docker build -f docker/Dockerfile.gpu --tag vpf-gpu .
3-
4-
vpf-gpu-all:
5-
DOCKER_BUILDKIT=1 docker build \
6-
--tag vpf-gpu-all \
7-
-f docker/Dockerfile.gpu \
8-
--build-arg GEN_PYTORCH_EXT=1 \
9-
--build-arg GEN_OPENGL_EXT=1 \
10-
.
11-
12-
run_tests: vpf-gpu
13-
docker run --rm -v $(shell pwd):/repo --entrypoint "python3" vpf-gpu -m unittest discover /repo/tests /repo/tests/test.mp4
14-
15-
run_samples: vpf-gpu-all
16-
docker run --rm -v $(shell pwd):/repo --entrypoint "python3" vpf-gpu-all -m unittest discover /repo/tests /repo/tests/test.mp4
17-
docker run --rm -v $(shell pwd):/repo --workdir /repo --entrypoint "make" vpf-gpu-all run_samples_without_docker
1+
run_tests:
2+
python -m unittest discover tests
183

194
run_samples_without_docker:
205
wget http://www.scikit-video.org/stable/_static/bikes.mp4
21-
6+
227
python ./samples/SampleDecode.py -g 0 -e ./bikes.mp4 -r ./tests/test.raw
238
python ./samples/SampleDecodeSw.py -e ./bikes.mp4 -r ./tests/test.raw
249
python ./samples/SampleEncodeMultiThread.py 0 848 464 ./tests/test.raw 10
@@ -43,7 +28,7 @@ generate-stubs:
4328
stubgen -mPyNvCodec._PyNvCodec
4429
cp out/PyNvCodec/_PyNvCodec.pyi src/PyNvCodec/__init__.pyi
4530

46-
.PHONY: run_tests vpf-gpu generate-stubs
31+
.PHONY: run_tests generate-stubs
4732

4833
# vim:ft=make
4934
#

README.md

+11-11
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
VPF stands for Video Processing Framework. It’s set of C++ libraries and Python bindings which provides full HW acceleration for video processing tasks such as decoding, encoding, transcoding and GPU-accelerated color space and pixel format conversions.
44

5-
VPF also supports exporting GPU memory objects such as decoded video frames to PyTorch tensors without Host to Device copies. Check the [Wiki page](https://github.com/NVIDIA/VideoProcessingFramework/wiki/Building-from-source) on how to build from source.
5+
VPF also supports exporting GPU memory objects such as decoded video frames to PyTorch tensors without Host to Device copies.
66

77
## Prerequisites
88
VPF works on Linux(Ubuntu 20.04 and Ubuntu 22.04 only) and Windows
@@ -61,8 +61,8 @@ please make sure to enable the `video` driver capability: https://docs.nvidia.co
6161
the `NVIDIA_DRIVER_CAPABILITIES` environment variable in the container or the `--gpus` command line parameter (e.g.
6262
`docker run -it --rm --gpus 'all,"capabilities=compute,utility,video"' nvidia/cuda:12.1.0-base-ubuntu22.04`).
6363

64-
Please note that some examples have additional dependencies https://github.com/NVIDIA/VideoProcessingFramework/blob/73a14683a17c8f1c7fa6dd73952f8813bd34a11f/setup.py#L26-L31
65-
that need to be installed via pip. Samples using PyTorch will require an optional extension which can be installed via
64+
Please note that some examples have additional dependencies that need to be installed via pip (`pip install .[samples]`).
65+
Samples using PyTorch will require an optional extension which can be installed via
6666
```bash
6767
pip install src/PytorchNvCodec # install Torch extension if needed (optional), requires "torch" to be installed before
6868
```
@@ -78,15 +78,14 @@ After resolving those you should be able to run `make run_samples_without_docker
7878
```pwsh
7979
# Indicate path to your FFMPEG installation (with subfolders `bin` with DLLs, `include`, `lib`)
8080
$env:SKBUILD_CONFIGURE_OPTIONS="-DTC_FFMPEG_ROOT=C:/path/to/your/ffmpeg/installation/ffmpeg/"
81-
8281
pip install .
8382
```
8483
To check whether VPF is correctly installed run the following Python script
8584
```python
8685
import PyNvCodec
8786
```
88-
Please note that some examples have additional dependencies https://github.com/NVIDIA/VideoProcessingFramework/blob/73a14683a17c8f1c7fa6dd73952f8813bd34a11f/setup.py#L26-L31
89-
that need to be installed via pip. Samples using PyTorch will require an optional extension which can be installed via
87+
Please note that some examples have additional dependencies (`pip install .[sampels]`) that need to be installed via pip.
88+
Samples using PyTorch will require an optional extension which can be installed via
9089

9190
```bash
9291
pip install src/PytorchNvCodec # install Torch extension if needed (optional), requires "torch" to be installed before
@@ -101,14 +100,15 @@ are required)
101100

102101
```bash
103102
DOCKER_BUILDKIT=1 docker build \
104-
--tag vpf-gpu-all \
105-
-f docker/Dockerfile.gpu \
106-
--build-arg GEN_PYTORCH_EXT=1 \
107-
--build-arg GEN_OPENGL_EXT=1 \
103+
--tag vpf-gpu \
104+
-f docker/Dockerfile \
105+
--build-arg PIP_INSTALL_EXTRAS=torch \
108106
.
109-
docker run -it --rm --gpus=all vpf-gpu-all
107+
docker run -it --rm --gpus=all vpf-gpu
110108
```
111109

110+
`PIP_INSTALL_EXTRAS` can be any subset listed under `project.optional-dependencies` in [pyproject.toml](pyproject.toml).
111+
112112
## Documentation
113113

114114
A documentation for Video Processing Framework can be generated from this repository:

docker/Dockerfile

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
FROM nvidia/cuda:12.1.1-devel-ubuntu22.04
2+
3+
ENV NVIDIA_DRIVER_CAPABILITIES=compute,video
4+
5+
RUN apt-get update && DEBIAN_FRONTEND=noninteractive \
6+
apt-get -y install \
7+
libavfilter-dev \
8+
libavformat-dev \
9+
libavcodec-dev \
10+
libswresample-dev \
11+
libavutil-dev\
12+
wget \
13+
build-essential \
14+
ninja-build \
15+
cmake \
16+
git \
17+
python3 \
18+
python3-pip \
19+
python-is-python3
20+
21+
ARG PIP_INSTALL_EXTRAS=""
22+
# Build vpf
23+
RUN mkdir /src
24+
WORKDIR /src
25+
COPY src src
26+
COPY setup.py setup.py
27+
COPY pyproject.toml pyproject.toml
28+
COPY CMakeLists.txt CMakeLists.txt
29+
RUN python3 -m pip install --no-cache-dir setuptools wheel
30+
RUN python3 -m pip install --no-cache-dir .[$PIP_INSTALL_EXTRAS]
31+
32+
RUN mkdir /cwd
33+
WORKDIR /cwd
34+
35+
ENTRYPOINT ["/bin/bash"]

docker/Dockerfile-tensorrt.gpu

-76
This file was deleted.

docker/Dockerfile.gpu

-88
This file was deleted.

0 commit comments

Comments
 (0)