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

ggml : do not use _GNU_SOURCE gratuitously #1992

Closed
wants to merge 1 commit into from
Closed

Conversation

ggerganov
Copy link
Member

@ggerganov
Copy link
Member Author

@przemoc

I'm trying to apply the _GNU_SOURCE patch from whisper.cpp but hitting the following error on MacOS:

In file included from llama.cpp:9:
./llama-util.h:189:63: error: use of undeclared identifier 'MADV_WILLNEED'
            if (madvise(addr, std::min(file->size, prefetch), MADV_WILLNEED)) {
                                                              ^
./llama-util.h:316:38: error: use of undeclared identifier 'RLIMIT_MEMLOCK'
            if (suggest && getrlimit(RLIMIT_MEMLOCK, &lock_limit))
                                     ^
2 errors generated.
make: *** [llama.o] Error 1
Error: Process completed with exit code 2.

Any ideas how to resolve?

@przemoc
Copy link
Contributor

przemoc commented Jun 25, 2023

Sorry, I will be momentarily afk for rest of the day, so cannot help much.

I would need to look into llama.cpp, but madvise() typically can be replaced with more portable posix_madvise() and MADV_WILLNEED with analogous POSIX_MADV_WILLNEED (unless you sometimes use in the code also advice that is not defined by POSIX.1).

getrlimit() is slightly different case, because you use resource RLIMIT_MEMLOCK that is not defined by POSIX.1 (even if you would look at the latest POSIX.1-2017), it comes from BSD. You may check if having _BSD_SOURCE additionally defined (-D_BSD_SOURCE after already defined -D_XOPEN_SOURCE=600) helps for macOS.

@przemoc
Copy link
Contributor

przemoc commented Jun 28, 2023

@ggerganov, see my attempt for llama.cpp in #2035. Please run CI checks there, because for macOS I'm kind of working in the dark. ;)

@przemoc
Copy link
Contributor

przemoc commented Jul 22, 2023

As we're dealing with this topic in my PR #2035 for llama.cpp, I think you may close your own PR #1992 (that was based on my initial attempt at whisper.cpp) to declutter PR space. :)

@ggerganov ggerganov closed this Jul 22, 2023
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

Successfully merging this pull request may close these issues.

2 participants