YavorGIvanov / sam.cpp

MIT License
1.26k stars 52 forks source link

Does not start on Windows #8

Closed kelteseth closed 1 year ago

kelteseth commented 1 year ago

Nothing happens except for the two prints. Also, what license does this project have? Cheers!


# python 3.11
python -m pip install torch numpy
# downloaded sam_vit_b_01ec64.pth  and put it in checkpoints
python convert-pth-to-ggml.py checkpoints/sam_vit_b_01ec64.pth . 1
mkdir build && cd build 
# PS C:\vcpkg> .\vcpkg.exe install sdl2:x64-windows
cmake .. -DCMAKE_TOOLCHAIN_FILE="C:\vcpkg\scripts\buildsystems\vcpkg.cmake"
cmake --build . --config Release
# contains sam.exe and SDL2.dll
cd .\bin\Release\
 C:\Code\cpp\sam.cpp\build\bin\Release> .\sam.exe -t 16 -i ../../../img.jpg -m ../../../checkpoints/ggml-model-f16.bin

SDL_main: seed = 1693989358
SDL_main: loaded image '../../../img.jpg' (680 x 453)
PS C:\Code\cpp\sam.cpp\build\bin\Release>
SpaceCowboy850 commented 1 year ago

Works for me.

You must get SDL2 DEV package for VC to work in Windows, then point CMAKE to where the sdl2-config.cmake resides. After that everything worked for me.

cmake -DSDL2_DIR=E:\SDL2-devel-2.28.3-VC\SDL2-2.28.3\cmake ..

https://github.com/libsdl-org/SDL/releases/tag/release-2.28.3

Finally, you'll need to copy the SDL2.dll to be next to the sam.exe, otherwise, you'll get an error about a missing dll when you run.

spacewalk01 commented 1 year ago

I've integrated it to visual studio: https://github.com/spacewalk01/sam-cpp-vs

FSSRepo commented 1 year ago

Nothing happens except for the two prints.

I resolved that inserting ggml_time_init(); in the beginning of the function std::shared_ptr<sam_state> sam_load_model(const sam_params & params) in the file sam.cpp

Like this:

std::shared_ptr<sam_state> sam_load_model(const sam_params & params) {
    ggml_time_init(); // add this and runs normal
    const int64_t t_start_ms = ggml_time_ms();
YavorGIvanov commented 1 year ago

This was already added last week in the master branch https://github.com/YavorGIvanov/sam.cpp/commit/39aa3ebbe35d5875e6a63f7b3cf60b61b6bd856b

YavorGIvanov commented 1 year ago

Closing for now. If any other similar problem happens on Windows, please open a new issue.