forked from geeknik/mmm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_gpu.py
More file actions
74 lines (60 loc) · 2.43 KB
/
test_gpu.py
File metadata and controls
74 lines (60 loc) · 2.43 KB
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env python3
"""
Test GPU acceleration
"""
import sys
sys.path.insert(0, '/home/geeknik/dev/mmm')
from pathlib import Path
import numpy as np
import librosa
import time
def test_gpu_acceleration():
print("🚀 Testing GPU Acceleration")
print("=" * 50)
# Test GPU availability
print("\n1. Testing GPU packages...")
try:
import torch
print(f"✅ PyTorch installed: {torch.__version__}")
print(f" CUDA available: {torch.cuda.is_available()}")
if torch.cuda.is_available():
print(f" GPU: {torch.cuda.get_device_name(0)}")
print(f" VRAM: {torch.cuda.get_device_properties(0).total_memory / 1024**3:.1f} GB")
except ImportError as e:
print(f"❌ PyTorch not available: {e}")
try:
import cupy as cp
print(f"✅ CuPy installed: {cp.__version__}")
print(f" CUDA devices: {cp.cuda.runtime.getDeviceCount()}")
except ImportError as e:
print(f"❌ CuPy not available: {e}")
# Test optimized processor
print("\n2. Testing Optimized Processor...")
try:
from mmm.optimized_processor import OptimizedAudioProcessor, GPUAcceleratedWatermarkDetector
processor = OptimizedAudioProcessor(use_gpu=True, use_multiprocessing=True)
# Load short audio sample for testing
file_path = Path("Schizo Shaman.mp3")
if file_path.exists():
print(f" Loading audio sample...")
audio, sr = processor.load_audio_optimized(file_path)
print(f" Audio shape: {audio.shape}")
print(f" Sample rate: {sr}")
print(f" Duration: {len(audio)/sr:.1f} seconds")
# Test GPU watermark detection on short sample
short_audio = audio[:48000] # 1 second
print(f" Testing GPU watermark detection on 1-second sample...")
gpu_detector = GPUAcceleratedWatermarkDetector()
start_time = time.time()
result = gpu_detector.detect_spectral_patterns_gpu(short_audio, sr)
elapsed = time.time() - start_time
print(f" ✅ GPU detection completed in {elapsed:.2f} seconds")
print(f" Result: {result}")
else:
print("❌ Schizo Shaman.mp3 not found")
except Exception as e:
print(f"❌ Optimized processor error: {e}")
import traceback
traceback.print_exc()
if __name__ == "__main__":
test_gpu_acceleration()