ggerganov / llama.cpp

LLM inference in C/C++
MIT License
64.69k stars 9.27k forks source link

Bug: Vulkan build no longer working with MSVC cmake on windows #8562

Closed stduhpf closed 1 month ago

stduhpf commented 1 month ago

What happened?

When trying to build the lastest version of the Vulkan backend, the shader compilation fails.

I suspect commit 17eb6aa8a992cda37ee65cf848d9289bd6cad860 to have introduced the issue, but more testing is required to know for sure.

Name and Version

commit: 3807c3de04cde853418033c95e96642876545f3e cmake flags: -DBUILD_SHARED_LIBS=OFF -DGGML_VULKAN=1 -G "Visual Studio 17 2022" -A x64 MSBuild version: 17.9.8+b34f75857 Vulkan Instance Version: 1.3.261

What operating system are you seeing the problem on?

Windows

Relevant log output

Version MSBuild 17.9.8+b34f75857 pour .NET Framework

[...]

Generate vulkan shaders
  ggml_vulkan: Generating and compiling shaders to SPIR-V
  cannot compile mul_mat_vec_id_f32_f32

  C:/VulkanSDK/1.3.275.0/Bin/glslc.exe -fshader-stage=compute --target-env=vulkan1.2 -O C:/llama cpp/ggml/src/vulkan-shaders\mul_mat_vec.comp -o C:/llama cpp/build/ggml/src/vulkan-shaders.spv\mul_mat_vec_id
  _f32_f32.spv -DB_TYPE=float -DDATA_A_F32=1 -DD_TYPE=float -DFLOAT_TYPE=float -DMUL_MAT_ID=1

glslc : error : linking multiple files is not supported yet. Use -c to compile files individually. [C:\llama cpp\build\ggml\src\ggml.vcxproj]

  cannot compile cannot compile mul_mat_vec_q4_0_f32_f32mul_mat_vec_q4_0_f16_f32

  C:/VulkanSDK/1.3.275.0/Bin/glslc.exe -fshader-stage=compute --target-env=vulkan1.2 -O C:/llama cpp/ggml/src/vulkan-shaders\mul_mat_vec.comp -o C:/llama cpp/build/ggml/src/vulkan-shaders.spv\mul_mat_vec_q4
  _0_f32_f32.spv -DB_TYPE=float -DDATA_A_Q4_0=1 -DD_TYPE=float -DFLOAT_TYPE=float

glslc : error : linking multiple files is not supported yet. Use -c to compile files individually. [C:\llama cpp\build\ggml\src\ggml.vcxproj]

(this goes on for every op, and build crashes with code -1)
stduhpf commented 1 month ago

Just tested again, I can confirm that commit 17eb6aa8a992cda37ee65cf848d9289bd6cad860 (pr https://github.com/ggerganov/llama.cpp/pull/8119) introduced this error.

Utkarsh4430 commented 1 month ago

I am getting some errors related to vulkan shaders as well

[ 2%] Generate vulkan shaders /bin/sh: 1: vulkan-shaders-gen: not found make[2]: [ggml/src/CMakeFiles/ggml.dir/build.make:123: ggml/src/ggml-vulkan-shaders.hpp] Error 127 make[1]: [CMakeFiles/Makefile2:1653: ggml/src/CMakeFiles/ggml.dir/all] Error 2 make: *** [Makefile:146: all] Error 2

FranzKafkaYu commented 1 month ago

I am getting some errors related to vulkan shaders as well

[ 2%] Generate vulkan shaders /bin/sh: 1: vulkan-shaders-gen: not found make[2]: [ggml/src/CMakeFiles/ggml.dir/build.make:123: ggml/src/ggml-vulkan-shaders.hpp] Error 127 make[1]: [CMakeFiles/Makefile2:1653: ggml/src/CMakeFiles/ggml.dir/all] Error 2 make: *** [Makefile:146: all] Error 2

same issue

Utkarsh4430 commented 1 month ago

The error was introduced in this commit: vulkan : cmake integration (https://github.com/ggerganov/llama.cpp/pull/8119[)](https://github.com/ggerganov/llama.cpp/commit/17eb6aa8a992cda37ee65cf848d9289bd6cad860)

The repo compiles for the commit before it: metal : template-ify some of the kernels (https://github.com/ggerganov/llama.cpp/pull/8447[)](https://github.com/ggerganov/llama.cpp/commit/c917b67f06c42d8ca8391b9bc73f5fe62c83bf70)