You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/source/en/guides/jobs.md
+23-6Lines changed: 23 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,6 +15,29 @@ A job runs on Hugging Face infrastructure and are defined with a command to run
15
15
If you want to run and manage a job on the Hub, your machine must be logged in. If you are not, please refer to
16
16
[this section](../quick-start#authentication). In the rest of this guide, we will assume that your machine is logged in.
17
17
18
+
## Jobs Command Line Interface
19
+
20
+
Use the [`hf jobs` CLI](./cli#hf-jobs) to run Jobs from the command line, and pass `--flavor` to specify your hardware.
21
+
22
+
`hf jobs run` runs Jobs with a Docker image and a command with a familiar Docker-like interface. Think `docker run`, but for running code on any hardware:
23
+
24
+
```bash
25
+
>>> hf jobs run python:12 -c "print('Hello world!')"
26
+
>>> hf jobs run --flavor a10g-small pytorch/pytorch:2.6.0-cuda12.4-cudnn9-devel python -c "import torch; print(torch.cuda.get_device_name())"
27
+
```
28
+
29
+
Use `hf jobs uv run` to run local or remote UV scripts:
30
+
31
+
```bash
32
+
>>> hf jobs uv run my_script.py
33
+
>>> hf jobs uv run --flavor a10g-small "https://raw.githubusercontent.com/huggingface/trl/main/trl/scripts/sft.py"
34
+
```
35
+
36
+
UV scripts are Python scripts that include their dependencies directly in the file using a special comment syntax defined in the [UV documentation](https://docs.astral.sh/uv/guides/scripts/).
37
+
38
+
Now the rest of this guide will show you the python API.
39
+
If you would like to view all the available `hf jobs` commands and options instead, check out the [guide on the `hf jobs` command line interface](./cli#hf-jobs).
40
+
18
41
## Run a Job
19
42
20
43
Run compute Jobs defined with a command and a Docker Image on Hugging Face infrastructure (including GPUs and TPUs).
@@ -57,12 +80,6 @@ This feature is pay-as-you-go: you only pay for the seconds you use.
57
80
>>> run_uv_job("my_script.py")
58
81
```
59
82
60
-
<Tip>
61
-
62
-
Use [hf jobs](./cli#hf-jobs) to run jobs in the command line.
63
-
64
-
</Tip>
65
-
66
83
[`run_job`] returns the [`JobInfo`] which has the URL of the Job on Hugging Face, where you can see the Job status and the logs.
67
84
Save the Job ID from [`JobInfo`] to manage the job:
0 commit comments