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

Here is a script to automate the build on Windows #664

Closed
jojorne opened this issue Feb 6, 2024 · 3 comments
Closed

Here is a script to automate the build on Windows #664

jojorne opened this issue Feb 6, 2024 · 3 comments

Comments

@jojorne
Copy link

jojorne commented Feb 6, 2024

Setup

  • Create a folder called KoboldCpp.
  • Download and extract KoboldCpp inside that folder and rename it to koboldcpp. Or open the CMD inside that folder and use this command git clone https://github.com/LostRuins/koboldcpp.git. You must have Git for Windows installed for this.
  • Install the Python with Add python.exe to PATH or Add Python to environment variables checked.
  • Install the Visual Studio with the Desktop development with C++ workload.
  • image
  • Install the CUDA Toolkit. If it fails to install, uncheck CUDA\Visual Studio Integration and all the CUDA\Nsight * during the installation. Then open the installation package with 7zip and extract all 4 files that are inside the visual_studio_integration\CUDAVisualStudioIntegration\extras\visual_studio_integration\MSBuildExtensions to your Visual Studio Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations folder.
  • Install the latest release of w64devkit and add its path to the Windows' PATH environment variable or to the "make.bat" below like so: set PATH=c:\path\to\w64devkit\bin;%PATH%
  • image
  • Create a new file called make.bat inside the first "KoboldCpp" folder (not inside the extracted/cloned folder).

make.bat

@echo off
title KoboldCpp
cd /d "%~dp0\koboldcpp"
make -s -j %NUMBER_OF_PROCESSORS% -C .
call "C:\Program Files\Microsoft Visual Studio\2022\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_x64
cmake -S . -B build -G "Visual Studio 17 2022" -DCMAKE_C_FLAGS="/utf-8" -DCMAKE_CXX_FLAGS="/utf-8 /EHsc" -DCMAKE_CUDA_FLAGS="--compiler-options=/utf-8" %*
cmake --build build --config Release -j %NUMBER_OF_PROCESSORS%
copy /y "build\bin\Release\koboldcpp_cublas.dll" "koboldcpp_cublas.dll"
if exist "cudart64_12.dll" del /q "cudart64_12.dll"
if exist "cudart64_110.dll" del /q "cudart64_110.dll"
if exist "msvcp140_codecvt_ids.dll" del /q "msvcp140_codecvt_ids.dll"
if exist "msvcp140.dll" del /q "msvcp140.dll"
pause
  • Now execute the "make.bat" and wait for it to finish.
  • Run KoboldCpp with py -m koboldcpp as usual.

Bonus

Run KoboldCpp

Open Kobo's launcher.

koboldcpp.bat

@echo off
cd /d "%~dp0\koboldcpp"
title KoboldCpp
py -m koboldcpp

Help file

You can call Kobo for help!

koboldcpp --help.bat

@echo off
cd /d "%~dp0\koboldcpp"
title KoboldCpp
py -m koboldcpp --help
pause

Cache clean

image
You can copy the make.bat and paste as shortcut. Now you can add additional commands to cmake like --fresh to clean the cmake cache. Open the shortcut properties and add a space followed by --fresh at the end of the target path.
image

Make clean

Here is a make clean.bat to delete all the build files.

make clean.bat

@echo off
cd /d "%~dp0\koboldcpp"
make -s clean
rm -vrf build
@jojorne jojorne closed this as completed Feb 6, 2024
@PhoenixtheII
Copy link

This was far more helpful than the readme.md of the repo for windows building....

@LostRuins
Copy link
Owner

Very nice. I will link to this in the wiki.

@rosemash
Copy link

rosemash commented Mar 26, 2024

For anyone who got stuck like I did, you have to install cmake from https://cmake.org/download/ and change cmake ".." -G "MinGW Makefiles" --fresh in the build script to path\to\bin\cmake.exe ".." -G "MinGW Makefiles" --fresh, (replacing path\to\bin\cmake.exe to the cmake distribution you downloaded) otherwise it tries to use a version of cmake bundled with Visual Studio, which results in an error about there being no generator called "MinGW Makefiles". After that I was able to build successfully.

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

4 participants