styler00dollar / VSGAN-tensorrt-docker

Using VapourSynth with super resolution and interpolation models and speeding them up with TensorRT.
BSD 3-Clause "New" or "Revised" License
288 stars 30 forks source link

Python exception: operator(): bits per sample mismatch #66

Closed mtuub closed 9 months ago

mtuub commented 9 months ago

Hello, i'm trying to run TRT inference using the minimal config https://github.com/styler00dollar/VSGAN-tensorrt-docker/blob/main/inference_config_minimal.py on the styler00dollar/vsgan_tensorrt:minimal docker image, but getting the error before:

vspipe -c y4m inference.py - | ffmpeg -i pipe: out.mp4 -y

ffmpeg version N-112456-g90d327d607 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 13.2.1 (GCC) 20230801
  configuration: --extra-cflags='-fopenmp -lcrypto -lz -ldl -static-libgcc -I/opt/cuda/include' --extra-cxxflags='-fopenmp -lcrypto -lz -ldl -static-libgcc' --extra-ldflags='-fopenmp -lcrypto -lz -ldl -static-libgcc -L/opt/cuda/lib64' --extra-libs='-lstdc++ -lcrypto -lz -ldl -static-libgcc' --pkg-config-flags=--static --toolchain=hardened --disable-debug --disable-shared --disable-ffplay --enable-static --enable-gpl --enable-gray --enable-nonfree --enable-openssl --enable-iconv --enable-libxml2 --enable-libmp3lame --enable-libfdk-aac --enable-libvorbis --enable-libopus --enable-libtheora --enable-libvpx --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libaom --enable-libvidstab --enable-libkvazaar --enable-libfreetype --enable-fontconfig --enable-libfribidi --enable-libass --enable-libsoxr --enable-libopenjpeg --enable-libdav1d --enable-librav1e --enable-libsrt --enable-libsvtav1 --enable-libdavs2 --enable-libxavs2 --enable-libvmaf --enable-cuda-nvcc --enable-vapoursynth --enable-libopenh264 --enable-optimizations --enable-cuda-llvm --enable-nvdec --enable-nvenc --enable-cuvid --enable-cuda --enable-pthreads --enable-runtime-cpudetect --enable-lto
  libavutil      58. 27.100 / 58. 27.100
  libavcodec     60. 30.102 / 60. 30.102
  libavformat    60. 15.100 / 60. 15.100
  libavdevice    60.  2.101 / 60.  2.101
  libavfilter     9. 11.100 /  9. 11.100
  libswscale      7.  4.100 /  7.  4.100
  libswresample   4. 11.100 /  4. 11.100
  libpostproc    57.  2.100 / 57.  2.100
Creating lwi index file 100%
Script evaluation failed:
Python exception: operator(): bits per sample mismatch

