Skip to content

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

Closed

Description

@jojorne

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

Activity

  1. PhoenixtheII commented on Feb 7, 2024

    @PhoenixtheII

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

  2. LostRuins commented on Feb 7, 2024

    @LostRuins
    Owner

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

  3. rosemash commented on Mar 26, 2024

    @rosemash

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions