MCPcopy Create free account
hub / github.com/RightNow-AI/autokernel / detect_gpu

Function detect_gpu

profile.py:170–193  ·  view source on GitHub ↗

Try to import detect_gpu from bench.py; fall back to standalone.

()

Source from the content-addressed store, hash-verified

168
169
170def detect_gpu() -> GPUSpec:
171 """Try to import detect_gpu from bench.py; fall back to standalone."""
172 try:
173 bench_path = os.path.join(os.path.dirname(os.path.abspath(__file__)), "bench.py")
174 spec = importlib.util.spec_from_file_location("bench", bench_path)
175 if spec and spec.loader:
176 bench_mod = importlib.util.module_from_spec(spec)
177 spec.loader.exec_module(bench_mod) # type: ignore[union-attr]
178 gpu = bench_mod.detect_gpu() # type: ignore[attr-defined]
179 # Convert to our local GPUSpec (fields are identical)
180 return GPUSpec(
181 name=gpu.name,
182 sm_count=gpu.sm_count,
183 memory_gb=gpu.memory_gb,
184 peak_tflops_fp16=gpu.peak_tflops_fp16,
185 peak_tflops_bf16=gpu.peak_tflops_bf16,
186 peak_tflops_fp32=gpu.peak_tflops_fp32,
187 peak_bandwidth_gb_s=gpu.peak_bandwidth_gb_s,
188 l2_cache_mb=gpu.l2_cache_mb,
189 compute_capability=gpu.compute_capability,
190 )
191 except Exception:
192 pass
193 return _fallback_detect_gpu()
194
195
196# ---------------------------------------------------------------------------

Callers 1

mainFunction · 0.70

Calls 2

_fallback_detect_gpuFunction · 0.85
GPUSpecClass · 0.70

Tested by

no test coverage detected