Skip to content

Commit 62a7526

Browse files
committed
ADD: CUDA improvements and libzmq
- Updated cuda-ubuntu Dockerfile to use NVIDIAs CUDA image instead - Updated cuda-ubuntu Dockerfile to build NVIDIAs deviceQuery for automatic compute capability detection - Updated build-ffmpeg to use automatic compute capability - Added libzmq to build-ffmpeg
1 parent b04ad75 commit 62a7526

File tree

3 files changed

+71
-23
lines changed

3 files changed

+71
-23
lines changed

README.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,6 +260,18 @@ $ ls build/lib
260260
libnppc.so.11 libnppicc.so.11 libnppidei.so.11 libnppig.so.11
261261
```
262262
263+
##### Notes on Docker build with CUDA
264+
265+
If you see a "CUDA compute capability could not be found" message during build, first check to see if your GPU device is even available.
266+
In addition, Docker build needs access to CUDA devices to detect your capability version. [some steps](https://stackoverflow.com/a/77348905/7764138) are required on the host machine to allow this access.
267+
268+
1. Install NVIDIA docker runtime and toolkit `sudo apt install nvidia-container-runtime nvidia-container-toolkit`
269+
2. Modify `/etc/docker/daemon.json` and add the line `"default-runtime": "nvidia"`
270+
3. Remove buildx: `sudo apt remove docker-buildx-plugin`
271+
4. Restart Docker: `sudo systemctl restart docker`
272+
5. (Optional but Recommended) If all this doesn't work, also disable buildkit with `export DOCKER_BUILDKIT=0` before building
273+
274+
263275
#### Full static version
264276

265277
If you're running an operating system other than the one above, a completely static build may work. To build a full
@@ -324,7 +336,7 @@ ffmpeg-build-script v1.xx
324336
325337
Using 12 make jobs simultaneously.
326338
With GPL and non-free codecs
327-
339+
CUDA compute capability: 75
328340
building giflib - version 5.2.1
329341
=======================
330342
Downloading https://netcologne.dl.sourceforge.net/project/giflib/giflib-5.2.1.tar.gz as giflib-5.2.1.tar.gz

build-ffmpeg

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,18 @@ if $NONFREE_AND_GPL; then
278278
echo "With GPL and non-free codecs"
279279
fi
280280

281+
# Check CUDA compute capability
282+
if [[ "$OSTYPE" == "linux-gnu" ]]; then
283+
if command_exists "nvcc"; then
284+
export CUDA_COMPUTE_CAPABILITY=$(deviceQuery | grep Capability | head -n 1 | awk 'END {print $NF}' | tr -d '.')
285+
echo "CUDA compute capability: $CUDA_COMPUTE_CAPABILITY"
286+
fi
287+
if [ -z "$CUDA_COMPUTE_CAPABILITY" ]; then
288+
echo "CUDA compute capability could not be found... do you have CUDA access in docker?"
289+
exit 1
290+
fi
291+
fi
292+
281293
if [ -n "$LDEXEFLAGS" ]; then
282294
echo "Start the build in full static mode."
283295
fi
@@ -847,7 +859,7 @@ fi
847859
##
848860

849861
if build "libsdl" "2.28.5"; then
850-
download "https://www.libsdl.org/release/SDL2-$CURRENT_PACKAGE_VERSION.tar.gz"
862+
download "https://github.com/libsdl-org/SDL/releases/download/release-$CURRENT_PACKAGE_VERSION/SDL2-$CURRENT_PACKAGE_VERSION.tar.gz"
851863
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
852864
execute make -j $MJOBS
853865
execute make install
@@ -883,6 +895,20 @@ if $NONFREE_AND_GPL; then
883895
CONFIGURE_OPTIONS+=("--enable-libsrt")
884896
fi
885897

898+
##
899+
## zmq library
900+
##
901+
902+
if build "libzmq" "4.3.5"; then
903+
download "https://github.com/zeromq/libzmq/releases/download/v$CURRENT_PACKAGE_VERSION/zeromq-$CURRENT_PACKAGE_VERSION.tar.gz"
904+
execute ./autogen.sh
905+
execute ./configure --prefix="${WORKSPACE}" --disable-shared --enable-static
906+
execute make -j $MJOBS
907+
execute make install
908+
build_done "libzmq" $CURRENT_PACKAGE_VERSION
909+
CONFIGURE_OPTIONS+=("--enable-libzmq")
910+
fi
911+
886912
##
887913
## HWaccel library
888914
##
@@ -904,7 +930,7 @@ if [[ "$OSTYPE" == "linux-gnu" ]]; then
904930
fi
905931

906932
# https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
907-
CONFIGURE_OPTIONS+=("--nvccflags=-gencode arch=compute_52,code=sm_52")
933+
CONFIGURE_OPTIONS+=("--nvccflags=-gencode arch=compute_$CUDA_COMPUTE_CAPABILITY,code=sm_$CUDA_COMPUTE_CAPABILITY")
908934
else
909935
CONFIGURE_OPTIONS+=("--disable-ffnvcodec")
910936
fi

cuda-ubuntu.dockerfile

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
1-
ARG VER=22.04
1+
ARG CUDAVER=12.2.2
2+
ARG UBUNTUVER=22.04
23

3-
FROM ubuntu:${VER} AS build
4-
5-
ARG CUDAVER=11.8.0-1
4+
FROM nvidia/cuda:${CUDAVER}-devel-ubuntu${UBUNTUVER} as build
65

76
ENV DEBIAN_FRONTEND noninteractive
87
ENV NVIDIA_VISIBLE_DEVICES all
98
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,video
109

11-
RUN apt-get update \
12-
&& apt-get -y --no-install-recommends install wget ca-certificates \
13-
&& update-ca-certificates \
14-
&& wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.0-1_all.deb \
15-
&& dpkg -i cuda-keyring_1.0-1_all.deb \
16-
&& apt-get update
17-
18-
RUN apt-get -y --no-install-recommends install build-essential curl libva-dev python3 python-is-python3 ninja-build meson cmake \
19-
cuda="${CUDAVER}" \
20-
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
10+
RUN apt-get update && \
11+
apt-get upgrade -y && \
12+
apt-get -y --no-install-recommends install \
13+
build-essential \
14+
curl \
15+
libva-dev \
16+
python3 \
17+
python-is-python3 \
18+
ninja-build \
19+
meson \
20+
cmake \
21+
git && \
22+
# clean
23+
apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
24+
25+
# build and move deviceQuery to /usr/bin
26+
RUN mkdir -p /code && \
27+
git clone --depth 1 https://github.com/NVIDIA/cuda-samples.git /code/cuda-samples && \
28+
cd /code/cuda-samples/Samples/1_Utilities/deviceQuery && \
29+
make && \
30+
mv deviceQuery /usr/local/bin
2131

2232
WORKDIR /app
2333
COPY ./build-ffmpeg /app/build-ffmpeg
2434

2535
RUN SKIPINSTALL=yes /app/build-ffmpeg --build --enable-gpl-and-non-free
2636

2737

28-
FROM ubuntu:${VER}
38+
FROM ubuntu:${UBUNTUVER} as release
2939

3040
ENV DEBIAN_FRONTEND noninteractive
3141
ENV NVIDIA_VISIBLE_DEVICES all
@@ -37,11 +47,11 @@ RUN apt-get update \
3747
&& apt-get clean; rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* /usr/share/doc/*
3848

3949
# Copy libnpp
40-
COPY --from=build /usr/local/cuda-11.8/targets/x86_64-linux/lib/libnppc.so.11 /lib/x86_64-linux-gnu/libnppc.so.11
41-
COPY --from=build /usr/local/cuda-11.8/targets/x86_64-linux/lib/libnppig.so.11 /lib/x86_64-linux-gnu/libnppig.so.11
42-
COPY --from=build /usr/local/cuda-11.8/targets/x86_64-linux/lib/libnppicc.so.11 /lib/x86_64-linux-gnu/libnppicc.so.11
43-
COPY --from=build /usr/local/cuda-11.8/targets/x86_64-linux/lib/libnppidei.so.11 /lib/x86_64-linux-gnu/libnppidei.so.11
44-
COPY --from=build /usr/local/cuda-11.8/targets/x86_64-linux/lib/libnppif.so.11 /lib/x86_64-linux-gnu/libnppif.so.11
50+
COPY --from=build /usr/local/cuda/targets/x86_64-linux/lib/libnppc.so /lib/x86_64-linux-gnu/libnppc.so
51+
COPY --from=build /usr/local/cuda/targets/x86_64-linux/lib/libnppig.so /lib/x86_64-linux-gnu/libnppig.so
52+
COPY --from=build /usr/local/cuda/targets/x86_64-linux/lib/libnppicc.so /lib/x86_64-linux-gnu/libnppicc.so
53+
COPY --from=build /usr/local/cuda/targets/x86_64-linux/lib/libnppidei.so /lib/x86_64-linux-gnu/libnppidei.so
54+
COPY --from=build /usr/local/cuda/targets/x86_64-linux/lib/libnppif.so /lib/x86_64-linux-gnu/libnppif.so
4555

4656
# Copy ffmpeg
4757
COPY --from=build /app/workspace/bin/ffmpeg /usr/bin/ffmpeg

0 commit comments

Comments
 (0)