Skip to content

Commit 96e46c9

Browse files
authored
Flatten troubleshooting section and add pip install error page (#111)
* Flatten troubleshooting section and add pip install error page Remove the nested "Templates" sub-group from troubleshooting navigation and move pages directly under the Troubleshooting group. Add a new troubleshooting page for pip install failures during template builds caused by /tmp tmpfs size limits. * Remove unnecessary user: root from runCmd examples The default template user doesn't require explicit root for pip install. * Add redirects for moved troubleshooting pages Redirect old /docs/troubleshooting/templates/* URLs to their new locations under /docs/troubleshooting/. * Use non-permanent redirects for moved troubleshooting pages * Keep troubleshooting files in templates/ dir, flatten nav only Keep the original URL paths under templates/ but remove the "Templates" sub-group from the sidebar navigation. Remove now-unnecessary redirects.
1 parent 1cd4397 commit 96e46c9

2 files changed

Lines changed: 66 additions & 7 deletions

File tree

docs.json

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -201,13 +201,9 @@
201201
{
202202
"group": "Troubleshooting",
203203
"pages": [
204-
{
205-
"group": "Templates",
206-
"pages": [
207-
"docs/troubleshooting/templates/build-authentication-error",
208-
"docs/troubleshooting/templates/49999-port-not-open"
209-
]
210-
}
204+
"docs/troubleshooting/templates/build-authentication-error",
205+
"docs/troubleshooting/templates/49999-port-not-open",
206+
"docs/troubleshooting/pip-install-error"
211207
]
212208
}
213209
]
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
---
2+
title: "pip install fails during template build"
3+
sidebarTitle: pip install fails during template build
4+
---
5+
6+
When building a template that installs large Python packages like PyTorch with CUDA dependencies, `pip install` can fail with one of two errors:
7+
8+
- **`MemoryError`** — pip tries to serialize large wheel files into memory for caching, exceeding available RAM.
9+
- **`OSError: [Errno 28] No space left on device`** — downloaded wheels fill up the `/tmp` directory.
10+
11+
**Example errors**
12+
13+
```txt
14+
File "pip/_vendor/cachecontrol/serialize.py", line 70, in dumps
15+
return b",".join([b"cc=4", msgpack.dumps(data, use_bin_type=True)])
16+
MemoryError
17+
```
18+
19+
```txt
20+
ERROR: Could not install packages due to an OSError: [Errno 28] No space left on device
21+
```
22+
23+
## Cause
24+
25+
The build environment mounts `/tmp` as a [tmpfs](https://www.kernel.org/doc/html/latest/filesystems/tmpfs.html) — 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.
26+
27+
## Solution 1: Redirect pip's temp directory to disk (recommended)
28+
29+
Set the `TMPDIR` 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.
30+
31+
<CodeGroup>
32+
```typescript JavaScript & TypeScript
33+
const template = Template()
34+
.runCmd('TMPDIR=/var/tmp pip install --no-cache-dir torch sentence-transformers')
35+
```
36+
```python Python
37+
template = (
38+
Template()
39+
.run_cmd("TMPDIR=/var/tmp pip install --no-cache-dir torch sentence-transformers")
40+
)
41+
```
42+
</CodeGroup>
43+
44+
## Solution 2: Install CPU-only PyTorch
45+
46+
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.
47+
48+
<CodeGroup>
49+
```typescript JavaScript & TypeScript
50+
const template = Template()
51+
.runCmd('pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu')
52+
.runCmd('echo "torch" > /tmp/constraints.txt && pip install --no-cache-dir -c /tmp/constraints.txt sentence-transformers')
53+
```
54+
```python Python
55+
template = (
56+
Template()
57+
.run_cmd("pip install --no-cache-dir torch --index-url https://download.pytorch.org/whl/cpu")
58+
.run_cmd('echo "torch" > /tmp/constraints.txt && pip install --no-cache-dir -c /tmp/constraints.txt sentence-transformers')
59+
)
60+
```
61+
</CodeGroup>
62+
63+
The constraints file in the second step prevents pip from replacing the CPU-only torch with the CUDA version when installing packages that depend on PyTorch.

0 commit comments

Comments
 (0)