From 43225286bbcc18472997535c662912fa5c9fac7a Mon Sep 17 00:00:00 2001 From: Peter Reid Date: Mon, 14 Aug 2023 21:07:03 -0400 Subject: [PATCH 1/2] Add build script for Microsoft Visual Studio --- build_msvc.bat | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 build_msvc.bat diff --git a/build_msvc.bat b/build_msvc.bat new file mode 100644 index 000000000..d4deb5018 --- /dev/null +++ b/build_msvc.bat @@ -0,0 +1,32 @@ +@echo OFF + +REM Determine if this batch file was launched by double-clicking it from Explorer. +REM If it was, we will pause before exiting so the user can read the output. +set explorer_launched=0 +for %%x in (%cmdcmdline%) do if /i "%%~x"=="/c" set explorer_launched=1 + +REM Make sure the Visual Studio compiler is present +where cl.exe > nul 2> nul +if %errorlevel% neq 0 ( + echo Unable to find `cl.exe`, the Visual Studio compiler. + echo Please make sure Visual Studio is installed and in your PATH environment variable. + echo if Visual Studio is installed, you may have to launch "x64 Native Tools Command Prompt for VS". + if "%explorer_launched%" == "1" pause + exit /b 1 +) + +REM Make sure that the x64 compiler is selected by looking for "for x86" in cl.exe's statement of its version. +for /f "delims=" %%a in ('cl.exe 2^>^&1') do ( + setlocal enabledelayedexpansion + set "line=%%a" + if "!line!" neq "!line:for x86=!" ( + echo The 32-bit Visual Studio tools are active, but Stable Diffusion cannot allocate enough memory in 32-bit mode. + echo Please make sure the Visual Studio tools targeting x64 are active. + echo You may have to launch "x64 Native Tools Command Prompt for VS". + if "%explorer_launched%" == "1" pause + exit /b 1 + ) + endlocal +) + +cl.exe /fp:fast /Ox /EHsc /I. /I ggml\include\ggml /I ggml\include main.cpp stable-diffusion.cpp ggml\src\ggml.c /link /out:sd.exe From c1cca94d7e8063f86a703e76922230c47909bd65 Mon Sep 17 00:00:00 2001 From: Peter Reid Date: Thu, 24 Aug 2023 17:03:38 -0400 Subject: [PATCH 2/2] Add /arch:AVX2 and /GL flags to cl.exe --- build_msvc.bat | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_msvc.bat b/build_msvc.bat index d4deb5018..ada943d7b 100644 --- a/build_msvc.bat +++ b/build_msvc.bat @@ -29,4 +29,4 @@ for /f "delims=" %%a in ('cl.exe 2^>^&1') do ( endlocal ) -cl.exe /fp:fast /Ox /EHsc /I. /I ggml\include\ggml /I ggml\include main.cpp stable-diffusion.cpp ggml\src\ggml.c /link /out:sd.exe +cl.exe /fp:fast /Ox /EHsc /arch:AVX2 /GL /I. /I ggml\include\ggml /I ggml\include main.cpp stable-diffusion.cpp ggml\src\ggml.c /link /out:sd.exe \ No newline at end of file