Spaces:
Sleeping
Sleeping
burtenshaw commited on
Commit ·
b5bdc08
1
Parent(s): 8ac80b5
skill md
Browse files
.claude/skills/hf-space-sandbox/SKILL.md
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
name: hf-sandbox
|
| 3 |
+
description: Run remote workloads on Hugging Face Spaces via SSH using Dev Mode. Use when executing Python scripts, training models, or running compute-intensive tasks on remote GPU hardware.
|
| 4 |
+
---
|
| 5 |
+
|
| 6 |
+
# HF Space Dev Mode Sandbox
|
| 7 |
+
|
| 8 |
+
Run scripts on remote GPU hardware via SSH. Requires HF Pro/Enterprise subscription.
|
| 9 |
+
|
| 10 |
+
## Create Space
|
| 11 |
+
|
| 12 |
+
```bash
|
| 13 |
+
uv run scripts/sandbox.py create user/sandbox
|
| 14 |
+
uv run scripts/sandbox.py create user/sandbox --hardware t4-small --sleep-time 3600 --private
|
| 15 |
+
```
|
| 16 |
+
|
| 17 |
+
## SSH Access
|
| 18 |
+
|
| 19 |
+
```bash
|
| 20 |
+
ssh USERNAME-SPACENAME@ssh.hf.space
|
| 21 |
+
```
|
| 22 |
+
|
| 23 |
+
For example, for space `burtenshaw/sandbox`, use:
|
| 24 |
+
```bash
|
| 25 |
+
ssh burtenshaw-sandbox@ssh.hf.space
|
| 26 |
+
```
|
| 27 |
+
|
| 28 |
+
Add your SSH key at https://huggingface.co/settings/keys first.
|
| 29 |
+
|
| 30 |
+
## Run uv Scripts
|
| 31 |
+
|
| 32 |
+
```bash
|
| 33 |
+
# Remote execution
|
| 34 |
+
ssh USERNAME-SPACENAME@ssh.hf.space "uv run --with requests python -c 'import requests; print(requests.get(\"https://httpbin.org/get\").status_code)'"
|
| 35 |
+
|
| 36 |
+
# Copy and run
|
| 37 |
+
scp script.py USERNAME-SPACENAME@ssh.hf.space:/app/
|
| 38 |
+
ssh USERNAME-SPACENAME@ssh.hf.space "cd /app && uv run script.py"
|
| 39 |
+
|
| 40 |
+
# Background job
|
| 41 |
+
ssh USERNAME-SPACENAME@ssh.hf.space "cd /data && nohup uv run train.py > train.log 2>&1 &"
|
| 42 |
+
ssh USERNAME-SPACENAME@ssh.hf.space "tail -f /data/train.log"
|
| 43 |
+
```
|
| 44 |
+
|
| 45 |
+
## uv Script Format (PEP 723)
|
| 46 |
+
|
| 47 |
+
```python
|
| 48 |
+
#!/usr/bin/env -S uv run --script
|
| 49 |
+
# /// script
|
| 50 |
+
# requires-python = ">=3.11"
|
| 51 |
+
# dependencies = ["transformers", "torch"]
|
| 52 |
+
# ///
|
| 53 |
+
|
| 54 |
+
from transformers import pipeline
|
| 55 |
+
print(pipeline("sentiment-analysis")("Hello!"))
|
| 56 |
+
```
|
| 57 |
+
|
| 58 |
+
## Space Management
|
| 59 |
+
|
| 60 |
+
```bash
|
| 61 |
+
uv run scripts/sandbox.py status user/sandbox
|
| 62 |
+
uv run scripts/sandbox.py start user/sandbox
|
| 63 |
+
uv run scripts/sandbox.py stop user/sandbox
|
| 64 |
+
uv run scripts/sandbox.py hardware user/sandbox t4-medium
|
| 65 |
+
uv run scripts/sandbox.py hardware user/sandbox a10g-small --sleep-time 3600
|
| 66 |
+
uv run scripts/sandbox.py wait user/sandbox
|
| 67 |
+
```
|
| 68 |
+
|
| 69 |
+
**Hardware:** `cpu-basic`, `cpu-upgrade`, `t4-small`, `t4-medium`, `a10g-small`, `a10g-large`, `a100-large`
|
| 70 |
+
|
| 71 |
+
Fetch this for up to date information: https://huggingface.co/docs/hub/en/spaces-overview
|