Workaround to successfully profile python script using scalene profiler on macOS? Just forget it and use machine with Windows or Linux?
Computational Science SE question How amenable is this 2D Frenkel–Kontorova-like energy minimization problem in Python to the use of a modest PC + GPU? (Heavy reliance on indexing) contains a short example script and note 3 links to my first attempt at profiling using scalene
The results were uninformative, so I followed a recommendation that I try the --profile-all
option. After running for 30 minutes without finishing on a script that took seconds to run I added a CPU percent limit; what I assume means only things that used at least 2% of the CPU time would be profiled in depth.
scalene --html --outfile prof.html --profile-all --cpu-percent-threshold 2 myscript.py
I received a two line error and was exited from python in a normal way.
Error getting real path: 2
Scalene error: received signal SIGABRT
This issue was closed in scalene issue #110 and there are links there to
- https://github.com/plasma-umass/scalene/commit/6636d95d7ea9a16adedaedbd4ff0926374798f2b
Q: How do I use Scalene with PyTorch?
A: Scalene works with PyTorch version 1.5.1. There's a bug in newer versions of PyTorch (https://github.com/pytorch/pytorch/issues/57185) that interferes with Scalene (discussion here: https://github.com/plasma-umass/scalene/issues/110).
there's more information there as well
and
- Pytorch open issue #57185 Segmentation fault with ITIMER_REAL PyTorch throws SIGSEGV when running alongside timer on MacOS x86
Question: Is there a workaround to successfully profile python script using scalene profiler on macOS? Or should I just move to a machine with Windows or Linux and forget about trying for now?
The message, Error getting real path: 2
, seems to have to do with scalene finding your script or a path internal to your script possibly.
Ensure you're referencing a full, valid path for myscript.py
, taking into account which directory you're at in the terminal. You may need to change directory.
The SIGABRT
message is different from the SIGSEGV
issue listed, though, if you wanted to test it, you could uninstall PyTorch (pip uninstall torch
) and reinstall a specific version (pip install 'torch==1.5.1'
).