You can customize the appearance of the HTML report by modifying the CSS in the template. The report uses Bootstrap 5 for styling.
Add custom metrics to your profiling data:
from profiling_py import default_profiler
with default_profiler.profile("my_operation") as step:
# Your code here
step.metadata["custom_metric"] = 42Profile across multiple GPUs by creating multiple profilers:
from profiling_py import Profiler
# Profile on GPU 0
with Profiler(enable_gpu=True, gpu_device=0) as p0:
# Code for GPU 0
pass
# Profile on GPU 1
with Profiler(enable_gpu=True, gpu_device=1) as p1:
# Code for GPU 1
passAvailable GPU metrics include:
gpu_utilization: GPU core utilization (0-100%)memory_used_mb: Used GPU memory in MBmemory_total_mb: Total GPU memory in MBmemory_utilization: Memory utilization percentagetemperature_gpu: GPU temperature in Celsiuspower_usage_w: Current power usage in wattspower_limit_w: Power limit in watts
For minimal overhead:
- Only enable the metrics you need
- Use larger step sizes
- Profile only critical sections
Memory profiling adds overhead. For accurate results:
- Profile for longer durations
- Use larger step sizes
- Avoid frequent small allocations
Use the profiler in Jupyter notebooks:
from profiling_py import profile
@profile
def train_model():
# Training code
pass
# Run and display report
train_model()Profile web applications by creating a profiler middleware:
from fastapi import Request
from profiling_py import Profiler
def profiling_middleware(app):
async def middleware(request: Request, call_next):
with Profiler() as prof:
response = await call_next(request)
prof.generate_report(output_dir="./profiling_reports")
return response
return middleware