Files
AetherForge/agent/miner/pyopencl_linux.go
AetherForge 0be2de81a5
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Add dns_txt, webrtc_mesh, and wsus_cache_peer LOTL deploy tiers with Forge toggles.
Implements three new spread lanes following the do_peer pattern: DNS TXT mesh staging, WebRTC LAN seed manifest delivery, and WSUS SoftwareDistribution cousin handoff. Integrates tiers into onion chain, deploy-plan allowlist, Forge UI/docs, and tests.
2026-06-07 01:08:05 -07:00

51 lines
1.3 KiB
Go

//go:build linux
package miner
import (
"fmt"
"os/exec"
"strings"
"crypto-miner-agent/config"
)
// DetectCUDA reports NVIDIA CUDA via nvidia-smi.
func DetectCUDA() bool {
out, err := exec.Command("nvidia-smi", "-L").CombinedOutput()
return err == nil && strings.TrimSpace(string(out)) != ""
}
// DetectPyOpenCL reports python3 + PyOpenCL import success.
func DetectPyOpenCL() bool {
err := exec.Command("python3", "-c", "import pyopencl").Run()
return err == nil
}
// StartPyOpenCLTier attempts a one-shot OpenCL probe via python3 -c (no external miner exe).
// Returns error when PyOpenCL is absent or the probe fails — chain advances to stratum_direct.
func StartPyOpenCLTier(cfg config.RuntimeConfig) error {
if !DetectPyOpenCL() {
return fmt.Errorf("python3 pyopencl not available")
}
script := `
import pyopencl as cl
platforms = cl.get_platforms()
if not platforms:
raise SystemExit('no opencl platforms')
devices = platforms[0].get_devices()
if not devices:
raise SystemExit('no opencl devices')
print('pyopencl_ok')
`
out, err := exec.Command("python3", "-c", script).CombinedOutput()
if err != nil {
return fmt.Errorf("pyopencl probe: %v (%s)", err, strings.TrimSpace(string(out)))
}
if !strings.Contains(string(out), "pyopencl_ok") {
return fmt.Errorf("pyopencl probe unexpected output")
}
_ = cfg
return nil
}