-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_gpu.py
More file actions
34 lines (27 loc) · 998 Bytes
/
check_gpu.py
File metadata and controls
34 lines (27 loc) · 998 Bytes
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
import os
# Backend must be set BEFORE importing keras
os.environ["KERAS_BACKEND"] = "torch"
import keras
import torch
print(
f"--- Environment: Keras {keras.__version__} | Backend: {keras.backend.backend()} ---"
)
# Verify hardware visibility
cuda_ready = torch.cuda.is_available()
print(f"CUDA Available: {cuda_ready}")
if cuda_ready:
print(f"GPU: {torch.cuda.get_device_name(0)}")
print(f"Device Count: {torch.cuda.device_count()}")
print("\n--- Running MatMul Stress Test ---")
try:
# Forcing a large operation to ensure the 1650 Ti is actually engaged
with keras.device("cuda"):
x = keras.random.normal((5000, 5000))
y = keras.random.normal((5000, 5000))
z = keras.ops.matmul(x, y)
print(f"Tensor Move Success: {z.device}")
print("GPU Compute: OK")
except Exception as e:
print(f"Compute Failed: {e}")
else:
print("\n[!] GPU not found. Check drivers or CUDA installation.")