Skip to content

Commit 93002a2

Browse files
authored
docs: update slurm (#7418)
- Using GPUs for interactive development - Other edits for clarity
1 parent c4c846e commit 93002a2

File tree

1 file changed

+68
-6
lines changed

1 file changed

+68
-6
lines changed

docs/guides/deploying/deploying_slurm.md

Lines changed: 68 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ Open `http://localhost:3000` in your browser.
4747

4848
## Running as Batch Jobs
4949

50-
marimo notebooks can run as batch jobs using `app.run()`. Use `mo.cli_args()` to pass parameters:
50+
Because marimo notebooks are just Python scripts, they can readily be run as
51+
batch jobs. This simple example uses [`mo.cli_args()`][marimo.cli_args] to pass
52+
parameters:
5153

5254
```python
5355
# /// script
@@ -86,10 +88,30 @@ Submit as a job:
8688
python notebook.py --learning-rate 0.01 --epochs 100
8789
```
8890

89-
## GPU Jobs
91+
### Using GPUs
9092

9193
Add GPU resources to your SBATCH directives:
9294

95+
/// tab | Interactive development
96+
```bash
97+
#!/bin/bash
98+
#SBATCH --job-name=marimo
99+
#SBATCH --output=marimo-%j.out
100+
#SBATCH --partition=gpu
101+
#SBATCH --gres=gpu:1
102+
#SBATCH --cpus-per-task=4
103+
#SBATCH --mem=16GB
104+
#SBATCH --time=4:00:00
105+
106+
# module load or otherwise set up environment
107+
108+
python -m marimo edit notebook.py --headless --port 3000
109+
```
110+
111+
///
112+
113+
/// tab | Batch jobs
114+
93115
```bash
94116
#!/bin/bash
95117
#SBATCH --job-name=marimo-gpu
@@ -101,9 +123,15 @@ Add GPU resources to your SBATCH directives:
101123
python notebook.py
102124
```
103125

104-
## Self-contained notebooks
126+
///
105127

106-
You can embed SBATCH directives directly in your notebook file, making it fully self-contained:
128+
## Inlining configuration in notebook files
129+
130+
You can inline SBATCH directives in your notebook file. If used alongside marimo's support for
131+
[inlining package dependencies](../package_management/inlining_dependencies.md) ("sandboxing"),
132+
this lets you create fully self-contained notebooks.
133+
134+
/// tab | Interactive development
107135

108136
```python
109137
#!/usr/bin/env -S python -m marimo edit --sandbox
@@ -135,15 +163,49 @@ if __name__ == "__main__":
135163
app.run()
136164
```
137165

166+
/// tab | Batch job
167+
168+
```
169+
#!/usr/bin/env -S python
170+
#SBATCH --job-name=marimo-job
171+
#SBATCH --output=marimo-%j.out
172+
#SBATCH --cpus-per-task=4
173+
#SBATCH --mem=16GB
174+
175+
# /// script
176+
# requires-python = ">=3.12"
177+
# dependencies = [
178+
# "marimo",
179+
# ]
180+
# ///
181+
182+
import marimo
183+
184+
app = marimo.App()
185+
186+
187+
@app.cell
188+
def _():
189+
import marimo as mo
190+
print("Hello World!")
191+
return
192+
193+
194+
if __name__ == "__main__":
195+
app.run()
196+
```
197+
198+
///
199+
200+
138201
Make executable and submit directly:
139202

140203
```bash
141204
chmod +x notebook.py
142205
sbatch notebook.py
143206
```
144207

145-
For this sandboxing to work correctly, [uv](https://docs.astral.sh/uv/getting-started/installation/) should be installed.
146-
Alternatively, following hashbang `#!/usr/bin/env -S uv run marimo edit --sandbox`.
208+
Sandboxing requires [uv](https://docs.astral.sh/uv/getting-started/installation/) to be installed.
147209

148210
## Learn more
149211

0 commit comments

Comments
 (0)