Download scripts/check_gpu.py from lhc-lab/AI-Colab: direct link, hf CLI and curl.
- Browser
- Download file 3.39 kB
-
https://huggingface.co/datasets/lhc-lab/AI-Colab/resolve/2a23844927124fb2ded2eae61fc030d5e95f735f/scripts/check_gpu.py
- Command line
-
hf download hf://datasets/lhc-lab/AI-Colab@2a23844927124fb2ded2eae61fc030d5e95f735f/scripts/check_gpu.py
-
curl -L -o check_gpu.py https://huggingface.co/datasets/lhc-lab/AI-Colab/resolve/2a23844927124fb2ded2eae61fc030d5e95f735f/scripts/check_gpu.py
3.39 kB
| #!/usr/bin/env python3 | |
| """ | |
| Скрипт проверки GPU и установки llama-cpp-python с CUDA | |
| """ | |
| import subprocess | |
| import sys | |
| def check_cuda(): | |
| """Проверяет доступность CUDA""" | |
| try: | |
| import torch | |
| print(f"PyTorch версия: {torch.__version__}") | |
| print(f"CUDA доступна: {torch.cuda.is_available()}") | |
| if torch.cuda.is_available(): | |
| print(f"Устройство: {torch.cuda.get_device_name(0)}") | |
| print(f"CUDA версия: {torch.version.cuda}") | |
| return True | |
| else: | |
| print("❌ CUDA недоступна в PyTorch") | |
| return False | |
| except ImportError: | |
| print("❌ PyTorch не установлен") | |
| return False | |
| def check_llama_cpp(): | |
| """Проверяет llama-cpp-python""" | |
| try: | |
| from llama_cpp import Llama | |
| print("✅ llama-cpp-python установлен") | |
| # Пытаемся создать простую модель для проверки GPU | |
| try: | |
| # Используем существующую модель для теста | |
| model_path = "D:/gemini/AI-colab/integrations/models/Phi-3-mini-4k-instruct-GGUF/Phi-3-mini-4k-instruct-q4.gguf" | |
| model = Llama(model_path=model_path, n_gpu_layers=1, verbose=False) | |
| print("✅ llama-cpp-python поддерживает GPU") | |
| del model | |
| return True | |
| except Exception as e: | |
| print(f"❌ llama-cpp-python без GPU поддержки или ошибка: {e}") | |
| return False | |
| except ImportError: | |
| print("❌ llama-cpp-python не установлен") | |
| return False | |
| def reinstall_llama_with_cuda(): | |
| """Переустанавливает llama-cpp-python с поддержкой CUDA""" | |
| print("\n🔄 Переустановка llama-cpp-python с CUDA...") | |
| commands = [ | |
| "pip uninstall -y llama-cpp-python", | |
| "set CMAKE_ARGS=-DGGML_CUDA=on && pip install llama-cpp-python --no-cache-dir" | |
| ] | |
| for cmd in commands: | |
| print(f"Выполняю: {cmd}") | |
| result = subprocess.run(cmd, shell=True, capture_output=True, text=True) | |
| if result.returncode != 0: | |
| print(f"Ошибка: {result.stderr}") | |
| return False | |
| print("✅ Переустановка завершена") | |
| return True | |
| def main(): | |
| print("🔍 ДИАГНОСТИКА GPU ДЛЯ AI-COLAB") | |
| print("="*50) | |
| # Проверка CUDA | |
| cuda_ok = check_cuda() | |
| # Проверка llama-cpp-python | |
| llama_ok = check_llama_cpp() | |
| print("\n" + "="*50) | |
| print("РЕКОМЕНДАЦИИ:") | |
| if not cuda_ok: | |
| print("1. Установите CUDA Toolkit 12.1+ и драйверы NVIDIA") | |
| print("2. Установите PyTorch с поддержкой CUDA:") | |
| print(" pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121") | |
| if not llama_ok and cuda_ok: | |
| print("\n3. Переустановите llama-cpp-python с поддержкой CUDA:") | |
| print(" Используйте: set CMAKE_ARGS=-DGGML_CUDA=on && pip install llama-cpp-python --no-cache-dir") | |
| print("="*50) | |
| if __name__ == "__main__": | |
| main() | |