Keep the export venv off tmpfs
`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) <noreply@anthropic.com>
This commit is contained in:
@@ -28,7 +28,12 @@ OUT="${REPO}/models/segment"
|
|||||||
|
|
||||||
MODEL="${1:-yolo26n-seg}"
|
MODEL="${1:-yolo26n-seg}"
|
||||||
IMGSZ="${2:-640}"
|
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
|
trap 'rm -rf "${WORK}"' EXIT
|
||||||
|
|
||||||
echo "==> exporting ${MODEL} at imgsz=${IMGSZ} in ${WORK}"
|
echo "==> exporting ${MODEL} at imgsz=${IMGSZ} in ${WORK}"
|
||||||
|
|||||||
Reference in New Issue
Block a user