-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_gpu.bat
More file actions
141 lines (124 loc) · 4.59 KB
/
run_gpu.bat
File metadata and controls
141 lines (124 loc) · 4.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
@echo off
echo LUTplus - Image Processing Tool (GPU Mode)
echo ==============================================
REM Check for network mode argument
set NETWORK_MODE=
if "%1"=="--network" set NETWORK_MODE=--network
REM Check if Python is installed
python --version >nul 2>&1
if errorlevel 1 (
echo Python is not installed! Please install Python 3.9 or higher.
pause
exit /b 1
)
REM Check Python version for compatibility
for /f "tokens=2" %%i in ('python --version 2^>^&1') do set PYTHON_VERSION=%%i
echo Detected Python version: %PYTHON_VERSION%
for /f "tokens=1,2 delims=." %%a in ("%PYTHON_VERSION%") do (
set PYTHON_MAJOR=%%a
set PYTHON_MINOR=%%b
)
REM Check if using Python 3.13 or higher (not compatible)
if %PYTHON_MAJOR% EQU 3 (
if %PYTHON_MINOR% GEQ 13 (
echo ERROR: Python %PYTHON_VERSION% is not compatible with LUTplus.
echo NumPy 1.x packages required by LUTplus are not available for Python 3.13+.
echo Please install Python 3.12.x instead.
echo See README.md for more information on compatibility.
pause
exit /b 1
)
)
REM Check if virtual environment exists
if not exist venv (
echo Creating virtual environment...
python -m venv venv
if errorlevel 1 (
echo Failed to create virtual environment!
pause
exit /b 1
)
)
REM Activate virtual environment
echo Activating virtual environment...
call venv\Scripts\activate.bat
if errorlevel 1 (
echo Failed to activate virtual environment!
pause
exit /b 1
)
REM Update pip
echo Updating pip...
python -m pip install --upgrade pip
if errorlevel 1 (
echo Failed to update pip!
pause
exit /b 1
)
REM Install requirements
echo Installing required packages...
echo Trying primary packages...
REM Try primary installation
python -m pip install gradio==4.19.2 numpy==1.26.4 opencv-python==4.9.0.80 Pillow==10.2.0 colour-science==0.4.6 huggingface-hub==0.20.0 --only-binary=:all: --no-cache-dir
if errorlevel 1 (
echo Primary installation failed. Trying with more compatible versions...
REM Try fallback installation
python -m pip install gradio==4.19.2 numpy==1.24.3 opencv-python==4.8.1.78 Pillow==10.0.0 colour-science==0.4.2 --only-binary=:all: --no-cache-dir
if errorlevel 1 (
echo Fallback installation failed. Trying minimal compatible versions...
REM Try minimal compatible installation
python -m pip install gradio==3.50.2 numpy==1.21.6 opencv-python==4.7.0.72 Pillow==9.5.0 colour-science==0.4.1 --only-binary=:all: --no-cache-dir
if errorlevel 1 (
echo Failed to install packages after multiple attempts!
echo Trying to install from requirements_compatible.txt file...
REM Last attempt - try to install from the requirements file
if exist requirements_compatible.txt (
python -m pip install -r requirements_compatible.txt --only-binary=:all: --no-cache-dir
if errorlevel 1 (
echo All installation attempts failed!
echo Please try running manual_install.bat or install packages manually.
pause
exit /b 1
)
) else (
echo All installation attempts failed!
echo Please install packages manually.
pause
exit /b 1
)
)
)
)
REM Install CuPy for GPU support
echo.
echo Installing GPU support (CuPy)...
echo Trying CuPy for CUDA 12.x...
python -m pip install cupy-cuda12x --no-cache-dir
if errorlevel 1 (
echo CuPy for CUDA 12.x failed. Trying CUDA 11.x...
python -m pip install cupy-cuda11x --no-cache-dir
if errorlevel 1 (
echo CuPy installation failed. GPU acceleration will not be available.
echo Make sure you have NVIDIA GPU with CUDA installed.
echo You can continue without GPU support, but processing will be slower.
pause
) else (
echo CuPy for CUDA 11.x installed successfully!
)
) else (
echo CuPy for CUDA 12.x installed successfully!
)
REM Launch the application with GPU flag
echo.
echo Starting LUTplus with GPU acceleration...
if defined NETWORK_MODE (
echo Network mode enabled. Application will be accessible from your local network.
python app.py --gpu --network
) else (
python app.py --gpu
)
REM Keep the window open if there's an error
if errorlevel 1 (
echo Application failed to start!
pause
)