antimatter15 / alpaca.cpp

Locally run an Instruction-Tuned Chat-Style LLM
MIT License
10.27k stars 917 forks source link

Cmake on windows does not work #106

Open dburner opened 1 year ago

dburner commented 1 year ago

Running the build command on windows I get lots of errors. cmake --build . --config Release It appears the restricted keyword is not recognized on multiple lines. Example

void quantize_row_q4_0(const float * restrict x, void * restrict y, int k) {

Error is:

E:\Projects\alpaca.cpp\ggml.c(404): error C2146: syntax error: missing ')' before identifier 'x' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(404): error C2061: syntax error: identifier 'x' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(404): error C2059: syntax error: ';' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(404): error C2059: syntax error: ',' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(404): error C2059: syntax error: ')' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(606): error C2146: syntax error: missing ')' before identifier 'x' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(606): error C2061: syntax error: identifier 'x' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(606): error C2059: syntax error: ';' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(606): error C2059: syntax error: ',' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(606): error C2059: syntax error: ')' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(651): error C2146: syntax error: missing ')' before identifier 'x' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(651): error C2061: syntax error: identifier 'x' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(651): error C2059: syntax error: ';' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(651): error C2059: syntax error: ',' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(651): error C2059: syntax error: ')' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(686): error C2146: syntax error: missing ')' before identifier 'x' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(686): error C2061: syntax error: identifier 'x' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(686): error C2059: syntax error: ';' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(686): error C2059: syntax error: ',' [E:\Projects\alpaca.cpp\ggml.vcxproj]
E:\Projects\alpaca.cpp\ggml.c(686): error C2059: syntax error: ')' [E:\Projects\alpaca.cpp\ggml.vcxproj]
frenchmustard commented 1 year ago

I have Windows 10 and it works fine, what version are you on? Also, do you have Visual Studio 2019 installed? Seemed to be required for me.

ROBOKiTTY commented 1 year ago

Put #define restrict __restrict at the top of ggml.c and #undef restrict at the bottom.

xuyuliang commented 1 year ago

The exact same error occurred to me too. I installed visual studio 2022 community version. I couldn't build it by visual studio . And I run CMake GUI (another software installed with CMake), I play with "config" button and "generate" button , config the system with VS 2022 , when I press "open project" and try to build it by VS 2022, I failed.

But , when I try the command line "cmake --build . --config Release" , it succeed . I delete them all and try again. I don't know what exactlly my random click in CMake GUI take effect, but it does. I wrote it down , hope it will help. image

there is another thing I don't has the chance to capture a picture. When you click the "config" button first time, CMake will ask what compiler you would choose, I choose VS 2022.

dburner commented 1 year ago

Put #define restrict __restrict at the top of ggml.c and #undef restrict at the bottom.

Yes that solved the prolem. Thanks 👍

LudoSGitHub commented 1 year ago

Hi Trying to make it work. First of all, the get ready says to launch the chat.exe but it does not come with the source. I tryed to compile with cmake but I have errors. I make the change on ggml.c as said in another response: Put #define restrict __restrict at the top of ggml.c and #undef restrict at the bottom.

But still have issues when trying cmake --build . --config Release:

D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(8681,45): warning C4244: 'initialisation' : conversion de 'const int64_t' en 'const int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(8682,45): warning C4244: 'initialisation' : conversion de 'const int64_t' en 'const int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(8690,30): warning C4244: 'initialisation' : conversion de 'int64_t' en 'const int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9365,24): error C2061: erreur de syntaxe : identificateur 'ss_mutex' [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9365,24): error C2059: erreur de syntaxe : ';' [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9365,33): error C2513: ' ' : aucune variable déclarée avant '=' [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9365,60): error C2065: 'PTHREAD_MUTEX_INITIALIZER' : identificateur non déclaré [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9366,23): error C2061: erreur de syntaxe : identificateur 'ss_cond' [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9366,23): error C2059: erreur de syntaxe : ';' [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9366,31): error C2513: ' ' : aucune variable déclarée avant '=' [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9366,57): error C2065: 'PTHREAD_COND_INITIALIZER' : identificateur non déclaré [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9369,5): warning C4013: 'pthread_mutex_lock' non défini(e) ; extern retournant int pris par défaut [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9369,33): error C2065: 'ss_mutex' : identificateur non déclaré [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9371,5): warning C4013: 'pthread_cond_broadcast' non défini(e) ; extern retournant int pris par défaut [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9371,36): error C2065: 'ss_cond' : identificateur non déclaré [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9372,5): warning C4013: 'pthread_mutex_unlock' non défini(e) ; extern retournant int pris par défaut [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9372,35): error C2065: 'ss_mutex' : identificateur non déclaré [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9377,33): error C2065: 'ss_mutex' : identificateur non déclaré [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9380,9): warning C4013: 'pthread_cond_wait' non défini(e) ; extern retournant int pris par défaut [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9380,35): error C2065: 'ss_cond' : identificateur non déclaré [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9380,46): error C2065: 'ss_mutex' : identificateur non déclaré [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9383,35): error C2065: 'ss_mutex' : identificateur non déclaré [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9652,64): warning C4244: 'fonction' : conversion de 'int64_t' en 'int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9658,64): warning C4244: 'fonction' : conversion de 'int64_t' en 'int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9673,68): warning C4244: 'fonction' : conversion de 'int64_t' en 'int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9647,54): warning C4244: 'initialisation' : conversion de 'int64_t' en 'const int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(9989,17): warning C4996: 'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(10109,36): warning C4244: 'fonction' : conversion de 'int64_t' en 'int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(10120,45): warning C4244: 'fonction' : conversion de 'int64_t' en 'int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(10131,51): warning C4244: 'fonction' : conversion de 'int64_t' en 'int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(10165,19): warning C4244: '+=' : conversion de 'int64_t' en 'int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(10244,68): warning C4244: 'fonction' : conversion de 'int' en 'float', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(10245,68): warning C4244: 'fonction' : conversion de 'int' en 'float', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj] D:\01 - PROJETS\Python\alpaca.cpp2\ggml.c(10465,19): warning C4244: '+=' : conversion de 'int64_t' en 'int', perte possible de données [D:\01 - PROJETS\Python\alpaca.cpp2\ggml.vcxproj]

Can you help me ?

LudoSGitHub commented 1 year ago

I dowloaded the .zip with executable but I have the same issue than others: D:\01 - PROJETS\Python\alpaca.cpp2>chat.exe -m ggml-alpaca-13b-q4.bin main: seed = 1680512416 llama_model_load: loading model from 'ggml-alpaca-13b-q4.bin' - please wait ... llama_model_load: ggml ctx size = 10959.49 MB llama_model_load: memory_size = 3200.00 MB, n_mem = 81920 llama_model_load: loading model part 1/1 from 'ggml-alpaca-13b-q4.bin' llama_model_load: ............................................. done llama_model_load: model size = 7759.39 MB / num tensors = 363

system_info: n_threads = 4 / 8 | AVX = 1 | AVX2 = 1 | AVX512 = 0 | FMA = 0 | NEON = 0 | ARM_FMA = 0 | F16C = 0 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 0 | VSX = 0 | main: interactive mode on. sampling parameters: temp = 0.100000, top_k = 40, top_p = 0.950000, repeat_last_n = 64, repeat_penalty = 1.300000

Then exiting