Traceback (most recent call last):
  File "src/cython/vapoursynth.pyx", line 3121, in vapoursynth._vpy_evaluate
  File "src/cython/vapoursynth.pyx", line 3122, in vapoursynth._vpy_evaluate
  File "inference.py", line 10, in <module>
    clip = inference_clip(video_path)
  File "/workspace/tensorrt/inference_config.py", line 18, in inference_clip
    clip = core.trt.Model(
  File "src/cython/vapoursynth.pyx", line 2857, in vapoursynth.Function.__call__
vapoursynth.Error: operator(): bits per sample mismatch

I also tried to build the minimal docker image, but it fails:

 => ERROR [ffmpeg-arch 43/43] RUN cd FFmpeg &&   PKG_CONFIG_PATH=/usr/  19.2s

 > [ffmpeg-arch 43/43] RUN cd FFmpeg &&   PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/home/makepkg/ssl/lib64/pkgconfig/ ./configure     --extra-cflags="-fopenmp -lcrypto -lz -ldl -static-libgcc -I/opt/cuda/include"     --extra-cxxflags="-fopenmp -lcrypto -lz -ldl -static-libgcc"     --extra-ldflags="-fopenmp -lcrypto -lz -ldl -static-libgcc -L/opt/cuda/lib64"     --extra-libs="-lstdc++ -lcrypto -lz -ldl -static-libgcc"     --pkg-config-flags=--static     --toolchain=hardened     --disable-debug     --disable-shared     --disable-ffplay     --enable-static     --enable-gpl     --enable-gray     --enable-nonfree     --enable-openssl     --enable-iconv     --enable-libxml2     --enable-libmp3lame     --enable-libfdk-aac     --enable-libvorbis     --enable-libopus     --enable-libtheora     --enable-libvpx     --enable-libx264     --enable-libx265     --enable-libwebp     --enable-libspeex     --enable-libaom     --enable-libvidstab     --enable-libkvazaar     --enable-libfreetype     --enable-fontconfig     --enable-libfribidi     --enable-libass     --enable-libsoxr     --enable-libopenjpeg     --enable-libdav1d     --enable-librav1e     --enable-libsrt     --enable-libsvtav1     --enable-libdavs2     --enable-libxavs2     --enable-libvmaf     --enable-cuda-nvcc     --enable-vapoursynth     --enable-libopenh264     --enable-optimizations     --enable-cuda-llvm     --enable-nvdec     --enable-nvenc     --enable-cuvid     --enable-cuda     --enable-pthreads     --enable-runtime-cpudetect     --enable-lto &&     make -j$(nproc):
19.17 ERROR: failed checking for nvcc.
19.17 
19.17 If you think configure made a mistake, make sure you are using the latest
19.17 version from Git.  If the latest version fails, report the problem to the
19.17 ffmpeg-user@ffmpeg.org mailing list or IRC #ffmpeg on irc.libera.chat.
19.18 Include the log file "ffbuild/config.log" produced by configure as this will help
19.18 solve the problem.
------
Dockerfile:168
--------------------
 167 |     RUN git clone https://github.com/FFmpeg/FFmpeg
 168 | >>> RUN cd FFmpeg && \
 169 | >>>   PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/home/makepkg/ssl/lib64/pkgconfig/ ./configure \
 170 | >>>     --extra-cflags="-fopenmp -lcrypto -lz -ldl -static-libgcc -I/opt/cuda/include" \
 171 | >>>     --extra-cxxflags="-fopenmp -lcrypto -lz -ldl -static-libgcc" \
 172 | >>>     --extra-ldflags="-fopenmp -lcrypto -lz -ldl -static-libgcc -L/opt/cuda/lib64" \
 173 | >>>     --extra-libs="-lstdc++ -lcrypto -lz -ldl -static-libgcc" \
 174 | >>>     --pkg-config-flags=--static \
 175 | >>>     --toolchain=hardened \
 176 | >>>     --disable-debug \
 177 | >>>     --disable-shared \
 178 | >>>     --disable-ffplay \
 179 | >>>     --enable-static \
 180 | >>>     --enable-gpl \
 181 | >>>     --enable-gray \
 182 | >>>     --enable-nonfree \
 183 | >>>     --enable-openssl \
 184 | >>>     --enable-iconv \
 185 | >>>     --enable-libxml2 \
 186 | >>>     --enable-libmp3lame \
 187 | >>>     --enable-libfdk-aac \
 188 | >>>     --enable-libvorbis \
 189 | >>>     --enable-libopus \
 190 | >>>     --enable-libtheora \
 191 | >>>     --enable-libvpx \
 192 | >>>     --enable-libx264 \
 193 | >>>     --enable-libx265 \
 194 | >>>     --enable-libwebp \
 195 | >>>     --enable-libspeex \
 196 | >>>     --enable-libaom \
 197 | >>>     --enable-libvidstab \
 198 | >>>     --enable-libkvazaar \
 199 | >>>     --enable-libfreetype \
 200 | >>>     --enable-fontconfig \
 201 | >>>     --enable-libfribidi \
 202 | >>>     --enable-libass \
 203 | >>>     --enable-libsoxr \
 204 | >>>     --enable-libopenjpeg \
 205 | >>>     --enable-libdav1d \
 206 | >>>     --enable-librav1e \
 207 | >>>     --enable-libsrt \
 208 | >>>     --enable-libsvtav1 \
 209 | >>>     --enable-libdavs2 \
 210 | >>>     --enable-libxavs2 \
 211 | >>>     --enable-libvmaf \
 212 | >>>     --enable-cuda-nvcc \
 213 | >>>     --enable-vapoursynth \
 214 | >>>     #--enable-hardcoded-tables \
 215 | >>>     --enable-libopenh264 \
 216 | >>>     --enable-optimizations \
 217 | >>>     --enable-cuda-llvm \
 218 | >>>     --enable-nvdec \
 219 | >>>     --enable-nvenc \
 220 | >>>     --enable-cuvid \
 221 | >>>     --enable-cuda \
 222 | >>>     --enable-pthreads \
 223 | >>>     --enable-runtime-cpudetect \
 224 | >>>     --enable-lto && \
 225 | >>>     make -j$(nproc)
 226 |     
--------------------
ERROR: failed to solve: process "/bin/sh -c cd FFmpeg &&   PKG_CONFIG_PATH=/usr/local/lib/pkgconfig/:/home/makepkg/ssl/lib64/pkgconfig/ ./configure     --extra-cflags=\"-fopenmp -lcrypto -lz -ldl -static-libgcc -I/opt/cuda/include\"     --extra-cxxflags=\"-fopenmp -lcrypto -lz -ldl -static-libgcc\"     --extra-ldflags=\"-fopenmp -lcrypto -lz -ldl -static-libgcc -L/opt/cuda/lib64\"     --extra-libs=\"-lstdc++ -lcrypto -lz -ldl -static-libgcc\"     --pkg-config-flags=--static     --toolchain=hardened     --disable-debug     --disable-shared     --disable-ffplay     --enable-static     --enable-gpl     --enable-gray     --enable-nonfree     --enable-openssl     --enable-iconv     --enable-libxml2     --enable-libmp3lame     --enable-libfdk-aac     --enable-libvorbis     --enable-libopus     --enable-libtheora     --enable-libvpx     --enable-libx264     --enable-libx265     --enable-libwebp     --enable-libspeex     --enable-libaom     --enable-libvidstab     --enable-libkvazaar     --enable-libfreetype     --enable-fontconfig     --enable-libfribidi     --enable-libass     --enable-libsoxr     --enable-libopenjpeg     --enable-libdav1d     --enable-librav1e     --enable-libsrt     --enable-libsvtav1     --enable-libdavs2     --enable-libxavs2     --enable-libvmaf     --enable-cuda-nvcc     --enable-vapoursynth     --enable-libopenh264     --enable-optimizations     --enable-cuda-llvm     --enable-nvdec     --enable-nvenc     --enable-cuvid     --enable-cuda     --enable-pthreads     --enable-runtime-cpudetect     --enable-lto &&     make -j$(nproc)" did not complete successfully: exit code: 1
mafiosnik777 commented 9 months ago

You're using an fp32 model with RGBH or an fp16 model with RGBS. You need to adjust accordingly.

styler00dollar commented 9 months ago

Mismatch of precision like @mafiosnik777 said. Use RGBS for fp32 and RGBH for fp16. The input will depend on your onnx file, but you can also overwrite it with trtexec by doing --inputIOFormats=fp16:chw --outputIOFormats=fp16:chw.