Skip to content

Commit

Permalink
Document how to use commands with python module instead of argparse (#…
Browse files Browse the repository at this point in the history
…1457)

* Include other commands

* Add another paragraph

* Reverse order

Co-authored-by: Stas Bekman <[email protected]>

---------

Co-authored-by: Stas Bekman <[email protected]>
  • Loading branch information
muellerzr and stas00 authored May 19, 2023
1 parent e6699e6 commit bfa74e5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
15 changes: 15 additions & 0 deletions docs/source/basic_tutorials/launch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,21 @@ For a visualization of this difference, that earlier `accelerate launch` on mult
MIXED_PRECISION="fp16" torchrun --nproc_per_node=2 --num_machines=1 {script_name.py} {--arg1} {--arg2} ...
```

You can also launch your script utilizing the launch CLI as a python module itself, enabling the ability to pass in other python-specific
launching behaviors. To do so, use `accelerate.commands.launch` instead of `accelerate launch`:

```bash
python -m accelerate.commands.launch --num_processes=2 {script_name.py} {--arg1} {--arg2}
```

If you want to execute the script with any other python flags, you can pass them in as well similar to `-m`, such as
the below example enabling unbuffered stdout and stderr:

```bash
python -u -m accelerate.commands.launch --num_processes=2 {script_name.py} {--arg1} {--arg2}
```


## Why you should always use `accelerate config`

Why is it useful to the point you should **always** run `accelerate config`?
Expand Down
4 changes: 2 additions & 2 deletions docs/source/package_reference/cli.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ accelerate config update [arguments]

**Command**:

`accelerate env` or `accelerate-env`
`accelerate env` or `accelerate-env` or `python -m accelerate.commands.env`

Lists the contents of the passed 🤗 Accelerate configuration file. Should always be used when opening an issue on the [GitHub repository](https://github.com/huggingface/accelerate).

Expand All @@ -103,7 +103,7 @@ accelerate env [arguments]

**Command**:

`accelerate launch` or `accelerate-launch`
`accelerate launch` or `accelerate-launch` or `python -m accelerate.commands.launch`

Launches a specified script on a distributed system with the right parameters.

Expand Down

0 comments on commit bfa74e5

Please sign in to comment.