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

Windows cmake failed compile for rocm #6972

Closed
sorasoras opened this issue Apr 29, 2024 · 9 comments · Fixed by #7029
Closed

Windows cmake failed compile for rocm #6972

sorasoras opened this issue Apr 29, 2024 · 9 comments · Fixed by #7029

Comments

@sorasoras
Copy link

sorasoras commented Apr 29, 2024

#6797 (comment)

@a-downing
Copy link
Contributor

I have the same error building on Windows with ROCm.

@a-downing
Copy link
Contributor

[1/81] Linking CXX static library llama.lib
[2/81] Linking CXX static library ggml_static.lib
[3/81] Linking CXX static library common\common.lib
[4/81] Linking CXX executable bin\test-c.exe
[5/81] Linking CXX executable bin\test-tokenizer-0.exe
[6/81] Linking CXX executable bin\test-tokenizer-1-bpe.exe
[7/81] Linking CXX executable bin\test-tokenizer-1-spm.exe
[8/81] Linking CXX executable bin\test-quantize-fns.exe
[9/81] Linking CXX executable bin\test-quantize-perf.exe
[10/81] Linking CXX executable bin\test-sampling.exe
[11/81] Linking CXX executable bin\test-chat-template.exe
[12/81] Linking CXX executable bin\test-grammar-parser.exe
[13/81] Linking CXX executable bin\test-llama-grammar.exe
[14/81] Linking CXX executable bin\test-grammar-integration.exe
[15/81] Linking CXX executable bin\test-grad0.exe
[16/81] Building CXX object examples/llava/CMakeFiles/llava-cli.dir/llava-cli.cpp.obj
FAILED: examples/llava/CMakeFiles/llava-cli.dir/llava-cli.cpp.obj 
ccache C:\PROGRA~1\AMD\ROCm\5.7\bin\CLANG_~1.EXE -DGGML_CUDA_DMMV_X=32 -DGGML_CUDA_MMV_Y=1 -DGGML_SCHED_MAX_COPIES=4 -DGGML_USE_CUDA -DGGML_USE_HIPBLAS -DGGML_USE_LLAMAFILE -DK_QUANTS_PER_ITERATION=2 -D_CRT_SECURE_NO_WARNINGS -D_XOPEN_SOURCE=600 -D__HIP_PLATFORM_AMD__=1 -D__HIP_PLATFORM_HCC__=1 -IC:/Users/andre/Desktop/development/llama.cpp/examples -IC:/Users/andre/Desktop/development/llama.cpp/common/. -IC:/Users/andre/Desktop/development/llama.cpp/. -IC:/Users/andre/Desktop/development/llama.cpp/examples/llava/. -IC:/Users/andre/Desktop/development/llama.cpp/examples/llava/../.. -IC:/Users/andre/Desktop/development/llama.cpp/examples/llava/../../common -isystem "C:/Program Files/AMD/ROCm/5.7/include" -O3 -DNDEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrt -std=gnu++14 -Wmissing-declarations -Wmissing-noreturn -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wunreachable-code-break -Wunreachable-code-return -Wmissing-prototypes -Wextra-semi -march=native -MD -MT examples/llava/CMakeFiles/llava-cli.dir/llava-cli.cpp.obj -MF examples\llava\CMakeFiles\llava-cli.dir\llava-cli.cpp.obj.d -o examples/llava/CMakeFiles/llava-cli.dir/llava-cli.cpp.obj -c C:/Users/andre/Desktop/development/llama.cpp/examples/llava/llava-cli.cpp
In file included from C:/Users/andre/Desktop/development/llama.cpp/examples/llava/llava-cli.cpp:2:
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:300:48: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
    #define LOG(str, ...) LOG_IMPL("%s" str, "", ##__VA_ARGS__, "")
                                               ^
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:251:106: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
            fprintf(LOG_TARGET, LOG_TIMESTAMP_FMT LOG_FLF_FMT str "%s" LOG_TIMESTAMP_VAL LOG_FLF_VAL "", ##__VA_ARGS__); \
                                                                                                         ^
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:467:5: error: expected ')'
    LOG("01 Hello World to nobody, because logs are disabled!\n");
    ^
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:300:27: note: expanded from macro 'LOG'
    #define LOG(str, ...) LOG_IMPL("%s" str, "", ##__VA_ARGS__, "")
                          ^
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:251:102: note: expanded from macro 'LOG_IMPL'
            fprintf(LOG_TARGET, LOG_TIMESTAMP_FMT LOG_FLF_FMT str "%s" LOG_TIMESTAMP_VAL LOG_FLF_VAL "", ##__VA_ARGS__); \
                                                                                                     ^
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:467:5: note: to match this '('
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:300:27: note: expanded from macro 'LOG'
    #define LOG(str, ...) LOG_IMPL("%s" str, "", ##__VA_ARGS__, "")
                          ^
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:251:20: note: expanded from macro 'LOG_IMPL'
            fprintf(LOG_TARGET, LOG_TIMESTAMP_FMT LOG_FLF_FMT str "%s" LOG_TIMESTAMP_VAL LOG_FLF_VAL "", ##__VA_ARGS__); \
                   ^
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:300:50: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
    #define LOG(str, ...) LOG_IMPL("%s" str, "", ##__VA_ARGS__, "")
                                                 ^
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:251:106: warning: token pasting of ',' and __VA_ARGS__ is a GNU extension [-Wgnu-zero-variadic-macro-arguments]
            fprintf(LOG_TARGET, LOG_TIMESTAMP_FMT LOG_FLF_FMT str "%s" LOG_TIMESTAMP_VAL LOG_FLF_VAL "", ##__VA_ARGS__); \
                                                                                                         ^
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:469:5: error: expected ')'
    LOG("02 Hello World to default output, which is \"%s\" ( Yaaay, arguments! )!\n", LOG_STRINGIZE(LOG_TARGET));

@a-downing
Copy link
Contributor

I compiled that file with the -E flag to get the preprocessed output. This is where the error occurs:

do { if (log_handler() != nullptr) { fprintf(log_handler(), "[%" "llu" "] " "[%24s:%5ld][%24s] " "%s" "01 Hello World to nobody, because logs are disabled!\n" "%s" , (std::chrono::duration_cast<std::chrono::duration<std::uint64_t>>(std::chrono::system_clock::now().time_since_epoch())).count() , "C:/Users/andre/Desktop/development/llama.cpp/common/.\\log.h", 467, __FUNCTION__ "", "", ""); fflush(log_handler()); } } while (0);

And tried compiling the preprocessed output:

C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:467:383: error: expected ')'
  ..., "C:/Users/andre/Desktop/development/llama.cpp/common/.\\log.h", 467, __FUNCTION__ "", "", ""); fflush(log_hand...
                                                                                         ^
C:/Users/andre/Desktop/development/llama.cpp/common/.\log.h:467:49: note: to match this '('
    do { if (log_handler() != nullptr) { fprintf(log_handler(), "[%" "llu" "] " "[%24s:%5ld][%24s] " "%s" "01 He...

@slaren
Copy link
Member

slaren commented Apr 30, 2024

Does it work with __func__ instead of __FUNCTION__? I am not sure what is special about the rocm compiler, it works with normal clang.

@a-downing
Copy link
Contributor

Nope, same error.

@a-downing
Copy link
Contributor

I was able to work around this for now by adding #define LOG_NO_FILE_LINE_FUNCTION to the top of log.h

@slaren
Copy link
Member

slaren commented Apr 30, 2024

I suspect that the issue is that the rocm compiler pretends to be MSVC and defines _MSC_VER, and this enables a workaround in log.h that is only meant to be enabled in MSVC.

https://rocm.docs.amd.com/en/docs-5.5.1/reference/rocmcc/rocmcc.html
image

So maybe this can be fixed by adding a || defined(__clang__) here:
https://github.com/ggerganov/llama.cpp/blob/77e15bec6217a39be59b9cc83d6b9afb6b0d8167/common/log.h#L237-L255

@a-downing
Copy link
Contributor

Adding that there and to the corresponding location for LOG_TEE_IMPL did indeed fix the issue.

@slaren
Copy link
Member

slaren commented Apr 30, 2024

Cool, feel free to open a PR.

a-downing added a commit to a-downing/llama.cpp that referenced this issue May 1, 2024
ROCm clang defines _MSC_VER which results in the wrong implementation of LOG_IMPL and LOG_TEE_IMPL being compiled.

This fixes ggml-org#6972
slaren pushed a commit that referenced this issue May 1, 2024
ROCm clang defines _MSC_VER which results in the wrong implementation of LOG_IMPL and LOG_TEE_IMPL being compiled.

This fixes #6972
nopperl pushed a commit to nopperl/llama.cpp that referenced this issue May 5, 2024
ROCm clang defines _MSC_VER which results in the wrong implementation of LOG_IMPL and LOG_TEE_IMPL being compiled.

This fixes ggml-org#6972
teleprint-me pushed a commit to teleprint-me/llama.cpp that referenced this issue May 7, 2024
ROCm clang defines _MSC_VER which results in the wrong implementation of LOG_IMPL and LOG_TEE_IMPL being compiled.

This fixes ggml-org#6972
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants