Download scripts/verify_cuda_simple.py from lhc-lab/AI-Colab: direct link, hf CLI and curl.
- Browser
- Download file 1.18 kB
-
https://huggingface.co/datasets/lhc-lab/AI-Colab/resolve/main/scripts/verify_cuda_simple.py
- Command line
-
hf download hf://datasets/lhc-lab/AI-Colab/scripts/verify_cuda_simple.py
-
curl -L -o verify_cuda_simple.py https://huggingface.co/datasets/lhc-lab/AI-Colab/resolve/main/scripts/verify_cuda_simple.py
1.18 kB
| import llama_cpp | |
| from llama_cpp import Llama | |
| import sys | |
| def check_cuda(): | |
| print(f"Python version: {sys.version}") | |
| print(f"Llama-cpp-python version: {llama_cpp.__version__}") | |
| model_path = "D:/gemini/AI-colab/integrations/models/Phi-3-mini-4k-instruct-GGUF/Phi-3-mini-4k-instruct-q4.gguf" | |
| print(f"Testing model loading with n_gpu_layers=1...") | |
| try: | |
| # Пытаемся загрузить модель с 1 слоем на GPU. | |
| # Если CUDA не поддерживается, это либо вызовет ошибку, либо проигнорируется (но в выводе будет видно). | |
| model = Llama( | |
| model_path=model_path, | |
| n_gpu_layers=1, | |
| verbose=True | |
| ) | |
| print("\n✅ Llama instance created.") | |
| # Проверяем атрибуты, указывающие на CUDA | |
| # В новых версиях llama-cpp-python можно проверить backend | |
| print("✅ Check completed.") | |
| del model | |
| except Exception as e: | |
| print(f"\n❌ Error during model loading: {e}") | |
| if __name__ == "__main__": | |
| check_cuda() | |