-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathgpu_installer_cuda.bat
More file actions
103 lines (91 loc) · 3.02 KB
/
gpu_installer_cuda.bat
File metadata and controls
103 lines (91 loc) · 3.02 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
@echo off
setlocal
pip --version >nul 2>&1
if %errorlevel% EQU 0 (
set PIP_COMMAND=pip
) else (
pip3 --version >nul 2>&1
if %errorlevel% EQU 0 (
set PIP_COMMAND=pip3
) else (
echo Error: pip or pip3 is required.
exit /b 1
)
)
%PIP_COMMAND% --version | findstr /C:"python 3" >nul 2>&1 && (
echo pip is for Python 3.x.
) || (
echo pip is not for Python 3.x.
echo trying pip3...
pip3 --version | findstr /C:"python 3" >nul 2>&1 && (
set PIP_COMMAND=pip3
echo pip3 is for Python 3.x.
) || (
echo pip3 is not for Python 3.x.
echo Error: pip or pip3 is required.
exit /b 1
)
)
python --version >nul 2>&1 && (
python -c "import sys; assert sys.version_info >= (3, 10), 'Error: Python version should be larger than 3.10.'" >nul 2>&1 && (
set PYTHON_COMMAND=python
) || (
py --version >nul 2>&1 && (
py -c "import sys; assert sys.version_info >= (3, 10), 'Error: Python version should be larger than 3.10.'" >nul 2>&1 && (
set PYTHON_COMMAND=py
) || (
echo Error: Python version should be larger than 3.10.
exit /b 1
)
)
)
) || (
echo Error: python or py is required.
exit /b 1
)
set /p use_venv="Do you want to use a virtual environment (venv) for the installation? (y/n): "
if /i "%use_venv%"=="y" (
%PYTHON_COMMAND% -c "import venv" >nul 2>&1
if %errorlevel% NEQ 0 (
echo Error: 'venv' module is not installed. Please install it using 'pip install virtualenv'.
exit /b 1
)
echo Creating a virtual environment...
%PYTHON_COMMAND% -m venv venv
if exist "venv\Scripts\activate.bat" (
echo Activating the virtual environment...
call venv\Scripts\activate.bat
) else (
echo Error: Virtual environment 'venv' not found.
exit /b 1
)
)
where nvcc >nul 2>&1
if %errorlevel% equ 0 (
nvcc --version | findstr /C:"release 11.8" >nul 2>&1
if %errorlevel% equ 0 (
echo CUDA 11.8 is installed.
) else (
echo Error: CUDA 11.8 is not installed.
exit /b 1
)
) else (
echo Error: nvcc is not found. Please install CUDA 11.8.
exit /b 1
)
echo Installing requirements...
%PIP_COMMAND% install -r requirements.txt -q
%PYTHON_COMMAND% -c "import torch; assert torch.version.cuda.startswith('11.8'), 'Error: CUDA version should be 11.8.'" >nul 2>&1 && (
echo PyTorch version is compatible with CUDA 11.8.
) || (
echo Error: PyTorch version should be compatible with CUDA 11.8.
echo Installing PyTorch for CUDA 11.8...
%PIP_COMMAND% install torch torchvision --force-reinstall --upgrade --no-cache-dir --index-url https://download.pytorch.org/whl/cu118
)
echo Building and installing llama-cpp-python package...
set CMAKE_ARGS="-DLLAMA_CUBLAS=on"
set FORCE_CMAKE=1
%PIP_COMMAND% uninstall llama-cpp-python -y
%PIP_COMMAND% install llama-cpp-python --force-reinstall --upgrade --no-cache-dir
echo Installation completed.
endlocal