Spaces:
Sleeping
Sleeping
feat: Add RTX 5080 support and remove requirements-local.txt
Browse files- Add CUDA compatibility testing for unsupported GPUs (RTX 5080/Blackwell)
- Detect compute capability and fall back to CPU for sm_120+ GPUs
- Update setup.py with PyTorch nightly builds for Blackwell GPUs
- Add comprehensive GPU troubleshooting guide in INSTALL.md
- Remove requirements-local.txt (deprecated in favor of setup.py)
- Enhance hardware detection with cuda_compatible flag
π€ Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- INSTALL.md +136 -17
- RTX_5080_README.md +94 -0
- app.py +68 -11
- requirements-local.txt +0 -25
- setup.py +167 -17
INSTALL.md
CHANGED
|
@@ -45,23 +45,44 @@ requirements-local.txt # λ‘μ»¬μ© (PyTorch >=2.2.0)
|
|
| 45 |
|
| 46 |
---
|
| 47 |
|
| 48 |
-
## λ°©λ² 2: setup.py (μλ κ°μ§)
|
| 49 |
|
| 50 |
### μ€μΉ
|
| 51 |
```bash
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
python setup.py
|
| 53 |
```
|
| 54 |
|
| 55 |
-
### λμ λ°©μ
|
| 56 |
-
1. `SPACE_ID` νκ²½ λ³μ νμΈ
|
| 57 |
-
2. HF Spaces
|
| 58 |
-
3.
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
|
| 61 |
### μ₯μ
|
| 62 |
-
- μλ
|
| 63 |
-
- ν λͺ
λ ΉμΌλ‘ μ€μΉ
|
| 64 |
-
- νλ«νΌλ³ μ΅μ ν
|
|
|
|
|
|
|
| 65 |
|
| 66 |
---
|
| 67 |
|
|
@@ -157,6 +178,92 @@ A: PyTorch λ²μ λ§ λ€λ₯΄κ³ λλ¨Έμ§λ λμΌνκ² μ μ§νμΈμ.
|
|
| 157 |
|
| 158 |
## λ¬Έμ ν΄κ²°
|
| 159 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
### ImportError: spaces
|
| 161 |
**λ‘컬 νκ²½**:
|
| 162 |
```
|
|
@@ -165,15 +272,27 @@ A: PyTorch λ²μ λ§ λ€λ₯΄κ³ λλ¨Έμ§λ λμΌνκ² μ μ§νμΈμ.
|
|
| 165 |
|
| 166 |
### PyTorch λ²μ μΆ©λ
|
| 167 |
```bash
|
| 168 |
-
pip uninstall torch -y
|
| 169 |
-
|
| 170 |
```
|
| 171 |
|
| 172 |
-
###
|
| 173 |
-
```
|
| 174 |
-
#
|
| 175 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 176 |
|
| 177 |
-
|
| 178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 179 |
```
|
|
|
|
| 45 |
|
| 46 |
---
|
| 47 |
|
| 48 |
+
## λ°©λ² 2: setup.py (μλ κ°μ§) β μλ‘μ΄ CUDA μ§μ!
|
| 49 |
|
| 50 |
### μ€μΉ
|
| 51 |
```bash
|
| 52 |
+
# κ°μνκ²½ μμ± λ° νμ±ν
|
| 53 |
+
python -m venv venv
|
| 54 |
+
source venv/bin/activate # Windows: venv\Scripts\activate
|
| 55 |
+
|
| 56 |
+
# μ€λ§νΈ μ€μΉ μ€ν
|
| 57 |
python setup.py
|
| 58 |
```
|
| 59 |
|
| 60 |
+
### λμ λ°©μ (NEW! CUDA μλ κ°μ§)
|
| 61 |
+
1. **νκ²½ κ°μ§**: `SPACE_ID` νκ²½ λ³μ νμΈ
|
| 62 |
+
2. **HF Spaces**: PyTorch 2.2.0 μ€μΉ (ZeroGPU νΈν)
|
| 63 |
+
3. **λ‘컬 νκ²½**:
|
| 64 |
+
- π **NVIDIA GPU κ°μ§**: `nvidia-smi` μ€ν
|
| 65 |
+
- π **CUDA λ²μ κ°μ§**: `nvcc --version` λλ nvidia-smiμμ μΆμΆ
|
| 66 |
+
- β
**CUDAλ³ PyTorch μ€μΉ**:
|
| 67 |
+
- CUDA 11.8 β PyTorch cu118
|
| 68 |
+
- CUDA 12.1-12.3 β PyTorch cu121
|
| 69 |
+
- CUDA 12.4-12.8 β PyTorch cu124
|
| 70 |
+
- π **Apple Silicon**: MPS μ§μ
|
| 71 |
+
- π» **GPU μμ**: CPU μ μ© PyTorch
|
| 72 |
+
|
| 73 |
+
### μ§μνλ CUDA λ²μ
|
| 74 |
+
| CUDA λ²μ | PyTorch λ³ν | Index URL |
|
| 75 |
+
|-----------|--------------|-----------|
|
| 76 |
+
| 11.8 | cu118 | https://download.pytorch.org/whl/cu118 |
|
| 77 |
+
| 12.1-12.3 | cu121 | https://download.pytorch.org/whl/cu121 |
|
| 78 |
+
| 12.4-12.8 | cu124 | https://download.pytorch.org/whl/cu124 |
|
| 79 |
|
| 80 |
### μ₯μ
|
| 81 |
+
- β
**μμ μλ CUDA κ°μ§** (NEW!)
|
| 82 |
+
- β
ν λͺ
λ ΉμΌλ‘ μ€μΉ
|
| 83 |
+
- β
νλ«νΌλ³ μ΅μ ν
|
| 84 |
+
- β
μ€μΉ ν μλ κ²μ¦
|
| 85 |
+
- β
μ€ν¨ μ CPUλ‘ ν΄λ°±
|
| 86 |
|
| 87 |
---
|
| 88 |
|
|
|
|
| 178 |
|
| 179 |
## λ¬Έμ ν΄κ²°
|
| 180 |
|
| 181 |
+
### π₯ GPUκ° κ°μ§λμ§ μμ (torch.cuda.is_available() = False)
|
| 182 |
+
|
| 183 |
+
#### μ¦μ 1: Driver/library version mismatch
|
| 184 |
+
```bash
|
| 185 |
+
nvidia-smi
|
| 186 |
+
# μΆλ ₯: Failed to initialize NVML: Driver/library version mismatch
|
| 187 |
+
```
|
| 188 |
+
|
| 189 |
+
**μμΈ**: NVIDIA λλΌμ΄λ² μ
λ°μ΄νΈ ν μ¬λΆν
νμ§ μμ
|
| 190 |
+
|
| 191 |
+
**ν΄κ²°μ±
**:
|
| 192 |
+
```bash
|
| 193 |
+
# μμ€ν
μ¬λΆν
(κ°μ₯ κ°λ¨νκ³ ν¨κ³Όμ )
|
| 194 |
+
sudo reboot
|
| 195 |
+
```
|
| 196 |
+
|
| 197 |
+
μ¬λΆν
ν λ€μ νμΈ:
|
| 198 |
+
```bash
|
| 199 |
+
nvidia-smi
|
| 200 |
+
python setup.py # PyTorch μ¬μ€μΉ
|
| 201 |
+
```
|
| 202 |
+
|
| 203 |
+
#### μ¦μ 2: PyTorchκ° CPU λ²μ μΌλ‘ μ€μΉλ¨
|
| 204 |
+
```python
|
| 205 |
+
import torch
|
| 206 |
+
print(torch.__version__) # μΆλ ₯: 2.9.0+cpu (CUDA μμ)
|
| 207 |
+
```
|
| 208 |
+
|
| 209 |
+
**μμΈ**: pip install torchκ° κΈ°λ³Έ CPU λ²μ μ μ€μΉν¨
|
| 210 |
+
|
| 211 |
+
**ν΄κ²°μ±
**:
|
| 212 |
+
```bash
|
| 213 |
+
# νμ¬ PyTorch μ κ±°
|
| 214 |
+
pip uninstall torch torchvision torchaudio -y
|
| 215 |
+
|
| 216 |
+
# setup.pyλ‘ μ¬μ€μΉ (μλ CUDA κ°μ§)
|
| 217 |
+
python setup.py
|
| 218 |
+
```
|
| 219 |
+
|
| 220 |
+
#### μ¦μ 3: CUDA λ²μ λΆμΌμΉ
|
| 221 |
+
```python
|
| 222 |
+
# μμ€ν
CUDA: 12.8
|
| 223 |
+
# PyTorch CUDA: 12.4
|
| 224 |
+
# μ€λ₯: forward compatibility was attempted on non supported HW
|
| 225 |
+
```
|
| 226 |
+
|
| 227 |
+
**μμΈ**: PyTorch CUDA λ²μ κ³Ό λλΌμ΄λ² CUDA λ²μ λΆμΌμΉ
|
| 228 |
+
|
| 229 |
+
**ν΄κ²°μ±
**:
|
| 230 |
+
```bash
|
| 231 |
+
# 1. λλΌμ΄λ² μ¬λΆν
(μ°μ μλ)
|
| 232 |
+
sudo reboot
|
| 233 |
+
|
| 234 |
+
# 2. λλΌμ΄λ² μ¬μ€μΉ (μ¬λΆν
μΌλ‘ μ λλ©΄)
|
| 235 |
+
sudo ubuntu-drivers autoinstall
|
| 236 |
+
sudo reboot
|
| 237 |
+
|
| 238 |
+
# 3. PyTorch μ¬μ€μΉ
|
| 239 |
+
python setup.py
|
| 240 |
+
```
|
| 241 |
+
|
| 242 |
+
#### μ¦μ 4: nvidia-smiλ μλνμ§λ§ PyTorchμμ GPU μΈμ μ λ¨
|
| 243 |
+
```bash
|
| 244 |
+
nvidia-smi # β
μλ
|
| 245 |
+
python -c "import torch; print(torch.cuda.is_available())" # β False
|
| 246 |
+
```
|
| 247 |
+
|
| 248 |
+
**ν΄κ²°μ±
**:
|
| 249 |
+
```bash
|
| 250 |
+
# PyTorchλ₯Ό CUDA λ²μ μΌλ‘ κ°μ μ¬μ€μΉ
|
| 251 |
+
pip uninstall torch torchvision torchaudio -y
|
| 252 |
+
|
| 253 |
+
# CUDA λ²μ νμΈ
|
| 254 |
+
nvidia-smi | grep "CUDA Version" # μ: CUDA Version: 12.1
|
| 255 |
+
|
| 256 |
+
# ν΄λΉ CUDA λ²μ μ PyTorch μ€μΉ
|
| 257 |
+
# CUDA 12.1-12.3
|
| 258 |
+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121
|
| 259 |
+
|
| 260 |
+
# CUDA 12.4+
|
| 261 |
+
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
|
| 262 |
+
|
| 263 |
+
# κ²μ¦
|
| 264 |
+
python -c "import torch; print(f'CUDA available: {torch.cuda.is_available()}')"
|
| 265 |
+
```
|
| 266 |
+
|
| 267 |
### ImportError: spaces
|
| 268 |
**λ‘컬 νκ²½**:
|
| 269 |
```
|
|
|
|
| 272 |
|
| 273 |
### PyTorch λ²μ μΆ©λ
|
| 274 |
```bash
|
| 275 |
+
pip uninstall torch torchvision torchaudio -y
|
| 276 |
+
python setup.py # μλ CUDA κ°μ§ λ° μ€μΉ
|
| 277 |
```
|
| 278 |
|
| 279 |
+
### μ€μΉ κ²μ¦
|
| 280 |
+
```python
|
| 281 |
+
# μμ ν νκ²½ κ²μ¦
|
| 282 |
+
import torch
|
| 283 |
+
print(f"PyTorch: {torch.__version__}")
|
| 284 |
+
print(f"CUDA available: {torch.cuda.is_available()}")
|
| 285 |
+
print(f"CUDA compiled: {torch.version.cuda}")
|
| 286 |
+
if torch.cuda.is_available():
|
| 287 |
+
print(f"GPU name: {torch.cuda.get_device_name(0)}")
|
| 288 |
+
print(f"GPU count: {torch.cuda.device_count()}")
|
| 289 |
+
```
|
| 290 |
|
| 291 |
+
**μμ μΆλ ₯ (GPU νκ²½)**:
|
| 292 |
+
```
|
| 293 |
+
PyTorch: 2.5.1+cu124
|
| 294 |
+
CUDA available: True
|
| 295 |
+
CUDA compiled: 12.4
|
| 296 |
+
GPU name: NVIDIA GeForce RTX 4090
|
| 297 |
+
GPU count: 1
|
| 298 |
```
|
RTX_5080_README.md
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# RTX 5080 (Blackwell) Compatibility Notice
|
| 2 |
+
|
| 3 |
+
## Issue
|
| 4 |
+
|
| 5 |
+
The NVIDIA GeForce RTX 5080 uses the Blackwell architecture with compute capability **sm_120** (12.0). As of January 2025, PyTorch does not yet support this compute capability, even in nightly builds.
|
| 6 |
+
|
| 7 |
+
### Error Message
|
| 8 |
+
```
|
| 9 |
+
CUDA error: no kernel image is available for execution on the device
|
| 10 |
+
```
|
| 11 |
+
|
| 12 |
+
This occurs because PyTorch binaries are not compiled with kernels for sm_120.
|
| 13 |
+
|
| 14 |
+
## Current Status
|
| 15 |
+
|
| 16 |
+
- **GPU Model**: NVIDIA GeForce RTX 5080
|
| 17 |
+
- **Compute Capability**: sm_120 (12.0)
|
| 18 |
+
- **Driver Version**: 580.95.05 (supports CUDA 13.0)
|
| 19 |
+
- **PyTorch Version**: 2.7.0.dev20250310+cu124 (nightly)
|
| 20 |
+
- **PyTorch Supported Architectures**: sm_50, sm_60, sm_70, sm_75, sm_80, sm_86, sm_90
|
| 21 |
+
- **Support Status**: β Not supported
|
| 22 |
+
|
| 23 |
+
## Solution Implemented
|
| 24 |
+
|
| 25 |
+
The application now automatically detects Blackwell GPUs (compute capability β₯ 12.0) and falls back to CPU mode:
|
| 26 |
+
|
| 27 |
+
1. **Hardware Detection**: `test_cuda_compatibility()` checks compute capability
|
| 28 |
+
2. **Automatic Fallback**: Falls back to CPU if sm_120 is detected
|
| 29 |
+
3. **Clear Messaging**: Displays warnings about unsupported GPU
|
| 30 |
+
|
| 31 |
+
## Running the Application
|
| 32 |
+
|
| 33 |
+
The app will automatically run in CPU mode:
|
| 34 |
+
|
| 35 |
+
```bash
|
| 36 |
+
source venv/bin/activate
|
| 37 |
+
python app.py
|
| 38 |
+
```
|
| 39 |
+
|
| 40 |
+
You'll see messages like:
|
| 41 |
+
```
|
| 42 |
+
β οΈ Detected compute capability 12.0 (sm_120)
|
| 43 |
+
This GPU architecture is not yet supported by PyTorch
|
| 44 |
+
β οΈ Local - CPU fallback (NVIDIA GeForce RTX 5080 not supported by PyTorch)
|
| 45 |
+
```
|
| 46 |
+
|
| 47 |
+
## Future Support
|
| 48 |
+
|
| 49 |
+
PyTorch support for Blackwell GPUs is expected in future releases. Monitor:
|
| 50 |
+
- https://github.com/pytorch/pytorch/issues
|
| 51 |
+
- https://pytorch.org/get-started/locally/
|
| 52 |
+
|
| 53 |
+
When support is added:
|
| 54 |
+
1. Update PyTorch: `pip install --upgrade torch`
|
| 55 |
+
2. The app will automatically detect and use GPU
|
| 56 |
+
|
| 57 |
+
## Alternative Solutions
|
| 58 |
+
|
| 59 |
+
### 1. Build PyTorch from Source (Advanced)
|
| 60 |
+
```bash
|
| 61 |
+
# Clone PyTorch
|
| 62 |
+
git clone --recursive https://github.com/pytorch/pytorch
|
| 63 |
+
cd pytorch
|
| 64 |
+
|
| 65 |
+
# Set CUDA architecture flags
|
| 66 |
+
export TORCH_CUDA_ARCH_LIST="12.0"
|
| 67 |
+
export CUDA_HOME=/usr/local/cuda
|
| 68 |
+
|
| 69 |
+
# Build (takes 1-2 hours)
|
| 70 |
+
python setup.py develop
|
| 71 |
+
```
|
| 72 |
+
|
| 73 |
+
**Note**: This is time-consuming and may not work until PyTorch officially adds sm_120 support.
|
| 74 |
+
|
| 75 |
+
### 2. Use Older GPU (Temporary)
|
| 76 |
+
If available, use an older GPU (RTX 40xx, 30xx, etc.) that has compute capability β€ 9.0.
|
| 77 |
+
|
| 78 |
+
### 3. Wait for Official Support
|
| 79 |
+
The most practical approach is to use CPU mode until PyTorch adds official support.
|
| 80 |
+
|
| 81 |
+
## Performance Notes
|
| 82 |
+
|
| 83 |
+
**CPU Mode Performance**:
|
| 84 |
+
- Inference is slower but functional
|
| 85 |
+
- Small models (< 1B parameters): Acceptable
|
| 86 |
+
- Large models (> 7B parameters): Very slow
|
| 87 |
+
- Consider using smaller models for now
|
| 88 |
+
|
| 89 |
+
## Questions?
|
| 90 |
+
|
| 91 |
+
Check PyTorch compatibility:
|
| 92 |
+
```bash
|
| 93 |
+
python -c "import torch; print(f'CUDA available: {torch.cuda.is_available()}'); print(f'Compute capability: {torch.cuda.get_device_capability(0) if torch.cuda.is_available() else \"N/A\"}')"
|
| 94 |
+
```
|
app.py
CHANGED
|
@@ -14,6 +14,38 @@ import torch
|
|
| 14 |
# Hardware Environment Detection
|
| 15 |
# ============================================================================
|
| 16 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 17 |
def detect_hardware_environment():
|
| 18 |
"""
|
| 19 |
Comprehensive hardware environment detection
|
|
@@ -26,7 +58,8 @@ def detect_hardware_environment():
|
|
| 26 |
'gpu_name': str or None,
|
| 27 |
'cpu_count': int,
|
| 28 |
'os': 'Darwin' | 'Linux' | 'Windows',
|
| 29 |
-
'description': str
|
|
|
|
| 30 |
}
|
| 31 |
"""
|
| 32 |
env_info = {
|
|
@@ -36,7 +69,8 @@ def detect_hardware_environment():
|
|
| 36 |
'gpu_name': None,
|
| 37 |
'cpu_count': os.cpu_count() or 1,
|
| 38 |
'os': platform.system(),
|
| 39 |
-
'description': ''
|
|
|
|
| 40 |
}
|
| 41 |
|
| 42 |
# Check if running on HF Spaces
|
|
@@ -53,6 +87,7 @@ def detect_hardware_environment():
|
|
| 53 |
env_info['gpu_available'] = True
|
| 54 |
env_info['gpu_name'] = 'NVIDIA H200 (ZeroGPU)'
|
| 55 |
env_info['description'] = f"π HF Spaces - ZeroGPU ({space_id})"
|
|
|
|
| 56 |
except ImportError:
|
| 57 |
# Check CPU tier by memory/CPU count
|
| 58 |
cpu_count = env_info['cpu_count']
|
|
@@ -65,21 +100,37 @@ def detect_hardware_environment():
|
|
| 65 |
else:
|
| 66 |
# Local environment detection
|
| 67 |
if torch.cuda.is_available():
|
| 68 |
-
|
| 69 |
-
|
|
|
|
| 70 |
try:
|
| 71 |
-
|
| 72 |
except:
|
| 73 |
-
|
| 74 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 75 |
elif torch.backends.mps.is_available():
|
| 76 |
env_info['hardware'] = 'local_gpu'
|
| 77 |
env_info['gpu_available'] = True
|
| 78 |
env_info['gpu_name'] = 'Apple Silicon GPU (MPS)'
|
| 79 |
env_info['description'] = f"π Local - Apple Silicon GPU"
|
|
|
|
| 80 |
else:
|
| 81 |
env_info['hardware'] = 'local_cpu'
|
| 82 |
env_info['description'] = f"π» Local - CPU ({env_info['os']}, {env_info['cpu_count']} cores)"
|
|
|
|
| 83 |
|
| 84 |
return env_info
|
| 85 |
|
|
@@ -270,7 +321,7 @@ def load_model_once(model_index=None):
|
|
| 270 |
print(f" ποΈ Unloading previous model from memory...")
|
| 271 |
del model
|
| 272 |
del tokenizer
|
| 273 |
-
if
|
| 274 |
torch.cuda.empty_cache()
|
| 275 |
|
| 276 |
# Load tokenizer
|
|
@@ -284,17 +335,23 @@ def load_model_once(model_index=None):
|
|
| 284 |
if tokenizer.pad_token is None:
|
| 285 |
tokenizer.pad_token = tokenizer.eos_token
|
| 286 |
|
| 287 |
-
# Detect device
|
| 288 |
-
|
|
|
|
| 289 |
print(f"π Using device: {device}")
|
| 290 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 291 |
# Load model with appropriate settings
|
| 292 |
if is_cached:
|
| 293 |
print(f" π Loading model from disk cache (15-30 seconds)...")
|
| 294 |
else:
|
| 295 |
print(f" π Downloading model from network (5-20 minutes, first time only)...")
|
| 296 |
if device == "cuda":
|
| 297 |
-
# GPU available
|
| 298 |
model = AutoModelForCausalLM.from_pretrained(
|
| 299 |
model_name,
|
| 300 |
token=HF_TOKEN,
|
|
|
|
| 14 |
# Hardware Environment Detection
|
| 15 |
# ============================================================================
|
| 16 |
|
| 17 |
+
def test_cuda_compatibility():
|
| 18 |
+
"""
|
| 19 |
+
Test if CUDA actually works on this GPU.
|
| 20 |
+
RTX 5080 and other Blackwell GPUs (sm_120) are not yet supported by PyTorch.
|
| 21 |
+
Returns: True if CUDA works, False otherwise
|
| 22 |
+
"""
|
| 23 |
+
if not torch.cuda.is_available():
|
| 24 |
+
return False
|
| 25 |
+
|
| 26 |
+
try:
|
| 27 |
+
# Check compute capability first
|
| 28 |
+
compute_cap = torch.cuda.get_device_capability(0)
|
| 29 |
+
compute_cap_major = compute_cap[0]
|
| 30 |
+
compute_cap_minor = compute_cap[1]
|
| 31 |
+
|
| 32 |
+
# sm_120 (compute capability 12.0) is Blackwell and not yet supported
|
| 33 |
+
if compute_cap_major >= 12:
|
| 34 |
+
print(f"β οΈ Detected compute capability {compute_cap_major}.{compute_cap_minor} (sm_{compute_cap_major}{compute_cap_minor})")
|
| 35 |
+
print(f" This GPU architecture is not yet supported by PyTorch")
|
| 36 |
+
return False
|
| 37 |
+
|
| 38 |
+
# Try a simple tensor operation for other cases
|
| 39 |
+
x = torch.randn(10, 10).cuda()
|
| 40 |
+
y = torch.randn(10, 10).cuda()
|
| 41 |
+
z = torch.matmul(x, y)
|
| 42 |
+
z.cpu()
|
| 43 |
+
return True
|
| 44 |
+
except Exception as e:
|
| 45 |
+
print(f"β οΈ CUDA test failed: {e}")
|
| 46 |
+
print(f" Will fall back to CPU mode")
|
| 47 |
+
return False
|
| 48 |
+
|
| 49 |
def detect_hardware_environment():
|
| 50 |
"""
|
| 51 |
Comprehensive hardware environment detection
|
|
|
|
| 58 |
'gpu_name': str or None,
|
| 59 |
'cpu_count': int,
|
| 60 |
'os': 'Darwin' | 'Linux' | 'Windows',
|
| 61 |
+
'description': str,
|
| 62 |
+
'cuda_compatible': bool
|
| 63 |
}
|
| 64 |
"""
|
| 65 |
env_info = {
|
|
|
|
| 69 |
'gpu_name': None,
|
| 70 |
'cpu_count': os.cpu_count() or 1,
|
| 71 |
'os': platform.system(),
|
| 72 |
+
'description': '',
|
| 73 |
+
'cuda_compatible': False
|
| 74 |
}
|
| 75 |
|
| 76 |
# Check if running on HF Spaces
|
|
|
|
| 87 |
env_info['gpu_available'] = True
|
| 88 |
env_info['gpu_name'] = 'NVIDIA H200 (ZeroGPU)'
|
| 89 |
env_info['description'] = f"π HF Spaces - ZeroGPU ({space_id})"
|
| 90 |
+
env_info['cuda_compatible'] = True
|
| 91 |
except ImportError:
|
| 92 |
# Check CPU tier by memory/CPU count
|
| 93 |
cpu_count = env_info['cpu_count']
|
|
|
|
| 100 |
else:
|
| 101 |
# Local environment detection
|
| 102 |
if torch.cuda.is_available():
|
| 103 |
+
# CUDA is available, but test if it actually works
|
| 104 |
+
cuda_works = test_cuda_compatibility()
|
| 105 |
+
|
| 106 |
try:
|
| 107 |
+
gpu_name = torch.cuda.get_device_name(0)
|
| 108 |
except:
|
| 109 |
+
gpu_name = 'CUDA GPU'
|
| 110 |
+
|
| 111 |
+
if cuda_works:
|
| 112 |
+
env_info['hardware'] = 'local_gpu'
|
| 113 |
+
env_info['gpu_available'] = True
|
| 114 |
+
env_info['gpu_name'] = gpu_name
|
| 115 |
+
env_info['description'] = f"π₯οΈ Local - GPU ({gpu_name})"
|
| 116 |
+
env_info['cuda_compatible'] = True
|
| 117 |
+
else:
|
| 118 |
+
# CUDA detected but not working (e.g., unsupported compute capability)
|
| 119 |
+
env_info['hardware'] = 'local_cpu'
|
| 120 |
+
env_info['gpu_available'] = False
|
| 121 |
+
env_info['gpu_name'] = gpu_name + " (Unsupported - using CPU)"
|
| 122 |
+
env_info['description'] = f"β οΈ Local - CPU fallback ({gpu_name} not supported by PyTorch)"
|
| 123 |
+
env_info['cuda_compatible'] = False
|
| 124 |
elif torch.backends.mps.is_available():
|
| 125 |
env_info['hardware'] = 'local_gpu'
|
| 126 |
env_info['gpu_available'] = True
|
| 127 |
env_info['gpu_name'] = 'Apple Silicon GPU (MPS)'
|
| 128 |
env_info['description'] = f"π Local - Apple Silicon GPU"
|
| 129 |
+
env_info['cuda_compatible'] = False
|
| 130 |
else:
|
| 131 |
env_info['hardware'] = 'local_cpu'
|
| 132 |
env_info['description'] = f"π» Local - CPU ({env_info['os']}, {env_info['cpu_count']} cores)"
|
| 133 |
+
env_info['cuda_compatible'] = False
|
| 134 |
|
| 135 |
return env_info
|
| 136 |
|
|
|
|
| 321 |
print(f" ποΈ Unloading previous model from memory...")
|
| 322 |
del model
|
| 323 |
del tokenizer
|
| 324 |
+
if HW_ENV['cuda_compatible']:
|
| 325 |
torch.cuda.empty_cache()
|
| 326 |
|
| 327 |
# Load tokenizer
|
|
|
|
| 335 |
if tokenizer.pad_token is None:
|
| 336 |
tokenizer.pad_token = tokenizer.eos_token
|
| 337 |
|
| 338 |
+
# Detect device - use hardware environment detection
|
| 339 |
+
use_gpu = HW_ENV['gpu_available'] and HW_ENV['cuda_compatible']
|
| 340 |
+
device = "cuda" if use_gpu else "cpu"
|
| 341 |
print(f"π Using device: {device}")
|
| 342 |
|
| 343 |
+
if not use_gpu and torch.cuda.is_available():
|
| 344 |
+
print(f" β οΈ GPU detected but not compatible with PyTorch")
|
| 345 |
+
print(f" βΉοΈ RTX 5080 (Blackwell/sm_120) requires PyTorch with sm_120 support")
|
| 346 |
+
print(f" βΉοΈ Falling back to CPU mode")
|
| 347 |
+
|
| 348 |
# Load model with appropriate settings
|
| 349 |
if is_cached:
|
| 350 |
print(f" π Loading model from disk cache (15-30 seconds)...")
|
| 351 |
else:
|
| 352 |
print(f" π Downloading model from network (5-20 minutes, first time only)...")
|
| 353 |
if device == "cuda":
|
| 354 |
+
# GPU available and compatible
|
| 355 |
model = AutoModelForCausalLM.from_pretrained(
|
| 356 |
model_name,
|
| 357 |
token=HF_TOKEN,
|
requirements-local.txt
DELETED
|
@@ -1,25 +0,0 @@
|
|
| 1 |
-
# Local Development Requirements
|
| 2 |
-
# Use this for Mac/Linux/Windows local development
|
| 3 |
-
# Install: pip install -r requirements-local.txt
|
| 4 |
-
|
| 5 |
-
# Gradio Framework
|
| 6 |
-
gradio==5.49.1
|
| 7 |
-
|
| 8 |
-
# ML Core Libraries (Latest versions for local)
|
| 9 |
-
transformers==4.57.1
|
| 10 |
-
torch>=2.2.0 # No ZeroGPU restriction - use latest
|
| 11 |
-
safetensors==0.6.2
|
| 12 |
-
accelerate==0.26.1
|
| 13 |
-
|
| 14 |
-
# Tokenizers & Serialization
|
| 15 |
-
sentencepiece==0.2.0
|
| 16 |
-
protobuf==4.25.1
|
| 17 |
-
|
| 18 |
-
# HF Hub & Authentication
|
| 19 |
-
huggingface-hub>=0.19.0
|
| 20 |
-
|
| 21 |
-
# Environment Management
|
| 22 |
-
python-dotenv==1.0.0
|
| 23 |
-
|
| 24 |
-
# Note: 'spaces' package not needed for local development
|
| 25 |
-
# It will be imported conditionally and gracefully fail
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setup.py
CHANGED
|
@@ -14,25 +14,142 @@ def detect_environment():
|
|
| 14 |
is_hf_spaces = os.environ.get('SPACE_ID') is not None
|
| 15 |
return 'hf_spaces' if is_hf_spaces else 'local'
|
| 16 |
|
| 17 |
-
def
|
| 18 |
-
"""
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
if env == 'hf_spaces':
|
| 20 |
# ZeroGPU compatible version
|
| 21 |
-
return 'torch==2.2.0'
|
| 22 |
else:
|
| 23 |
-
#
|
|
|
|
|
|
|
| 24 |
# Check if Apple Silicon
|
| 25 |
-
if
|
| 26 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
else:
|
| 28 |
-
|
|
|
|
| 29 |
|
| 30 |
def install_dependencies():
|
| 31 |
"""Install dependencies based on environment"""
|
| 32 |
env = detect_environment()
|
| 33 |
-
print(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 34 |
|
| 35 |
-
# Base dependencies
|
| 36 |
base_deps = [
|
| 37 |
'gradio==5.49.1',
|
| 38 |
'transformers==4.57.1',
|
|
@@ -44,25 +161,58 @@ def install_dependencies():
|
|
| 44 |
'python-dotenv==1.0.0',
|
| 45 |
]
|
| 46 |
|
| 47 |
-
# Add PyTorch with appropriate version
|
| 48 |
-
pytorch = get_pytorch_version(env)
|
| 49 |
-
base_deps.insert(2, pytorch)
|
| 50 |
-
|
| 51 |
# Add spaces for HF Spaces only
|
| 52 |
if env == 'hf_spaces':
|
| 53 |
base_deps.append('spaces')
|
| 54 |
|
| 55 |
-
print(
|
| 56 |
-
print(f"Installing
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
|
| 58 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 59 |
subprocess.check_call([
|
| 60 |
sys.executable, '-m', 'pip', 'install', '--upgrade'
|
| 61 |
] + base_deps)
|
| 62 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
print("β
Installation complete!")
|
|
|
|
| 64 |
print(f"Environment: {env}")
|
| 65 |
-
print(f"PyTorch: {
|
|
|
|
|
|
|
| 66 |
|
| 67 |
if __name__ == '__main__':
|
| 68 |
install_dependencies()
|
|
|
|
| 14 |
is_hf_spaces = os.environ.get('SPACE_ID') is not None
|
| 15 |
return 'hf_spaces' if is_hf_spaces else 'local'
|
| 16 |
|
| 17 |
+
def detect_gpu_info():
|
| 18 |
+
"""Detect GPU model and CUDA version"""
|
| 19 |
+
gpu_model = None
|
| 20 |
+
cuda_version = None
|
| 21 |
+
|
| 22 |
+
try:
|
| 23 |
+
# Try nvidia-smi first
|
| 24 |
+
result = subprocess.run(
|
| 25 |
+
['nvidia-smi', '--query-gpu=gpu_name', '--format=csv,noheader'],
|
| 26 |
+
capture_output=True,
|
| 27 |
+
text=True,
|
| 28 |
+
timeout=5
|
| 29 |
+
)
|
| 30 |
+
if result.returncode == 0:
|
| 31 |
+
gpu_model = result.stdout.strip()
|
| 32 |
+
print(f" Detected GPU: {gpu_model}")
|
| 33 |
+
|
| 34 |
+
# Try to get CUDA version from nvcc
|
| 35 |
+
try:
|
| 36 |
+
nvcc_result = subprocess.run(
|
| 37 |
+
['nvcc', '--version'],
|
| 38 |
+
capture_output=True,
|
| 39 |
+
text=True,
|
| 40 |
+
timeout=5
|
| 41 |
+
)
|
| 42 |
+
if nvcc_result.returncode == 0:
|
| 43 |
+
output = nvcc_result.stdout
|
| 44 |
+
# Parse CUDA version (e.g., "release 12.1")
|
| 45 |
+
if 'release' in output:
|
| 46 |
+
version = output.split('release')[1].strip().split(',')[0].strip()
|
| 47 |
+
major_minor = '.'.join(version.split('.')[:2])
|
| 48 |
+
print(f" Detected CUDA version: {major_minor}")
|
| 49 |
+
cuda_version = major_minor
|
| 50 |
+
except (FileNotFoundError, subprocess.TimeoutExpired):
|
| 51 |
+
pass
|
| 52 |
+
|
| 53 |
+
# If nvcc not found, try to get CUDA version from nvidia-smi output
|
| 54 |
+
if not cuda_version:
|
| 55 |
+
result = subprocess.run(
|
| 56 |
+
['nvidia-smi'],
|
| 57 |
+
capture_output=True,
|
| 58 |
+
text=True,
|
| 59 |
+
timeout=5
|
| 60 |
+
)
|
| 61 |
+
for line in result.stdout.split('\n'):
|
| 62 |
+
if 'CUDA Version:' in line:
|
| 63 |
+
version = line.split('CUDA Version:')[1].strip().split()[0]
|
| 64 |
+
major_minor = '.'.join(version.split('.')[:2])
|
| 65 |
+
print(f" Detected CUDA version from nvidia-smi: {major_minor}")
|
| 66 |
+
cuda_version = major_minor
|
| 67 |
+
break
|
| 68 |
+
|
| 69 |
+
# GPU detected but CUDA version unknown, use latest
|
| 70 |
+
if not cuda_version:
|
| 71 |
+
print(" NVIDIA GPU detected but CUDA version unknown, using CUDA 12.4")
|
| 72 |
+
cuda_version = '12.4'
|
| 73 |
+
|
| 74 |
+
except (FileNotFoundError, subprocess.TimeoutExpired):
|
| 75 |
+
pass
|
| 76 |
+
|
| 77 |
+
return gpu_model, cuda_version
|
| 78 |
+
|
| 79 |
+
def requires_pytorch_2_6(gpu_model):
|
| 80 |
+
"""Check if GPU requires PyTorch 2.6.0+ (for Blackwell/compute capability 12.0+)"""
|
| 81 |
+
if not gpu_model:
|
| 82 |
+
return False
|
| 83 |
+
|
| 84 |
+
# Blackwell GPUs (RTX 50xx series) require PyTorch 2.6.0+
|
| 85 |
+
blackwell_gpus = ['rtx 50', 'rtx50', '5080', '5090', '5070']
|
| 86 |
+
gpu_lower = gpu_model.lower()
|
| 87 |
+
return any(model in gpu_lower for model in blackwell_gpus)
|
| 88 |
+
|
| 89 |
+
def get_pytorch_install_command(env):
|
| 90 |
+
"""Get appropriate PyTorch install command for environment"""
|
| 91 |
if env == 'hf_spaces':
|
| 92 |
# ZeroGPU compatible version
|
| 93 |
+
return (['torch==2.2.0'], None)
|
| 94 |
else:
|
| 95 |
+
# Local environment
|
| 96 |
+
system = platform.system()
|
| 97 |
+
|
| 98 |
# Check if Apple Silicon
|
| 99 |
+
if system == 'Darwin' and platform.machine() == 'arm64':
|
| 100 |
+
print(" Detected Apple Silicon, installing PyTorch with MPS support")
|
| 101 |
+
return (['torch>=2.2.0'], None)
|
| 102 |
+
|
| 103 |
+
# Check for CUDA on Linux/Windows
|
| 104 |
+
elif system in ['Linux', 'Windows']:
|
| 105 |
+
gpu_model, cuda_version = detect_gpu_info()
|
| 106 |
+
|
| 107 |
+
if cuda_version:
|
| 108 |
+
# Check if GPU requires PyTorch 2.6.0+
|
| 109 |
+
needs_pytorch_2_6 = requires_pytorch_2_6(gpu_model)
|
| 110 |
+
|
| 111 |
+
if needs_pytorch_2_6:
|
| 112 |
+
print(f" β οΈ Detected Blackwell GPU ({gpu_model})")
|
| 113 |
+
print(f" Installing PyTorch nightly with CUDA 12.4+ support (required for compute capability 12.0)")
|
| 114 |
+
print(f" Note: Stable PyTorch releases do not yet fully support sm_120")
|
| 115 |
+
# Use nightly build for Blackwell GPU support
|
| 116 |
+
return (['torch', 'torchvision', 'torchaudio'], 'https://download.pytorch.org/whl/nightly/cu124')
|
| 117 |
+
|
| 118 |
+
# Map CUDA version to PyTorch index URL
|
| 119 |
+
cuda_map = {
|
| 120 |
+
'11.8': ('cu118', 'https://download.pytorch.org/whl/cu118'),
|
| 121 |
+
'12.1': ('cu121', 'https://download.pytorch.org/whl/cu121'),
|
| 122 |
+
'12.2': ('cu121', 'https://download.pytorch.org/whl/cu121'), # Use 12.1 for 12.2
|
| 123 |
+
'12.3': ('cu121', 'https://download.pytorch.org/whl/cu121'), # Use 12.1 for 12.3
|
| 124 |
+
'12.4': ('cu124', 'https://download.pytorch.org/whl/cu124'),
|
| 125 |
+
'12.5': ('cu124', 'https://download.pytorch.org/whl/cu124'), # Use 12.4 for 12.5
|
| 126 |
+
'12.6': ('cu124', 'https://download.pytorch.org/whl/cu124'), # Use 12.4 for 12.6
|
| 127 |
+
'12.7': ('cu124', 'https://download.pytorch.org/whl/cu124'), # Use 12.4 for 12.7
|
| 128 |
+
'12.8': ('cu124', 'https://download.pytorch.org/whl/cu124'), # Use 12.4 for 12.8
|
| 129 |
+
'13.0': ('cu124', 'https://download.pytorch.org/whl/cu124'), # Use 12.4 for 13.0
|
| 130 |
+
}
|
| 131 |
+
|
| 132 |
+
cuda_suffix, index_url = cuda_map.get(cuda_version, ('cu124', 'https://download.pytorch.org/whl/cu124'))
|
| 133 |
+
print(f" Installing PyTorch with CUDA {cuda_version} support ({cuda_suffix})")
|
| 134 |
+
return (['torch', 'torchvision', 'torchaudio'], index_url)
|
| 135 |
+
else:
|
| 136 |
+
print(" No CUDA detected, installing CPU-only PyTorch")
|
| 137 |
+
return (['torch>=2.2.0'], None)
|
| 138 |
else:
|
| 139 |
+
# Other systems, default to CPU
|
| 140 |
+
return (['torch>=2.2.0'], None)
|
| 141 |
|
| 142 |
def install_dependencies():
|
| 143 |
"""Install dependencies based on environment"""
|
| 144 |
env = detect_environment()
|
| 145 |
+
print("=" * 60)
|
| 146 |
+
print(f"π Detected environment: {env}")
|
| 147 |
+
print("=" * 60)
|
| 148 |
+
|
| 149 |
+
# Get PyTorch installation command
|
| 150 |
+
pytorch_packages, index_url = get_pytorch_install_command(env)
|
| 151 |
|
| 152 |
+
# Base dependencies (excluding PyTorch)
|
| 153 |
base_deps = [
|
| 154 |
'gradio==5.49.1',
|
| 155 |
'transformers==4.57.1',
|
|
|
|
| 161 |
'python-dotenv==1.0.0',
|
| 162 |
]
|
| 163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 164 |
# Add spaces for HF Spaces only
|
| 165 |
if env == 'hf_spaces':
|
| 166 |
base_deps.append('spaces')
|
| 167 |
|
| 168 |
+
print("=" * 60)
|
| 169 |
+
print(f"π¦ Installing PyTorch...")
|
| 170 |
+
print("=" * 60)
|
| 171 |
+
|
| 172 |
+
# Install PyTorch (with optional index URL for CUDA)
|
| 173 |
+
pytorch_cmd = [sys.executable, '-m', 'pip', 'install', '--upgrade'] + pytorch_packages
|
| 174 |
+
if index_url:
|
| 175 |
+
pytorch_cmd.extend(['--index-url', index_url])
|
| 176 |
+
|
| 177 |
+
try:
|
| 178 |
+
subprocess.check_call(pytorch_cmd)
|
| 179 |
+
print("β
PyTorch installed successfully!")
|
| 180 |
+
except subprocess.CalledProcessError as e:
|
| 181 |
+
print(f"β PyTorch installation failed: {e}")
|
| 182 |
+
print(" Falling back to CPU-only PyTorch...")
|
| 183 |
+
subprocess.check_call([
|
| 184 |
+
sys.executable, '-m', 'pip', 'install', '--upgrade', 'torch>=2.2.0'
|
| 185 |
+
])
|
| 186 |
|
| 187 |
+
print("=" * 60)
|
| 188 |
+
print(f"π¦ Installing remaining dependencies ({len(base_deps)} packages)...")
|
| 189 |
+
print("=" * 60)
|
| 190 |
+
|
| 191 |
+
# Install remaining dependencies
|
| 192 |
subprocess.check_call([
|
| 193 |
sys.executable, '-m', 'pip', 'install', '--upgrade'
|
| 194 |
] + base_deps)
|
| 195 |
|
| 196 |
+
# Verify PyTorch installation
|
| 197 |
+
print("=" * 60)
|
| 198 |
+
print("π Verifying PyTorch installation...")
|
| 199 |
+
print("=" * 60)
|
| 200 |
+
try:
|
| 201 |
+
result = subprocess.run([
|
| 202 |
+
sys.executable, '-c',
|
| 203 |
+
'import torch; print(f"PyTorch: {torch.__version__}"); print(f"CUDA available: {torch.cuda.is_available()}"); print(f"CUDA version: {torch.version.cuda if torch.version.cuda else \"N/A\"}")'
|
| 204 |
+
], capture_output=True, text=True, timeout=10)
|
| 205 |
+
print(result.stdout)
|
| 206 |
+
except Exception as e:
|
| 207 |
+
print(f"β οΈ Could not verify PyTorch: {e}")
|
| 208 |
+
|
| 209 |
+
print("=" * 60)
|
| 210 |
print("β
Installation complete!")
|
| 211 |
+
print("=" * 60)
|
| 212 |
print(f"Environment: {env}")
|
| 213 |
+
print(f"PyTorch packages: {', '.join(pytorch_packages)}")
|
| 214 |
+
if index_url:
|
| 215 |
+
print(f"Index URL: {index_url}")
|
| 216 |
|
| 217 |
if __name__ == '__main__':
|
| 218 |
install_dependencies()
|