docker: warn, not stop, on a host CPU without AVX2 (#1584)

This commit is contained in:
Niko1221 committed 2026-10-09 03:15:12 +02:00
1 parent 224bb6f899
commit 9d64b93a0f
2 files changed
+30

No files matched your search

+10
View File
@@ -6,6 +6,16 @@
set -e
cd /opt/strata || exit 1
# #1584: the engine in the image is built with AVX2 CPU kernels. A host CPU without AVX2 (Sandy / Ivy Bridge Xeons,
# Bulldozer) runs it into an illegal instruction. A warning, not a stop: recommend, never force (the flags file
# can be wrong in a VM, and a build made on that host may be fine). STRATA_CPUINFO is for the test.
cpuinfo="${STRATA_CPUINFO:-/proc/cpuinfo}"
if [ -r "$cpuinfo" ] && grep -q '^flags' "$cpuinfo" && ! grep -m1 '^flags' "$cpuinfo" | grep -qw avx2; then
echo "WARNING: this host CPU has no AVX2. The engine in this image is built for CPUs with AVX2, so it may stop" >&2
echo " with 'illegal instruction' (exit 132). Build the image on this machine (docker build), which compiles the" >&2
echo " engine for the CPU it runs on, and see docs/INSTALL.md (Older CPUs, experimental) for the older-CPU build." >&2
fi
STRATA_DATA="${STRATA_DATA:-/data}"
FAMILY="${FAMILY:-qwen}"
MODEL="${MODEL:-IQ2_XS}"
+20
View File
@@ -95,6 +95,26 @@ class Entrypoint(unittest.TestCase):
self.assertIn("by-model", out)
self.assertIn(f"Config: {self.data}/config/strata-iq3_s.json", out)
def warning_for(self, flags):
info = self.tmp / "cpuinfo"
info.write_text(f"processor : 0
flags : {flags}
")
(self.data / "config" / "strata-iq3_s.json").write_text('{"args": ["x"]}
')
env = dict(os.environ, STRATA_DATA=str(self.data), MODEL="IQ3_S", REINSTALL="0", STRATA_CPUINFO=str(info))
r = subprocess.run([SH, str(self.script)], env=env, capture_output=True, text=True, timeout=60)
self.assertEqual(r.returncode, 0, r.stderr) # a warning, never a stop (#1584)
return r.stderr
def test_a_cpu_without_avx2_is_warned_not_stopped(self):
err = self.warning_for("fpu sse4_2 avx aes")
self.assertIn("no AVX2", err)
self.assertIn("docker build", err)
def test_a_cpu_with_avx2_gets_no_warning(self):
self.assertEqual(self.warning_for("fpu sse4_2 avx avx2 fma"), "")
if __name__ == "__main__":
unittest.main()