|
1 | | -# Debugging MLIR-TensorRT backend |
| 1 | +# Debugging MLIR-TensorRT |
2 | 2 |
|
3 | | -1. Install new python bindings for compiler and runtime. Assuming `tripy/mlir-tensorrt` directory exists. No need to update `LD_LIBRARY_PATH`. |
| 3 | +While developing Tripy features, you may need to debug MLIR-TRT code. |
| 4 | +This guide outlines some methods of doing so. |
4 | 5 |
|
5 | | -<!-- Tripy: DOC: NO_EVAL Start --> |
6 | | - ```bash |
7 | | - python3 -m pip install --force-reinstall mlir-tensorrt/build/wheels/trt100/**/*.whl |
8 | | - ``` |
9 | | -<!-- Tripy: DOC: NO_EVAL End --> |
10 | 6 |
|
11 | | -2. Set environment flags for debugging: |
| 7 | +## Environment Variables |
| 8 | + |
| 9 | +We include some environment variables to enable extra debugging information from MLIR-TRT: |
| 10 | + |
| 11 | +- `export TRIPY_MLIR_DEBUG_ENABLED=1` will enable debug prints in MLIR-TRT and dump all intermediate IRs to a directory. |
| 12 | +- `export TRIPY_MLIR_DEBUG_PATH=<mlir-debug-path>` sets the directory for IR dumps. The default path is `mlir-dumps`. |
| 13 | +- `export TRIPY_TRT_DEBUG_ENABLED=1` will dump TensorRT engines and their layer information. |
| 14 | +- `export TRIPY_TRT_DEBUG_PATH=<trt-debug-path>` sets the directory for TensorRT dumps. Default path is `tensorrt-dumps`. |
12 | 15 |
|
13 | | -- `export TRIPY_MLIR_DEBUG_ENABLED=1` to enable MLIR-TRT debugging. It will enable debugging prints in MLIR-TRT as well as dump all intermediate IRs after each pass. |
14 | | -- `export TRIPY_MLIR_DEBUG_PATH=<mlir-debug-path>` to set debug path for MLIR-TRT dumps. Default path is `mlir-dumps` under the repo directory. This will create one or more folders named like `module_ins_t1_outs_t2_1`. |
15 | | -- `export TRIPY_TRT_DEBUG_ENABLED=1` to enable TensorRT debugging. It will dump TensorRT engines and their layer information (if there are any TensorRT built during compilation). |
16 | | -- `export TRIPY_TRT_DEBUG_PATH=<trt-debug-path>` to set debug path for TensorRT dumps. Default path is `tensorrt-dumps` under the repo directory. |
17 | 16 |
|
| 17 | +## Using A Debugger |
18 | 18 |
|
19 | | -3. Use LLDB for debugging MLIR-TensorRT backend. |
20 | | -In order to use `lldb` in tripy container, launch the container with extra security options: |
| 19 | +For more involved bugs, it may be helpful to step into MLIR-TRT code. |
| 20 | +To do so, you will need a debug build of MLIR-TRT; |
| 21 | +see [CONTRIBUTING.md](source:/CONTRIBUTING.md) |
| 22 | +for details on using custom builds of MLIR-TRT. |
| 23 | + |
| 24 | +Once you've installed the debug build in the container, you should be able to use `gdb` as normal. |
| 25 | + |
| 26 | +Alternatively, you can use [LLDB](https://lldb.llvm.org/) if you launch the container with extra security options: |
21 | 27 |
|
22 | 28 | <!-- Tripy: DOC: NO_EVAL Start --> |
23 | 29 | ```bash |
24 | 30 | docker run --gpus all --cap-add=SYS_PTRACE \ |
25 | | - --security-opt seccomp=unconfined --security-opt apparmor=unconfined \ |
26 | | - -p 8080:8080 -v $(pwd):/tripy/ -it --rm tripy:latest |
| 31 | + --security-opt seccomp=unconfined --security-opt apparmor=unconfined \ |
| 32 | + -p 8080:8080 -v $(pwd):/tripy/ -it --rm tripy:latest |
27 | 33 | ``` |
28 | 34 | <!-- Tripy: DOC: NO_EVAL End --> |
29 | | -See https://forums.swift.org/t/debugging-using-lldb/18046 for more details. |
| 35 | + |
| 36 | +See [this post](https://forums.swift.org/t/debugging-using-lldb/18046) for details on |
| 37 | +why these security options are required. |
0 commit comments