NREL / HPC

A collection of various resources, examples, and executables for the general NREL HPC user community's benefit. Use the following website for accessing documentation.
https://nrel.github.io/HPC/
Other
103 stars 64 forks source link

Option for VS Code debugging within a job #598

Open mnblonsky opened 3 months ago

mnblonsky commented 3 months ago

Thanks for including documentation on using VS Code on HPC. I have a method for attaching a python debug process that others may find useful. Feel free to add this to the VS Code docs page if you're interested.

Tips for debugging on HPC

  1. Create a "Python: Remote Attach" configuration in VS Code

    • use localhost and port 5678
    • no adjustments to defaults needed
  2. Start an interactive job

salloc --partition=debug --qos=high --time=10 --account=<account>

record the <user@hostname> for that job (e.g. mblonsky@x1008c0s0b0n1)

  1. Open a new terminal and create an ssh tunnel from a login node to the interactive job node
ssh -2 -L 5678:localhost:5678 <user@hostname>
  1. In the interactive job terminal run your code using the debugpy module (you may need to update your environment or install the debugpy package):
python -m debugpy --wait-for-client --listen 5678 <my_script.py> <my_args>
  1. Run the "Python: Remote Attach" debug configuration