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

undefined reference to ggml_new_tensor_1d' ggml_new_tensor_2d' #15

Closed
yuxuan2015 opened this issue Mar 30, 2023 · 5 comments
Closed

undefined reference to ggml_new_tensor_1d' ggml_new_tensor_2d' #15

yuxuan2015 opened this issue Mar 30, 2023 · 5 comments

Comments

@yuxuan2015
Copy link

yuxuan2015 commented Mar 30, 2023

运行 make chat 命令报错如下:
g++ chat.cpp -o chat
/usr/bin/ld: /tmp/ccCnl7Fq.o: in function llama_model_load(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, llama_model&, gpt_vocab&, int)': chat.cpp:(.text+0x62c): undefined reference to ggml_type_sizef'
/usr/bin/ld: chat.cpp:(.text+0x6cc): undefined reference to ggml_type_sizef' /usr/bin/ld: chat.cpp:(.text+0x778): undefined reference to ggml_type_sizef'
/usr/bin/ld: chat.cpp:(.text+0x828): undefined reference to ggml_type_sizef' /usr/bin/ld: chat.cpp:(.text+0x8e8): undefined reference to ggml_type_sizef'
/usr/bin/ld: /tmp/ccCnl7Fq.o:chat.cpp:(.text+0x9a8): more undefined references to ggml_type_sizef' follow /usr/bin/ld: /tmp/ccCnl7Fq.o: in function llama_model_load(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, llama_model&, gpt_vocab&, int)':
chat.cpp:(.text+0x10cb): undefined reference to ggml_init' /usr/bin/ld: chat.cpp:(.text+0x11a1): undefined reference to ggml_new_tensor_2d'
/usr/bin/ld: chat.cpp:(.text+0x11c9): undefined reference to ggml_new_tensor_1d' /usr/bin/ld: chat.cpp:(.text+0x11f8): undefined reference to ggml_new_tensor_2d'
/usr/bin/ld: chat.cpp:(.text+0x13c0): undefined reference to ggml_new_tensor_1d' /usr/bin/ld: chat.cpp:(.text+0x13ee): undefined reference to ggml_new_tensor_2d'
/usr/bin/ld: chat.cpp:(.text+0x141d): undefined reference to ggml_new_tensor_2d' /usr/bin/ld: chat.cpp:(.text+0x144c): undefined reference to ggml_new_tensor_2d'
/usr/bin/ld: chat.cpp:(.text+0x147b): undefined reference to ggml_new_tensor_2d' /usr/bin/ld: chat.cpp:(.text+0x14a3): undefined reference to ggml_new_tensor_1d'
/usr/bin/ld: chat.cpp:(.text+0x14d2): undefined reference to ggml_new_tensor_2d' /usr/bin/ld: chat.cpp:(.text+0x1501): undefined reference to ggml_new_tensor_2d'
/usr/bin/ld: chat.cpp:(.text+0x1530): undefined reference to ggml_new_tensor_2d' /usr/bin/ld: chat.cpp:(.text+0x1bd3): undefined reference to ggml_new_tensor_1d'
/usr/bin/ld: chat.cpp:(.text+0x1bfb): undefined reference to ggml_new_tensor_1d' /usr/bin/ld: chat.cpp:(.text+0x1c19): undefined reference to ggml_nbytes'
/usr/bin/ld: chat.cpp:(.text+0x1c2f): undefined reference to ggml_nbytes' /usr/bin/ld: chat.cpp:(.text+0x2325): undefined reference to ggml_nelements'
/usr/bin/ld: chat.cpp:(.text+0x238c): undefined reference to ggml_nelements' /usr/bin/ld: chat.cpp:(.text+0x2659): undefined reference to ggml_type_size'
/usr/bin/ld: chat.cpp:(.text+0x266f): undefined reference to ggml_type_size' /usr/bin/ld: chat.cpp:(.text+0x2685): undefined reference to ggml_type_size'
/usr/bin/ld: chat.cpp:(.text+0x26c6): undefined reference to ggml_type_size' /usr/bin/ld: chat.cpp:(.text+0x2772): undefined reference to ggml_blck_size'
/usr/bin/ld: chat.cpp:(.text+0x2792): undefined reference to ggml_nbytes' /usr/bin/ld: chat.cpp:(.text+0x27be): undefined reference to ggml_nbytes'
/usr/bin/ld: chat.cpp:(.text+0x2826): undefined reference to ggml_nbytes' /usr/bin/ld: chat.cpp:(.text+0x285a): undefined reference to ggml_nbytes'
/usr/bin/ld: chat.cpp:(.text+0x2883): undefined reference to ggml_nbytes' /usr/bin/ld: chat.cpp:(.text+0x28b2): undefined reference to ggml_blck_size'
/usr/bin/ld: chat.cpp:(.text+0x28d2): undefined reference to ggml_nbytes' /usr/bin/ld: chat.cpp:(.text+0x2913): undefined reference to ggml_nbytes'
/usr/bin/ld: chat.cpp:(.text+0x29a8): undefined reference to ggml_blck_size' /usr/bin/ld: chat.cpp:(.text+0x29c3): undefined reference to ggml_type_size'
/usr/bin/ld: chat.cpp:(.text+0x2a57): undefined reference to ggml_blck_size' /usr/bin/ld: chat.cpp:(.text+0x2a72): undefined reference to ggml_type_size'
/usr/bin/ld: chat.cpp:(.text+0x2b06): undefined reference to ggml_blck_size' /usr/bin/ld: chat.cpp:(.text+0x2b21): undefined reference to ggml_type_size'
/usr/bin/ld: chat.cpp:(.text+0x2bb8): undefined reference to ggml_nbytes' /usr/bin/ld: /tmp/ccCnl7Fq.o: in function llama_eval(llama_model const&, int, int, std::vector<int, std::allocator > const&, std::vector<float, std::allocator >&, unsigned long&)':
chat.cpp:(.text+0x34ae): undefined reference to ggml_init' /usr/bin/ld: chat.cpp:(.text+0x34f4): undefined reference to ggml_new_tensor_1d'
/usr/bin/ld: chat.cpp:(.text+0x3513): undefined reference to ggml_element_size' /usr/bin/ld: chat.cpp:(.text+0x3569): undefined reference to ggml_get_rows'
/usr/bin/ld: chat.cpp:(.text+0x35b3): undefined reference to ggml_rms_norm' /usr/bin/ld: chat.cpp:(.text+0x35f4): undefined reference to ggml_repeat'
/usr/bin/ld: chat.cpp:(.text+0x3610): undefined reference to ggml_mul' /usr/bin/ld: chat.cpp:(.text+0x3652): undefined reference to ggml_mul_mat'
/usr/bin/ld: chat.cpp:(.text+0x3694): undefined reference to ggml_mul_mat' /usr/bin/ld: chat.cpp:(.text+0x36d6): undefined reference to ggml_mul_mat'
/usr/bin/ld: chat.cpp:(.text+0x36fd): undefined reference to ggml_element_size' /usr/bin/ld: chat.cpp:(.text+0x3753): undefined reference to ggml_view_1d'
/usr/bin/ld: chat.cpp:(.text+0x376d): undefined reference to ggml_element_size' /usr/bin/ld: chat.cpp:(.text+0x37c3): undefined reference to ggml_view_1d'
/usr/bin/ld: chat.cpp:(.text+0x37ea): undefined reference to ggml_cpy' /usr/bin/ld: chat.cpp:(.text+0x37ff): undefined reference to ggml_build_forward_expand'
/usr/bin/ld: chat.cpp:(.text+0x381f): undefined reference to ggml_cpy' /usr/bin/ld: chat.cpp:(.text+0x3834): undefined reference to ggml_build_forward_expand'
/usr/bin/ld: chat.cpp:(.text+0x386a): undefined reference to ggml_new_tensor_3d' /usr/bin/ld: chat.cpp:(.text+0x3886): undefined reference to ggml_cpy'
/usr/bin/ld: chat.cpp:(.text+0x38aa): undefined reference to ggml_rope' /usr/bin/ld: chat.cpp:(.text+0x38d2): undefined reference to ggml_permute'
/usr/bin/ld: chat.cpp:(.text+0x391c): undefined reference to ggml_element_size' /usr/bin/ld: chat.cpp:(.text+0x3963): undefined reference to ggml_view_1d'
/usr/bin/ld: chat.cpp:(.text+0x3983): undefined reference to ggml_reshape_3d' /usr/bin/ld: chat.cpp:(.text+0x39a7): undefined reference to ggml_rope'
/usr/bin/ld: chat.cpp:(.text+0x39cf): undefined reference to ggml_permute' /usr/bin/ld: chat.cpp:(.text+0x39f6): undefined reference to ggml_mul_mat'
/usr/bin/ld: chat.cpp:(.text+0x3a3d): undefined reference to ggml_new_f32' /usr/bin/ld: chat.cpp:(.text+0x3a59): undefined reference to ggml_scale'
/usr/bin/ld: chat.cpp:(.text+0x3a7f): undefined reference to ggml_diag_mask_inf' /usr/bin/ld: chat.cpp:(.text+0x3a9f): undefined reference to ggml_soft_max'
/usr/bin/ld: chat.cpp:(.text+0x3ae9): undefined reference to ggml_element_size' /usr/bin/ld: chat.cpp:(.text+0x3b30): undefined reference to ggml_view_1d'
/usr/bin/ld: chat.cpp:(.text+0x3b50): undefined reference to ggml_reshape_3d' /usr/bin/ld: chat.cpp:(.text+0x3b78): undefined reference to ggml_permute'
/usr/bin/ld: chat.cpp:(.text+0x3b9f): undefined reference to ggml_mul_mat' /usr/bin/ld: chat.cpp:(.text+0x3bd2): undefined reference to ggml_permute'
/usr/bin/ld: chat.cpp:(.text+0x3bf9): undefined reference to ggml_new_tensor_2d' /usr/bin/ld: chat.cpp:(.text+0x3c15): undefined reference to ggml_cpy'
/usr/bin/ld: chat.cpp:(.text+0x3c57): undefined reference to ggml_mul_mat' /usr/bin/ld: chat.cpp:(.text+0x3c7e): undefined reference to ggml_add'
/usr/bin/ld: chat.cpp:(.text+0x3c9e): undefined reference to ggml_rms_norm' /usr/bin/ld: chat.cpp:(.text+0x3ce0): undefined reference to ggml_repeat'
/usr/bin/ld: chat.cpp:(.text+0x3cfc): undefined reference to ggml_mul' /usr/bin/ld: chat.cpp:(.text+0x3d3e): undefined reference to ggml_mul_mat'
/usr/bin/ld: chat.cpp:(.text+0x3d80): undefined reference to ggml_mul_mat' /usr/bin/ld: chat.cpp:(.text+0x3da0): undefined reference to ggml_silu'
/usr/bin/ld: chat.cpp:(.text+0x3dc7): undefined reference to ggml_mul' /usr/bin/ld: chat.cpp:(.text+0x3e09): undefined reference to ggml_mul_mat'
/usr/bin/ld: chat.cpp:(.text+0x3e30): undefined reference to ggml_add' /usr/bin/ld: chat.cpp:(.text+0x3e6a): undefined reference to ggml_rms_norm'
/usr/bin/ld: chat.cpp:(.text+0x3e95): undefined reference to ggml_repeat' /usr/bin/ld: chat.cpp:(.text+0x3eb1): undefined reference to ggml_mul'
/usr/bin/ld: chat.cpp:(.text+0x3edc): undefined reference to ggml_mul_mat' /usr/bin/ld: chat.cpp:(.text+0x3efc): undefined reference to ggml_build_forward_expand'
/usr/bin/ld: chat.cpp:(.text+0x3f15): undefined reference to ggml_graph_compute' /usr/bin/ld: chat.cpp:(.text+0x3f4f): undefined reference to ggml_get_data'
/usr/bin/ld: chat.cpp:(.text+0x3fa5): undefined reference to ggml_used_mem' /usr/bin/ld: chat.cpp:(.text+0x3fd2): undefined reference to ggml_free'
/usr/bin/ld: /tmp/ccCnl7Fq.o: in function llama_print_system_info()': chat.cpp:(.text+0x40d1): undefined reference to ggml_cpu_has_avx'
/usr/bin/ld: chat.cpp:(.text+0x414e): undefined reference to ggml_cpu_has_avx2' /usr/bin/ld: chat.cpp:(.text+0x41cb): undefined reference to ggml_cpu_has_avx512'
/usr/bin/ld: chat.cpp:(.text+0x4248): undefined reference to ggml_cpu_has_fma' /usr/bin/ld: chat.cpp:(.text+0x42c5): undefined reference to ggml_cpu_has_neon'
/usr/bin/ld: chat.cpp:(.text+0x4342): undefined reference to ggml_cpu_has_arm_fma' /usr/bin/ld: chat.cpp:(.text+0x43bf): undefined reference to ggml_cpu_has_f16c'
/usr/bin/ld: chat.cpp:(.text+0x443c): undefined reference to ggml_cpu_has_fp16_va' /usr/bin/ld: chat.cpp:(.text+0x44b9): undefined reference to ggml_cpu_has_wasm_simd'
/usr/bin/ld: chat.cpp:(.text+0x4536): undefined reference to ggml_cpu_has_blas' /usr/bin/ld: chat.cpp:(.text+0x45b3): undefined reference to ggml_cpu_has_sse3'
/usr/bin/ld: chat.cpp:(.text+0x4630): undefined reference to ggml_cpu_has_vsx' /usr/bin/ld: /tmp/ccCnl7Fq.o: in function main':
chat.cpp:(.text+0x4a7b): undefined reference to ggml_time_init' /usr/bin/ld: chat.cpp:(.text+0x4a80): undefined reference to ggml_time_us'
/usr/bin/ld: chat.cpp:(.text+0x4b0d): undefined reference to gpt_params_parse(int, char**, gpt_params&)' /usr/bin/ld: chat.cpp:(.text+0x4bb2): undefined reference to gpt_random_prompt[abi:cxx11](std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>&)'
/usr/bin/ld: chat.cpp:(.text+0x4c0c): undefined reference to ggml_time_us' /usr/bin/ld: chat.cpp:(.text+0x4c8b): undefined reference to ggml_time_us'
/usr/bin/ld: chat.cpp:(.text+0x4d6c): undefined reference to llama_tokenize(gpt_vocab const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)' /usr/bin/ld: chat.cpp:(.text+0x4dd8): undefined reference to llama_tokenize(gpt_vocab const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool)'
/usr/bin/ld: chat.cpp:(.text+0x4e44): undefined reference to llama_tokenize(gpt_vocab const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool)' /usr/bin/ld: chat.cpp:(.text+0x51b6): undefined reference to ggml_time_us'
/usr/bin/ld: chat.cpp:(.text+0x5296): undefined reference to ggml_time_us' /usr/bin/ld: chat.cpp:(.text+0x536e): undefined reference to ggml_time_us'
/usr/bin/ld: chat.cpp:(.text+0x5420): undefined reference to llama_sample_top_p_top_k(gpt_vocab const&, float const*, std::vector<int, std::allocator<int> >&, double, int, double, double, std::mersenne_twister_engine<unsigned long, 32ul, 624ul, 397ul, 31ul, 2567483615ul, 11ul, 4294967295ul, 7ul, 2636928640ul, 15ul, 4022730752ul, 18ul, 1812433253ul>&)' /usr/bin/ld: chat.cpp:(.text+0x548c): undefined reference to ggml_time_us'
/usr/bin/ld: chat.cpp:(.text+0x5a79): undefined reference to `llama_tokenize(gpt_vocab const&, std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&, bool)'
collect2: error: ld returned 1 exit status
make: *** [: chat] Error 1

@LZY-the-boys
Copy link
Collaborator

这个编译的时候是需要ggml.cpp/h和util.cpp/h的,我们提供了cmakelist和makefile,可以尝试一下

@yuxuan2015
Copy link
Author

@LZY-the-boys

这个编译的时候是需要ggml.cpp/h和util.cpp/h的,我们提供了cmakelist和makefile,可以尝试一下

chat.cpp里面用到了ggml_new_tensor_2d这个方法,但是在ggml.cpp和util.cpp里面却没有定义这个方法啊
model.tok_embeddings = ggml_new_tensor_2d(ctx, wtype, n_embd, n_vocab);
model.norm = ggml_new_tensor_1d(ctx, GGML_TYPE_F32, n_embd);
model.output = ggml_new_tensor_2d(ctx, wtype, n_embd, n_vocab);

@LZY-the-boys
Copy link
Collaborator

ggml.c 2630行有定义的

struct ggml_tensor * ggml_new_tensor_1d(
        struct ggml_context * ctx,
        enum   ggml_type type,
        int    ne0) {
    return ggml_new_tensor(ctx, type, 1, &ne0);
}
struct ggml_tensor * ggml_new_tensor_2d(
        struct ggml_context * ctx,
        enum   ggml_type type,
        int    ne0,
        int    ne1) {
    const int ne[2] = { ne0, ne1 };
    return ggml_new_tensor(ctx, type, 2, ne);
}

是不是拉取错代码了?

@yuxuan2015
Copy link
Author

@LZY-the-boys

ggml.c 2630行有定义的

struct ggml_tensor * ggml_new_tensor_1d(
        struct ggml_context * ctx,
        enum   ggml_type type,
        int    ne0) {
    return ggml_new_tensor(ctx, type, 1, &ne0);
}
struct ggml_tensor * ggml_new_tensor_2d(
        struct ggml_context * ctx,
        enum   ggml_type type,
        int    ne0,
        int    ne1) {
    const int ne[2] = { ne0, ne1 };
    return ggml_new_tensor(ctx, type, 2, ne);
}

是不是拉取错代码了?
解决了,代码没有拉错,用make -f Makefile.ref chat编译就成功了

@LZY-the-boys
Copy link
Collaborator

OK

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

2 participants