Skip to content

Commit

Permalink
Add skip_torch_install flag to install_dependencies.py
Browse files Browse the repository at this point in the history
  • Loading branch information
wozna committed Jun 10, 2024
1 parent 6dff71c commit cc85faf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
13 changes: 11 additions & 2 deletions examples/pt2/torch_compile_hpu/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,17 @@

This guide provides steps on how to optimize a ResNet50 model using `torch.compile` with [HPU backend](https://docs.habana.ai/en/latest/PyTorch/Inference_on_PyTorch/Getting_Started_with_Inference.html), aiming to enhance inference performance when deployed through TorchServe. `torch.compile` allows for ahead-of-time compilation of PyTorch models.

### Prerequisites
- `Intel® Gaudi® AI accelerator software for PyTorch` - Go to [Installation_Guide](https://docs.habana.ai/en/latest/Installation_Guide/index.html) which covers installation procedures, including software verification and subsequent steps for software installation and management.
### Prerequisites and installation
Fisrt install `Intel® Gaudi® AI accelerator software for PyTorch` - Go to [Installation_Guide](https://docs.habana.ai/en/latest/Installation_Guide/index.html) which covers installation procedures, including software verification and subsequent steps for software installation and management.

Then install the dependencies with the `--skip_torch_install` flag so as not to overwrite habana torch, which you should already have installed. Then install torchserve, torch-model-archiver torch-workflow-archiver as in the example below.

```bash
python ./ts_scripts/install_dependencies.py --skip_torch_install

# Latest release
python install -c torchserve torch-model-archiver torch-workflow-archiver
```

## Workflow
1. Configure torch.compile.
Expand Down
8 changes: 8 additions & 0 deletions ts_scripts/install_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ def install_python_packages(self, cuda_version, requirements_file_path, nightly)
os.system(
f"pip3 install numpy --pre torch torchvision torchaudio torchtext --index-url https://download.pytorch.org/whl/nightly/{pt_nightly}"
)
elif args.skip_torch_install:
print("Skipping Torch installation")
else:
self.install_torch_packages(cuda_version)

Expand Down Expand Up @@ -379,6 +381,12 @@ def get_brew_version():
help="Install nightly version of torch package",
)

parser.add_argument(
"--skip_torch_install",
action="store_true",
help="Skip Torch installation",
)

parser.add_argument(
"--force",
action="store_true",
Expand Down

0 comments on commit cc85faf

Please sign in to comment.