ggerganov / ggml

Tensor library for machine learning
MIT License
11.3k stars 1.06k forks source link

cmake fails without -G #211

Open NancyAurum opened 1 year ago

NancyAurum commented 1 year ago

On Windows 11 cmake .. fails to produce a working Makefile One has to explicitly specify cmake -G 'Unix Makefiles' ..

The w64devkit gcc version 12.2.0 (GCC) has no aligned_alloc, therefore

C:/soft/w64devkit//bin/ld.exe: CMakeFiles/test-vec0.dir/objects.a(test-vec0.c.obj):test-vec0.c:(.text.startup+0x1f): undefined reference to `aligned_alloc'

I replaced it with the usual malloc, and it compiled just fine.

There is also an attempt to use strlen inside std:: (since when C functions got there?!!)

C:/Users/nangl/d/code/ggml/examples/common.cpp:319:68: error: 'strlen' is not a member of 'std'; did you mean 'mbrlen'?
  319 |             std::string s_tokens = line.substr(delimiterPos + std::strlen(delimeter));

Apparently #include <cstring> declares it as part of std.

Attempt to run mpt-7b-instruct.ggmlv3.q8_0.bin from https://huggingface.co/TheBloke/MPT-7B-Instruct-GGML results into a Windows related error with using a wstring converter on a utf8 input

$ ./bin/mpt -m C:/Users/nangl/d/ai/models/mpt-7b-instruct.ggmlv3.q8_0.bin -p "The meaning of life is"
main: seed      = 1685365941
main: n_threads = 4
main: n_batch   = 8
main: n_ctx     = 512
main: n_predict = 200

mpt_model_load: loading model from 'C:/Users/nangl/d/ai/models/mpt-7b-instruct.ggmlv3.q8_0.bin' - please wait ...
mpt_model_load: d_model        = 4096
mpt_model_load: max_seq_len    = 2048
mpt_model_load: n_ctx          = 512
mpt_model_load: n_heads        = 32
mpt_model_load: n_layers       = 32
mpt_model_load: n_vocab        = 50432
mpt_model_load: alibi_bias_max = 8.000000
mpt_model_load: clip_qkv       = 0.000000
mpt_model_load: ftype          = 2007
mpt_model_load: qntvr          = 2
terminate called after throwing an instance of 'std::range_error'
  what():  wstring_convert::from_bytes

Replacing it with

std::wstring convert_to_wstring(const std::string & input) {
    for (int i = 0; i < input.length(); i++)
      if ((uint8_t)input[i] & 0x80)
        return convert_to_wstring(std::string(" "));
    std::wstring_convert<std::codecvt_utf8<wchar_t>> converter;
    return converter.from_bytes(input);
}

Solves the issue. Nobody needs unicode anyway.

dillfrescott commented 1 year ago
C:\Users\micro\Downloads\ggml\build>cmake -G "Unix Makefiles" ..
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_C_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CC" or the CMake cache entry CMAKE_C_COMPILER to the full path to
  the compiler, or to the compiler name if it is in the PATH.

CMake Error at CMakeLists.txt:2 (project):
  No CMAKE_CXX_COMPILER could be found.

  Tell CMake where to find the compiler by setting either the environment
  variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path
  to the compiler, or to the compiler name if it is in the PATH.

-- Configuring incomplete, errors occurred!

Sadly it doesnt work either