I use line_profiler in my .ipynb file with vscode:
from line_profiler import LineProfiler
lpf = LineProfiler()
lpf.add_function(train_loop)
lpf.add_function(Covid_dataset.__getitem__)
lpf.add_function(Covid_dataset.__len__)
lpf.enable_by_count()
lpf.runcall(train_loop, model, train_dataloader, optimizer, criterion)
lpf.print_stats()
it used to work correctly,but today i meet this:
Timer unit: 1e-07 s
Total time: 1.33e-05 s
Could not find file C:\Users\12978\AppData\Local\Temp\ipykernel_11908\222113089.py
Are you sure you are running this program from the same directory
that you ran the profiler from?
Continuing without the function's contents.
The only change is that I debug my code in notebook now. And if i run this cell in debug mode, it works again.
It seem to be like jupyter runs the cell in different path when debugging, but the line_profiler now can only get the debug path, but cannot get the normal one.
How to fix it ?