-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_complete_benchmark.sh
More file actions
executable file
Β·159 lines (127 loc) Β· 5.05 KB
/
run_complete_benchmark.sh
File metadata and controls
executable file
Β·159 lines (127 loc) Β· 5.05 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
#!/bin/bash
# Complete Deep Learning Benchmark Script: Python vs Rust
# This script runs all working combinations systematically
set -e
echo "π Starting Complete Deep Learning Benchmark Suite"
echo "=============================================="
# Setup environment variables
export CUBLAS_WORKSPACE_CONFIG=:4096:8
export CUDA_VISIBLE_DEVICES=0
export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH
export LIBTORCH=/home/$USER/miniforge3/envs/cpp-torch
export PYTHONPATH=/home/shiro/Projects/Paper1
# Function to run Python benchmark
run_python_benchmark() {
local dataset=$1
local architecture=$2
local device=$3
local run_id="python_${dataset}_${architecture}_${device}_complete"
echo "π Running Python: $dataset + $architecture + $device"
# Convert device names for Python (gpu->cuda, cpu->cpu)
local py_device=$device
if [ "$device" = "gpu" ]; then
py_device="cuda"
fi
source .venv/bin/activate
python src/python/deep_learning/cnn_benchmark.py \
--dataset $dataset \
--architecture $architecture \
--mode training \
--run-id $run_id \
--device $py_device
echo "β
Completed: $run_id"
echo ""
}
# Function to run Rust benchmark
run_rust_benchmark() {
local dataset=$1
local architecture=$2
local device=$3
local run_id="rust_${dataset}_${architecture}_${device}_complete"
echo "π¦ Running Rust: $dataset + $architecture + $device"
# Convert device names for Rust (gpu->cuda, cpu->cpu)
local rust_device=$device
if [ "$device" = "gpu" ]; then
rust_device="cuda"
fi
cd src/rust/deep_learning/cnn_benchmark
# Set proper library path for Rust + CUDA
export LD_LIBRARY_PATH=/home/$USER/miniforge3/envs/cpp-torch/lib:/usr/lib/wsl/lib:$LD_LIBRARY_PATH
cargo run --release -- \
--dataset $dataset \
--architecture $architecture \
--mode training \
--run-id $run_id \
--device $rust_device \
--epochs 10
cd ../../../../
echo "β
Completed: $run_id"
echo ""
}
# Function to copy results
copy_results() {
echo "π Copying all results to project root..."
cp src/rust/deep_learning/cnn_benchmark/*_complete_training_results.json . 2>/dev/null || true
echo "β
Results copied"
echo ""
}
# Main benchmark execution
echo "π― Phase 1: SYNTHETIC DATASET BENCHMARKS"
echo "========================================"
echo "--- Simple CNN on Synthetic Dataset ---"
run_python_benchmark synthetic simple_cnn gpu
run_python_benchmark synthetic simple_cnn cpu
run_rust_benchmark synthetic simple_cnn gpu
run_rust_benchmark synthetic simple_cnn cpu
echo "--- ResNet18 on Synthetic Dataset ---"
run_python_benchmark synthetic resnet18 gpu
# Note: Rust ResNet18 with synthetic fails due to channel mismatch (expects 3-ch, gets 1-ch)
echo ""
echo "π― Phase 2: CIFAR-10 DATASET BENCHMARKS"
echo "======================================="
echo "--- ResNet18 on CIFAR-10 Dataset ---"
run_python_benchmark cifar10 resnet18 gpu
run_python_benchmark cifar10 resnet18 cpu
run_rust_benchmark cifar10 resnet18 gpu
run_rust_benchmark cifar10 resnet18 cpu
echo "--- VGG16 on CIFAR-10 Dataset ---"
run_python_benchmark cifar10 vgg16 gpu || echo "β οΈ Python VGG16 failed or not implemented"
run_rust_benchmark cifar10 vgg16 gpu || echo "β οΈ Rust VGG16 failed or not implemented"
echo ""
echo "π― Phase 3: CIFAR-100 DATASET BENCHMARKS"
echo "========================================="
echo "--- ResNet18 on CIFAR-100 Dataset ---"
run_python_benchmark cifar100 resnet18 gpu || echo "β οΈ Python CIFAR-100 failed"
run_rust_benchmark cifar100 resnet18 gpu || echo "β οΈ Rust CIFAR-100 failed"
echo ""
echo "π― Phase 4: MNIST DATASET BENCHMARKS"
echo "===================================="
echo "--- Simple CNN on MNIST Dataset ---"
run_python_benchmark mnist simple_cnn gpu || echo "β οΈ Python MNIST Simple CNN failed"
run_rust_benchmark mnist simple_cnn gpu || echo "β οΈ Rust MNIST Simple CNN failed"
echo "--- LeNet on MNIST Dataset ---"
run_python_benchmark mnist lenet gpu || echo "β οΈ Python LeNet failed"
run_rust_benchmark mnist lenet gpu || echo "β οΈ Rust LeNet failed"
echo ""
echo "π― Phase 5: COLLECTING RESULTS"
echo "=============================="
copy_results
echo "π Listing all benchmark result files:"
ls -la *_complete_training_results.json 2>/dev/null || echo "No complete results found yet"
echo ""
echo "π BENCHMARK SUITE COMPLETED!"
echo "============================="
echo ""
echo "π Result files are saved with pattern: *_complete_training_results.json"
echo "π Each file contains detailed metrics for:"
echo " - Training time (seconds)"
echo " - Memory usage (peak/average MB)"
echo " - Model accuracy (%)"
echo " - GPU memory usage (MB)"
echo " - Resource utilization"
echo ""
echo "π Next steps:"
echo " 1. Check all *_complete_training_results.json files"
echo " 2. Provide results to Claude for comprehensive analysis"
echo " 3. Generate final comparison tables and recommendations"
echo ""