From 2e09906a0877d3c9265dee204e0c21aa3df2cebe Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sun, 30 Aug 2026 10:05:19 +0200 Subject: [PATCH] Keep the export venv off tmpfs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit `mktemp -d` lands in `/tmp`, which on this and most current Linux distributions is a tmpfs — memory, not disk, sized at half of RAM. The venv this script builds installs torch into it, several gigabytes, and the failure mode is not subtle: error: Failed to install: torch-2.13.0-...whl Caused by: No space left on device (os error 28) on a machine with 102 GB free on the filesystem holding `/var/tmp`. The quieter version of the same bug is worse: when it does fit, it evicts whatever the user had in page cache to make room. `${TMPDIR:-/var/tmp}` respects an explicit TMPDIR and otherwise picks the disk-backed directory, which is what a multi-gigabyte throwaway wants. Co-Authored-By: Claude Opus 5 (1M context) --- tools/export-seg-model.sh | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/export-seg-model.sh b/tools/export-seg-model.sh index 911effa..261fad5 100755 --- a/tools/export-seg-model.sh +++ b/tools/export-seg-model.sh @@ -28,7 +28,12 @@ OUT="${REPO}/models/segment" MODEL="${1:-yolo26n-seg}" IMGSZ="${2:-640}" -WORK="$(mktemp -d)" +# Not `mktemp -d`: the default TMPDIR is `/tmp`, which on most current Linux +# distributions is a tmpfs — RAM, sized at half of physical memory. The venv +# below pulls torch, several gigabytes of it, and installing that into RAM +# either evicts the user's page cache or fails outright with ENOSPC on a +# machine that has hundreds of gigabytes of actual disk free. +WORK="$(mktemp -d -p "${TMPDIR:-/var/tmp}")" trap 'rm -rf "${WORK}"' EXIT echo "==> exporting ${MODEL} at imgsz=${IMGSZ} in ${WORK}"