Skip to content

Commit 78aaa95

Browse files
Merge pull request #243 from ZaberKo/fix-win-installer
Fix win installer
2 parents f565d2e + cc41b13 commit 78aaa95

File tree

1 file changed

+96
-23
lines changed

1 file changed

+96
-23
lines changed

docs/source/_static/win-install.bat

Lines changed: 96 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ setlocal enabledelayedexpansion
33

44
REM Check NVIDIA driver version
55
set "use_cpu=N"
6-
set "install_triton=Y"
6+
set "install_triton=N"
77
where nvidia-smi > nul 2>&1
8-
if %errorlevel% neq 0 (
8+
if !errorlevel! neq 0 (
99
echo [ERROR] NVIDIA driver not found. Please install the latest NVIDIA driver first from https://www.nvidia.com/drivers/.
1010
echo Do you want install torch cpu version instead? ^(Y/N, default N^)
1111
set /p use_cpu=">> "
@@ -19,12 +19,13 @@ if %errorlevel% neq 0 (
1919

2020
REM If using GPU, ask if the user want to install triton-windows for torch.compile support
2121
if /i "!use_cpu!"=="N" (
22-
echo Do you want to install triton-windows for torch.compile support? ^(Y/N, default Y^)
22+
echo Do you want to install triton-windows for torch.compile support? ^(Y/N, default N^)
2323
set /p install_triton=">> "
24-
if "!install_triton!"=="" set "install_triton=Y"
24+
if "!install_triton!"=="" set "install_triton=N"
2525
if /i "!install_triton!"=="Y" (
2626
echo [INFO] Will install triton-windows
2727
) else (
28+
set "install_triton=N"
2829
echo [INFO] Skip triton-windows installation
2930
)
3031
)
@@ -38,15 +39,15 @@ for /f "tokens=1* delims=," %%A in ('nvidia-smi --query-gpu=driver_version --for
3839
@REM echo %use_cpu%
3940
REM check winget is installed
4041
where winget > nul 2>&1
41-
if %errorlevel% neq 0 (
42+
if !errorlevel! neq 0 (
4243
echo [ERROR] winget is not installed. This usually happens on LTSC and Server OS. Please manually install winget from https://github.com/microsoft/winget-cli, then reopen this script.
4344
pause
4445
exit /b 1
4546
)
4647

4748
REM Check if VS Code is installed
4849
where code > nul 2>&1
49-
if %errorlevel% neq 0 (
50+
if !errorlevel! neq 0 (
5051
echo [INFO] VSCode is not found. Downloading Visual Studio Code installer...
5152
winget install -e --id Microsoft.VisualStudioCode
5253
) else (
@@ -55,7 +56,7 @@ if %errorlevel% neq 0 (
5556

5657
REM Checking if Git is installed
5758
where git > nul 2>&1
58-
if %errorlevel% neq 0 (
59+
if !errorlevel! neq 0 (
5960
echo [INFO] Git is not found. Downloading Git installer...
6061
winget install -e --id Git.Git
6162
) else (
@@ -65,7 +66,6 @@ if %errorlevel% neq 0 (
6566

6667

6768
REM Install Miniforge3 (example using curl)
68-
@REM where conda > nul 2>&1
6969
echo [INFO] Downloading Miniforge...
7070
if not exist "%UserProfile%\miniforge3" (
7171
curl -L -o Miniforge3-Windows-x86_64.exe https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-Windows-x86_64.exe
@@ -81,54 +81,127 @@ if not exist "%UserProfile%\miniforge3" (
8181
REM Temp activate conda
8282

8383
call %UserProfile%\miniforge3\Scripts\activate.bat %UserProfile%\miniforge3
84-
call mamba info
85-
echo [INFO] Installing EvoX packages...
84+
call conda info
85+
86+
echo [INFO] Creating evox-env environment...
8687
call conda env list | findstr "evox-env" >nul
87-
if %ERRORLEVEL%==0 (
88+
if !errorlevel!==0 (
8889
echo Environment evox-env already exists. Removing...
8990
call conda env remove -n evox-env -y
9091
)
91-
call mamba create -n evox-env python=3.12 -y
92-
call mamba activate evox-env
92+
call conda create -n evox-env python=3.12 -y
93+
call conda activate evox-env
94+
95+
echo [INFO] Installing basic packages...
9396
pip install numpy jupyterlab nbformat
97+
98+
echo [INFO] Installing Pytorch packages...
9499
if /i "!use_cpu!"=="Y" (
95-
pip install torch
100+
pip install "torch==2.7.1" "torchvision~=0.22" --index-url https://download.pytorch.org/whl/cpu
96101
) else (
97-
pip install "torch>=2.7.0" --index-url https://download.pytorch.org/whl/cu124
98-
pip show triton > nul 2>&1
99-
REM Check if install_triton is Y and triton-windows is not installed
100-
if /i "!install_triton!"=="Y" if %errorlevel% neq 0 (
102+
REM use fixed torch version and cu118 for compt on old nvidia driver
103+
pip install "torch==2.7.1" "torchvision~=0.22" --index-url https://download.pytorch.org/whl/cu118
104+
105+
REM Check if install_triton is Y
106+
if /i "!install_triton!"=="Y" (
101107
echo [INFO] Installing triton-windows
102108
echo [INFO] Downloading MSVC and Windows SDK
103109
curl -L -o vs_buildtools.exe https://aka.ms/vs/17/release/vs_BuildTools.exe
104110
if exist vs_buildtools.exe (
105111
echo [INFO] Installing MSVC and Windows SDK
106-
start /wait vs_buildtools.exe --quiet --wait --norestart --nocache --installPath %UserProfile%\vs_buildtools
112+
start /wait vs_buildtools.exe --passive --wait --norestart --nocache --add Microsoft.VisualStudio.Workload.VCTools;includeRecommended
113+
if !errorlevel! neq 0 (
114+
echo [ERROR] Installing MSVC and Windows SDK failed.
115+
pause
116+
exit /b 1
117+
)
118+
call :config_msvc_path
119+
if !errorlevel! neq 0 (
120+
echo [ERROR] Config PATH failed.
121+
pause
122+
exit /b 1
123+
)
107124
)
108125
echo [INFO] Downloading vcredist
109126
curl -L -o vcredist.exe https://aka.ms/vs/17/release/vc_redist.x64.exe
110127
if exist vcredist.exe (
111128
echo [INFO] Installing vcredist
112129
start /wait vcredist.exe /install /quiet /norestart
130+
if !errorlevel! neq 0 (
131+
echo [ERROR] Installing vcredist failed.
132+
pause
133+
exit /b 1
134+
)
113135
)
114136
echo [INFO] Installing triton-windows pip package
115-
pip install -U "triton-windows<3.4"
137+
pip install -U "triton-windows~=3.3"
116138

117-
echo [INFO] Check if Windows file path length limit (260) exists
139+
echo [INFO] Check if Windows file path length limit ^(260^) exists
118140
echo [INFO] Attempting to modify registry to enable long path support.
119141
powershell -Command "Start-Process powershell -ArgumentList '-NoProfile -ExecutionPolicy Bypass -Command New-ItemProperty -Path \"HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem\" -Name \"LongPathsEnabled\" -Value 1 -PropertyType DWORD -Force' -Verb RunAs"
120142
echo [INFO] Long Path Support should now be enabled. Restart required.
121143
)
122144
)
123145
echo [INFO] Installing EvoX packages...
124-
pip install "evox[vis]>=1.0.0" torchvision
146+
pip install "evox[vis]>=1.0.0"
125147
REM Download some demo
126148
mkdir %UserProfile%\evox-demo
127149
git clone --depth 1 https://github.com/EMI-Group/evox.git %UserProfile%\evox-demo\evox
128-
xcopy %UserProfile%\evox-demo\evox\docs\source\example\ %UserProfile%\evox-demo /E /I /Y
150+
xcopy %UserProfile%\evox-demo\evox\docs\source\examples\ %UserProfile%\evox-demo /E /I /Y
129151
start code %UserProfile%\evox-demo
130152

131153
echo Reboot is highly recommended to apply the changes.
132154

133155
pause
134156
:: ...existing code...
157+
goto :EOF
158+
159+
160+
:config_msvc_path
161+
REM 1. get root path of VS BuildTools
162+
for /f "usebackq delims=" %%I in (`
163+
"%ProgramFiles(x86)%\Microsoft Visual Studio\Installer\vswhere.exe" ^
164+
-latest ^
165+
-products * ^
166+
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ^
167+
-property installationPath
168+
`) do set "VSROOT=%%I"
169+
170+
if not defined VSROOT (
171+
echo [ERROR] BuildTools not found
172+
exit /b 1
173+
)
174+
175+
REM 2. select the largest version folder in VC\Tools\MSVC
176+
set "MSVCDIR="
177+
for /f "delims=" %%V in ('dir "!VSROOT!\VC\Tools\MSVC" /b /ad /o-n') do (
178+
set "MSVCDIR=%%V"
179+
goto :got_msvc
180+
)
181+
:got_msvc
182+
183+
if not defined MSVCDIR (
184+
echo [ERROR] Not found dir of MSVC
185+
exit /b 1
186+
)
187+
188+
set "BINPATH=!VSROOT!\VC\Tools\MSVC\!MSVCDIR!\bin\Hostx64\x64"
189+
190+
echo [INFO] write to user's PATH env !BINPATH!
191+
set "PATH=!BINPATH!;!PATH!"
192+
193+
set "USERPATH="
194+
for /f "skip=2 tokens=2*" %%A in ('
195+
reg query "HKCU\Environment" /v PATH 2^>nul
196+
') do set "USERPATH=%%B"
197+
198+
if "!USERPATH!"=="" (
199+
setx PATH "!BINPATH!" >nul
200+
) else (
201+
echo !USERPATH! | find /I "!BINPATH!" >nul
202+
if !errorlevel! neq 0 (
203+
setx PATH "!BINPATH!;!USERPATH!" >nul
204+
) else (
205+
echo [INFO] Skip. PATH already contains !BINPATH!
206+
)
207+
)

0 commit comments

Comments
 (0)