Python: Difference between revisions

Jump to navigation Jump to search
no edit summary
No edit summary
No edit summary
Line 390: Line 390:
== Jupyter == <!--T:22-->
== Jupyter == <!--T:22-->
Please see [[Jupyter]].
Please see [[Jupyter]].
== Troubleshooting ==
=== Python script is hanging ===
By using the [https://docs.python.org/3.8/library/faulthandler.html faulthandler] module, you can edit your script to allow dumping a traceback after a timeout. See <code>faulthandler.dump_traceback_later()</code>.
You can also inspect a python process while the job is running, without modifying it beforehand, using [https://pythonrepo.com/repo/benfred-py-spy-python-debugging-tools py-spy]:
# Install py-spy in a virtualenv in your home
# Attach to the running job, using <code>srun --pty --jobid JOBID bash</code>
# Use <code>htop -u $USER</code> to find the process ID of your python script
# Activate the virtualenv where py-spy is installed
# Run <code>py-spy top --pid PID</code> to see live feedback about where your code is spending time
# Run <code>py-spy dump --pid PID</code> to get a traceback of where your code is currently at.
</translate>
</translate>
cc_staff
353

edits

Navigation menu