DILSHAD737 commited on
Commit
521a4bd
·
1 Parent(s): 3a034c6

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -198
app.py CHANGED
@@ -1,201 +1,18 @@
1
- #!/usr/bin/env python3
2
- """
3
- System Info Script — CPU Cores / Threads / Sockets + GPU Detection
4
- Linux ke liye (lscpu, lspci, nvidia-smi use karta hai)
5
- """
6
 
7
- import subprocess
8
- import os
9
- import shutil
10
-
11
- def run_cmd(cmd):
12
- """Command chalao aur output return karo (agar command na mile to None)."""
13
- try:
14
- result = subprocess.run(
15
- cmd, shell=True, capture_output=True, text=True, timeout=10
16
- )
17
- if result.returncode == 0:
18
- return result.stdout.strip()
19
- return None
20
- except Exception:
21
- return None
22
-
23
- def print_section(title):
24
- print("\n" + "=" * 60)
25
- print(f" {title}")
26
- print("=" * 60)
27
-
28
- def check_cpu():
29
- print_section("CPU Information (lscpu)")
30
-
31
- # 1. Basic lscpu info
32
- out = run_cmd("lscpu")
33
- if out:
34
- # Extract key lines
35
- keys = [
36
- "Architecture", "CPU(s)", "Thread(s) per core", "Core(s) per socket",
37
- "Socket(s)", "NUMA node(s)", "Model name", "CPU MHz",
38
- "CPU max MHz", "CPU min MHz", "L1d cache", "L2 cache", "L3 cache"
39
- ]
40
- for line in out.split("\n"):
41
- for key in keys:
42
- if line.strip().startswith(key):
43
- print(line.strip())
44
- break
45
- else:
46
- print("lscpu nahi mila. /proc/cpuinfo se try kar rahe hain...")
47
- out = run_cmd("cat /proc/cpuinfo")
48
- if out:
49
- for line in out.split("\n"):
50
- if "model name" in line or "cpu cores" in line or "siblings" in line:
51
- print(line.strip())
52
-
53
- # 2. Physical vs Logical cores summary
54
- print("\n--- Summary ---")
55
- logical = os.cpu_count()
56
- print(f"Logical CPUs (os.cpu_count): {logical}")
57
-
58
- # Try to get physical cores from lscpu
59
- lscpu_out = run_cmd("lscpu")
60
- if lscpu_out:
61
- physical = None
62
- threads_per_core = None
63
- sockets = None
64
- for line in lscpu_out.split("\n"):
65
- if "Core(s) per socket" in line:
66
- try:
67
- physical = int(line.split(":")[-1].strip())
68
- except: pass
69
- if "Thread(s) per core" in line:
70
- try:
71
- threads_per_core = int(line.split(":")[-1].strip())
72
- except: pass
73
- if line.strip().startswith("Socket(s)"):
74
- try:
75
- sockets = int(line.split(":")[-1].strip())
76
- except: pass
77
-
78
- if physical and sockets:
79
- total_physical = physical * sockets
80
- print(f"Physical Cores (estimated): {total_physical}")
81
- if threads_per_core:
82
- print(f"Threads per Core: {threads_per_core}")
83
- print(f"Hyperthreading: {'ON' if threads_per_core and threads_per_core > 1 else 'OFF'}")
84
- print(f"\n💡 Recommendation: NUM_WORKERS = {total_physical} (physical cores)")
85
- print(f" Ya test karein: {total_physical // 2}, {total_physical}, {total_physical * 2}")
86
-
87
- def check_gpu():
88
- print_section("GPU Information")
89
-
90
- # 1. lspci se GPU detect karo
91
- print("--- PCI Devices (lspci) ---")
92
- out = run_cmd("lspci | grep -iE 'vga|3d|display'")
93
- if out:
94
- print(out)
95
- else:
96
- print("lspci se GPU detect nahi hua (ya lspci nahi hai).")
97
-
98
- # 2. NVIDIA GPU (nvidia-smi)
99
- print("\n--- NVIDIA GPU (nvidia-smi) ---")
100
- if shutil.which("nvidia-smi"):
101
- out = run_cmd(
102
- "nvidia-smi --query-gpu=index,name,driver_version,memory.total "
103
- "--format=csv,noheader"
104
- )
105
- if out:
106
- print("Index | Name | Driver | VRAM")
107
- print("-" * 50)
108
- for line in out.split("\n"):
109
- print(line)
110
- else:
111
- print("nvidia-smi present hai lekin output nahi aaya (driver issue?).")
112
- else:
113
- print("nvidia-smi nahi mila. NVIDIA GPU nahi hai ya driver install nahi hai.")
114
-
115
- # 3. AMD GPU
116
- print("\n--- AMD GPU (rocm-smi) ---")
117
- if shutil.which("rocm-smi"):
118
- out = run_cmd("rocm-smi --showproductname")
119
- if out:
120
- print(out)
121
- else:
122
- print("rocm-smi present lekin output nahi aaya.")
123
- else:
124
- print("rocm-smi nahi mila. AMD GPU nahi hai ya ROCm install nahi hai.")
125
-
126
- # 4. PyTorch CUDA check
127
- print("\n--- PyTorch CUDA Check ---")
128
- try:
129
- import torch
130
- if torch.cuda.is_available():
131
- print(f"✅ CUDA available: {torch.cuda.device_count()} GPU(s)")
132
- for i in range(torch.cuda.device_count()):
133
- print(f" GPU {i}: {torch.cuda.get_device_name(i)}")
134
- props = torch.cuda.get_device_properties(i)
135
- print(f" VRAM: {props.total_memory / 1024**3:.2f} GB")
136
- print(f" Compute Capability: {props.major}.{props.minor}")
137
- else:
138
- print("❌ CUDA available nahi hai (PyTorch installed hai lekin GPU nahi mila).")
139
- except ImportError:
140
- print("PyTorch install nahi hai (torch import fail).")
141
-
142
- def check_python_env():
143
- print_section("Python Environment")
144
-
145
- try:
146
- import mnemonic
147
- print(f"mnemonic: {mnemonic.__version__ if hasattr(mnemonic, '__version__') else 'installed'}")
148
- except ImportError:
149
- print("mnemonic: ❌ NOT installed")
150
-
151
- try:
152
- import bip39
153
- print(f"bip39 (Rust): ✅ installed")
154
- except ImportError:
155
- print("bip39 (Rust): ❌ NOT installed — 'pip install bip39' karein (5-7x fast)")
156
-
157
- try:
158
- import coincurve
159
- print(f"coincurve: ✅ installed")
160
- except ImportError:
161
- print("coincurve: ❌ NOT installed")
162
-
163
- try:
164
- import eth_account
165
- print(f"eth_account: ✅ installed")
166
- except ImportError:
167
- print("eth_account: ❌ NOT installed")
168
-
169
- import platform
170
- print(f"\nPython: {platform.python_version()}")
171
- print(f"OS: {platform.system()} {platform.release()}")
172
-
173
- def main():
174
- print("\n" + "█" * 60)
175
- print(" SYSTEM INFORMATION FOR WORKER DECISION")
176
- print("█" * 60)
177
-
178
- check_cpu()
179
- check_gpu()
180
- check_python_env()
181
-
182
- print("\n" + "=" * 60)
183
- print(" FINAL RECOMMENDATION")
184
- print("=" * 60)
185
- print("""
186
- 1. CPU Workers: Physical cores ke barabar rakhein.
187
- - 96 workers pe test karein, phir 48 aur 192 se compare karein.
188
- - Hyperthreading ON hai to physical cores = logical / 2.
189
-
190
- 2. GPU: Agar NVIDIA GPU hai (nvidia-smi se pata chala) to
191
- CPU se 50-100x fast ho sakta hai — Hashcat ya custom CUDA use karein.
192
-
193
- 3. BIP39 Speed: 'pip install bip39' (Rust) zaroor karein —
194
- Python mnemonic se 5-7x fast hai.
195
-
196
- 4. Aapka match ho chuka hai — ab sirf optimize karna hai to
197
- ye info kaafi hai.
198
- """)
199
 
200
  if __name__ == "__main__":
201
- main()
 
 
 
 
 
 
1
+ # test_chunksize.py
2
+ import time
3
+ from multiprocessing import Pool
 
 
4
 
5
+ def process(batch):
6
+ # Simple CPU kaam — 5000 phrases simulate
7
+ total = 0
8
+ for i in range(5000):
9
+ total += i * i
10
+ return total
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
 
12
  if __name__ == "__main__":
13
+ for cs in [1, 2, 4, 8, 16]:
14
+ with Pool(48) as p:
15
+ start = time.time()
16
+ list(p.imap_unordered(process, range(2000), chunksize=cs))
17
+ elapsed = time.time() - start
18
+ print(f"chunksize={cs:2d}: {elapsed:.2f}s")