Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Request: [Support for libvmaf_cuda] #2526

Open
nico-lab opened this issue Oct 2, 2023 · 4 comments
Open

Request: [Support for libvmaf_cuda] #2526

nico-lab opened this issue Oct 2, 2023 · 4 comments

Comments

@nico-lab
Copy link

nico-lab commented Oct 2, 2023

Wish to support libvmaf_cuda recently added to FFmpeg.
FFmpeg/FFmpeg@7f685d0

-Denable_float=true -Dbuilt_in_models=true

adding -Denable_cuda=true

Likely error (tail of the failed operation logfile):
Program nasm found: YES (H:\mas\msys64\mingw64\bin/nasm.EXE)
Configuring config.asm using configuration
Program xxd found: YES (H:\mas\msys64\usr\bin/xxd.EXE)
Run-time dependency CUDA (modules: cudart) found: YES 12.2 (C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2)
../src/meson.build:166: WARNING: add_languages is missing native:, assuming languages are wanted for both host and build.
Compiler for language cuda for the build machine not found.

../src/meson.build:166:4: ERROR: Compiler ccache nvcc can not compile programs.

A full log can be found at H:/mas/build/vmaf-git/libvmaf/build-64bit/meson-logs/meson-log.txt
meson failed. Check H:/mas/build/vmaf-git/libvmaf/build-64bit/ab-suite.meson.log
This is required for other packages, so this script will exit.

H:/mas/build/vmaf-git/libvmaf/build-64bit/ab-suite.meson.log
Sanity testing Cuda compiler: ccache nvcc
Is cross compiler: False.
Sanity check compiler command line: ccache nvcc -w -cudart static H:/mas/build/vmaf-git/libvmaf/build-64bit/meson-private/sanitycheckcuda.cu -o H:/mas/build/vmaf-git/libvmaf/build-64bit/meson-private/sanitycheckcuda.exe
Sanity check compile stdout:
nvcc fatal : Failed to preprocess host compiler properties.


Sanity check compile stderr:
Microsoft(R) C/C++ Optimizing Compiler Version 19.25.28612 for x64
Copyright (C) Microsoft Corporation. All rights reserved.

tmpxft_00000f7c_00000000-2.cpp
cl : コマンド ライン error D8027 : 'c1xx' を実行できません


../src/meson.build:166:4: ERROR: Compiler ccache nvcc can not compile programs.

@waldonnis
Copy link
Contributor

I poked at this a little since it's something that's potentially useful to me, but it's not a priority and I have no idea if/when I'll get around to working on it myself. Here are some thoughts, though, in case anyone else has some interest in working on it....

nvcc is really just a compiler driver rather than a compiler itself, and on Windows, it (unfortunately) depends on MS' C++ compiler (cl.exe). This may add to the current CUDA requirements if nvcc is a hard requirement for libvmaf_cuda support. I have Visual Studio and the CUDA Toolkit installed anyway for other projects, so I don't know if not having it breaks anything currently. Probably the best alternative I can think of is trying to use clang/llvm to build the CUDA kernels, but I haven't tried it yet. There's a discussion about it in vmaf's github issues list that I haven't looked at too deeply at that may yield some ideas as far as that goes.

Suite-wise, it looks like do_changeFFmpegConfig() and verify_cuda_deps() handle checking and adding CUDA-related paths to the environment, but that's not called until just before compiling ffmpeg itself (and it's not as simple as just calling those functions earlier). It seems like splitting out the CUDA-related bits into their own, not-ffmpeg-centric function(s) would be ideal. Doing so is not super easy, though, since a lot of what is currently being done in both functions is specific to ffmpeg anyway. IMO, that whole aspect needs to be redesigned to possibly be more generic/abstracted from the current ffmpeg focus or at least written so that it can be performed earlier with no unwanted side effects to the non-ffmpeg parts of the building process.

@nico-lab
Copy link
Author

nico-lab commented Oct 4, 2023

Probably the best alternative I can think of is trying to use clang/llvm to build the CUDA kernels,

Thanks. I'll give it a try.

@nico-lab
Copy link
Author

nico-lab commented Oct 5, 2023

CFLAGS="-msse2 -mfpmath=sse -mstackrealign $CFLAGS" do_mesoninstall video \

delete -mstackrealign $CFLAGS
and set at CC=1 in media-autobuild_suite.ini
but
nvcc fatal : Cannot find compiler 'cl.exe' in PATH
meson-log.txt

@HunterAP23
Copy link

That's because, as waldonnis said, the checks used for adding in CUDA paths comes much later than when libvmaf gets compiled. Without checking and adding the CUDA paths to the environment variables, libvmaf will not compile with CUDA support.

nvcc is really just a compiler driver rather than a compiler itself, and on Windows, it (unfortunately) depends on MS' C++ compiler (cl.exe). This may add to the current CUDA requirements if nvcc is a hard requirement for libvmaf_cuda support. I have Visual Studio and the CUDA Toolkit installed anyway for other projects, so I don't know if not having it breaks anything currently. Probably the best alternative I can think of is trying to use clang/llvm to build the CUDA kernels, but I haven't tried it yet. There's a discussion about it in vmaf's github issues list that I haven't looked at too deeply at that may yield some ideas as far as that goes.

I opened that ticket in the hopes that I could statically compile libvmaf with CUDA support on Windows, rather than through WSL, and then use them in this tool rather than building libvmaf from source due to the exact issues you described. It'll take quite a bit of work that I'm not personally able to do, so the best I can do is wait until a later date. I can offer to do testing and small additions if need be though

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants