pip install can fail with one of two errors:
MemoryError— pip tries to serialize large wheel files into memory for caching, exceeding available RAM.OSError: [Errno 28] No space left on device— downloaded wheels fill up the/tmpdirectory.
Cause
The build environment mounts/tmp as a tmpfs — a RAM-backed filesystem capped at ~3.9 GB. pip downloads all wheels to /tmp/pip-* before installing them. PyTorch with CUDA dependencies totals ~4.1 GB of downloads, which exceeds this limit.
Solution 1: Redirect pip’s temp directory to disk (recommended)
Set theTMPDIR environment variable to a disk-backed path so pip downloads don’t go through the RAM-backed /tmp. Combined with --no-cache-dir, this avoids both the disk space and memory issues.
Solution 2: Install CPU-only PyTorch
E2B sandboxes don’t have GPUs, so there’s no reason to download CUDA dependencies. Installing the CPU-only variant of PyTorch reduces the download from ~4.1 GB to ~189 MB, avoiding the/tmp size limit entirely.