Spaces:
Runtime error
Runtime error
Download app.py from mapleadmin/GPT: direct link, hf CLI and curl.
- Browser
- Download file 705 Bytes
-
https://huggingface.co/spaces/mapleadmin/GPT/resolve/refs%2Fpr%2F2/app.py
- Command line
-
hf download hf://spaces/mapleadmin/GPT@refs/pr/2/app.py
-
curl -L -o app.py https://huggingface.co/spaces/mapleadmin/GPT/resolve/refs%2Fpr%2F2/app.py
705 Bytes
| import subprocess | |
| def get_gpu_utilization(): | |
| try: | |
| # Run the nvidia-smi command to get GPU utilization | |
| cmd = "nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits" | |
| result = subprocess.check_output(cmd, shell=True, encoding="utf-8") | |
| # Parse and return GPU utilization as a float | |
| gpu_utilization = float(result.strip()) | |
| return gpu_utilization | |
| except Exception as e: | |
| print(f"Error: {e}") | |
| return None | |
| # Get and print GPU utilization | |
| gpu_utilization = get_gpu_utilization() | |
| if gpu_utilization is not None: | |
| print(f"GPU Utilization: {gpu_utilization}%") | |
| else: | |
| print("GPU Utilization information not available.") | |