llama.cpp cmake编译问题解决(error: unknown type name ‘cpu_set_t‘ )

最近在使用cmake对llama.cpp进行交叉编译,以生成linux可执行文件,需要在基于linux的、有安卓环境的设备上运行。之前对于2024年4月30日的llama.cpp版本(GitHub - ggerganov/llama.cpp: LLM inference in C/C++),使用的ndk版本为android-ndk-r20b-windows-x86_64,编译均能正常进行。

今天将本地llama.cpp更新为5月27日的版本后,按往常方法编译时遇到如下报错(摘取部分):

[  0%] Building C object CMakeFiles/ggml.dir/ggml.c.o

D:/llama/llama.cpp/ggml.c:2869:5: error: unknown type name 'cpu_set_t'
    cpu_set_t cpuset; // cpuset from numactl
    ^
D:/llama/llama.cpp/ggml.c:2907:8: error: unknown type name 'cpu_set_t'
static cpu_set_t ggml_get_numa_affinity(void) {
       ^
D:/llama/llama.cpp/ggml.c:2908:5: error: use of undeclared identifier 'cpu_set_t'
    cpu_set_t cpuset;
D:/llama/llama.cpp/ggml.c:2912:5: error: implicit declaration of function
      'pthread_getaffinity_np' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    pthread_getaffinity_np(thread, sizeof(cpu_set_t), &cpuset);
D:/llama/llama.cpp/ggml.c:18964:22: error: implicit declaration of function
      'CPU_ALLOC_SIZE' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    size_t setsize = CPU_ALLOC_SIZE(g_state.numa.total_cpus);
D:/llama/llama.cpp/ggml.c:18989:5: error: implicit declaration of function
      'CPU_ZERO_S' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
    CPU_ZERO_S(setsize, cpus);

出现上述问题后,尝试了github上类似问题的解决方法,尝试了GPT及KIMI的解决建议,例如自行定义cpu_set_t类型、或是对ggml.c的头文件删删改改,都是相同的报错。还尝试把所有涉及"cpu_set_t"的代码都注释掉,但是这样即使编译通过,生成的可执行文件也无法运行。

尝试了其他adb版本,包括r22、r26,都是相同报错。最后试到r21的时候发现编译通过了(android-ndk-r21e-windows-x86_64),生成的可执行文件也可以在终端上正常运行。

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据提供的引用信息,你遇到的问题是在编译过程中出现了错误。具体来说,错误信息是"\k_quants.h(145): error C2059: 语法错误:“)”"。根据提供的引用,这个错误可能是在编译GPU版本的llama.cpp文件时出现的,并且与选项'gpu-architecture'的值为'native'有关。 解决这个问题的步骤如下: 1. 首先,查看编译错误的具体位置,即\k_quants.h文件的第145行。 2. 在该行附近检查代码,查找是否有语法错误,例如缺少分号或括号不匹配等。 3. 如果代码没有明显的语法错误,可以考虑检查编译选项和环境设置是否正确。特别是关于选项'gpu-architecture'的值,确保它被正确定义和使用。 4. 如果是Makefile文件导致的问题,则需要修改Makefile源码,确保编译选项被正确设置。 5. 重新编译代码并进行测试,确保问题已经解决。 请注意,以上步骤仅供参考,具体解决方法可能因个人环境和代码情况而异。建议仔细检查错误信息和相关代码,结合实际情况采取相应的解决措施。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *3* [【AI实战】llama.cpp量化cuBLAS编译;nvcc fatal:Value ‘native‘ is not defined for option ‘gpu-...](https://blog.csdn.net/zengNLP/article/details/131576986)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] - *2* [ubuntu下编译时遇到的错误及解决方式](https://blog.csdn.net/weixin_30267691/article/details/94986381)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值