Repository navigation
Docs: more C++ troubleshooting and a GPU input and output example for the pip package - #24649
Open
pytorchbot wants to merge 1 commit into
Open
pytorchbot wants to merge 1 commit into
pytorchbot wants to merge 1 commit into
Conversation
… the pip package (#24633) ## Problem Building a C++ app against the ExecuTorch pip package works well, but some common mistakes give errors that "Using ExecuTorch with C++" does not explain: - Finding the package with `os.path.dirname(executorch.__file__)` fails with a `TypeError`. The `executorch` package has no `__init__.py`, so `__file__` is `None`. - A model whose weights are in a separate `.ptd` file fails to load when only the `.pte` is passed. The CUDA backend reports `... is missing from named data`. - A GPU model exported with `alloc_graph_output=False` fails on its first run when the program does not give it output buffers. The C++ guide already shows the right way for the first two, and the Module guide and the CUDA backend guide cover the third. But the C++ guide never names these errors, so someone who hits one cannot tell which fix applies. ## Change In `docs/source/using-executorch-cpp.md`: - A new CUDA subsection says that a model can keep its inputs and outputs on the GPU. It links the CUDA backend guide for the export side, and shows the C++ side in a few lines: GPU tensors made with `from_blob`, and `set_output` before the first run. - "When something does not work" gets an entry for each error above, with its fix. ## Testing On Linux x86_64 with an NVIDIA A100, in fresh virtual environments with `executorch==1.6.0` and `torch==2.15.0`, installed from PyPI and from the CPU index: - The CPU walkthrough on this page (export, program, CMake, build and run) prints `11 22 33 44` with both installs. The `os.path.dirname(executorch.__file__)` form fails as described. - With the PyPI install, the CUDA export from this page, loaded with `Module("model.pte", "aoti_cuda_blob.ptd")`, prints `11 22 33 44`. - A CUDA model with weights fails to load without its `.ptd` file with the message quoted above, and loads with it. Saving only `program.buffer` writes no `.ptd` and fails the same way. - The new snippet, pasted unchanged into a small program that allocates the GPU buffers and prints the result, runs a model exported with GPU inputs and outputs and `alloc_graph_output=False`, and prints `11 22 33 44`. - A model exported with only the input copies skipped writes its output into a host buffer given with `set_output`. - A minimal Sphinx build of the page shows no new warnings, and both new links resolve. (cherry picked from commit 0b8cfc2)
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/24649
Note: Links to docs will display an error until the docs builds have been completed. ⏳ No Failures, 1 PendingAs of commit 58d8aef with merge base 4db778e ( This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Building a C++ app against the ExecuTorch pip package works well, but some common mistakes give
errors that "Using ExecuTorch with C++" does not explain:
os.path.dirname(executorch.__file__)fails with aTypeError. Theexecutorchpackage has no__init__.py, so__file__isNone..ptdfile fails to load when only the.pteis passed.The CUDA backend reports
... is missing from named data.alloc_graph_output=Falsefails on its first run when the program doesnot give it output buffers.
The C++ guide already shows the right way for the first two, and the Module guide and the CUDA backend
guide cover the third. But the C++ guide never names these errors, so someone who hits one cannot
tell which fix applies.
Change
In
docs/source/using-executorch-cpp.md:CUDA backend guide for the export side, and shows the C++ side in a few lines: GPU tensors made
with
from_blob, andset_outputbefore the first run.Testing
On Linux x86_64 with an NVIDIA A100, in fresh virtual environments with
executorch==1.6.0andtorch==2.15.0, installed from PyPI and from the CPU index:11 22 33 44withboth installs. The
os.path.dirname(executorch.__file__)form fails as described.Module("model.pte", "aoti_cuda_blob.ptd"), prints11 22 33 44..ptdfile with the message quoted above, andloads with it.
Saving only
program.bufferwrites no.ptdand fails the same way.the result, runs a model exported with GPU inputs and outputs and
alloc_graph_output=False, andprints
11 22 33 44.with
set_output.