Skip to main content

A helper tool for remote debugging on HPC clusters.

Project description

🚀 remote-debug

A CLI tool to simplify visual debugging of Python scripts on remote HPC clusters directly from your local VS Code instance.

remote-debug helps you bridge the gap between your local editor and a script running on a remote compute node, making it easy to debug GPU-specific issues or complex cluster jobs with a full-featured debugger.


Table of Contents


Installation

Install from PyPI:

pip install remote-debug

Or, build from source using Pixi:

# Install pixi with: curl -fsSL https://pixi.sh/install.sh | sh
pixi install

Quick Start

  1. Initialize your project This command creates the necessary VS Code launch configurations in .vscode/launch.json.

    rdg init
    

[!WARNING] If launch.json exists but is malformed, it will be backed up to launch.json.bak and a new file will be created.

  1. Run your script on the cluster Prefix your usual Python command with rdg debug. This will start a debug server and wait for you to connect.

    # Instead of: python my_script.py --arg value
    # Run this:
    rdg debug python my_script.py --arg value
    
  2. Check your job's output The job output will contain the connection details and the SSH command needed to attach the debugger.

    --- Python Debugger Info ---
    Node: uc2n805.localdomain
    Port: 51041
    Remote Path: /path/to/your/project
    --------------------------
    
    To connect from a local VS Code instance, run this on your local machine:
    ssh -N -L 5678:uc2n805.localdomain:51041 <user@login.hostname>
    Then, attach the debugger to localhost:5678.
    
    Script is paused, waiting for debugger to attach...
    
  3. Connect VS Code Follow one of the two methods below depending on your setup. Once attached, you can set breakpoints and debug as if you were running the code locally.


Debugging Workflow

[!NOTE] For the debugger to work, your VS Code editor must have access to the exact source code that is running on the remote compute node.

  • If you are developing locally: Make sure you have an identical copy of the project on your local machine (e.g., by using git clone).
  • If you are using VS Code Remote-SSH: You are already viewing the project files on the remote machine, so no extra steps are needed.

Method A: Connecting from your Local Machine

Use this method if you are running your IDE locally and want to connect to the remote cluster.

  1. Create an SSH Tunnel You can either copy the ssh command directly from your job's output (just replace the <user@login.hostname> placeholder), or use the rdg tunnel helper command as shown below.

    On your local machine, run the tunnel command using the Node and Port from the job output, along with your cluster's SSH login details.

    # rdg tunnel <NODE> <REMOTE_PORT> <SSH_LOGIN>
    rdg tunnel uc2n805.localdomain 51041 username@cluster.hostname.com
    

    This will generate an ssh command. Copy, paste, and run it in a new terminal to establish the tunnel. Keep this terminal open.

  2. Attach Debugger (example with VS Code)

    • Open the "Run and Debug" panel in VS Code (Ctrl+Shift+D).
    • Select "Python Debugger: Remote Attach (via SSH Tunnel)" from the dropdown and click the play button.
    • You will be prompted for:
      • localTunnelPort: The local port for the tunnel (default is 5678).
      • remoteWorkspaceFolder: The Remote Path from the job output.

Method B: Connecting via VS Code Remote-SSH

Use this method if you are already connected to a remote machine (like a login node) using the VS Code Remote - SSH extension.

  1. Attach VS Code
    • Open the "Run and Debug" panel in VS Code (Ctrl+Shift+D).
    • Select "Python Debugger: Attach to Compute Node" from the dropdown and click the play button.
    • You will be prompted for:
      • computeNodeHost: The Node from the job output.
      • computeNodePort: The Port from the job output.

Command Reference

Command Description
rdg rebug python <script> [args...] Wraps a Python script to start a debugpy listener and waits for a client to attach.
rdg init Creates or updates .vscode/launch.json with the required debugger configurations.
rdg tunnel <node> <port> <login> [--local-port <port>] Constructs the SSH command to establish a tunnel to the compute node.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

remote_debug-0.2.7.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

remote_debug-0.2.7-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file remote_debug-0.2.7.tar.gz.

File metadata

  • Download URL: remote_debug-0.2.7.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for remote_debug-0.2.7.tar.gz
Algorithm Hash digest
SHA256 ea04482cad9ea51a2e6a7160128579d63791dd0e3753be64593452a3b6539ca0
MD5 86d8626bfec04c7647a3c1ba9ba4b088
BLAKE2b-256 7c8613ced9e09b60a810b31724b62607340a90465c326adf6a3c13d7d5c947f6

See more details on using hashes here.

File details

Details for the file remote_debug-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: remote_debug-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for remote_debug-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 88826265e04696ef407cfb93c291f6c450b2e2beef97c8a0c219dbb6d79b9d6e
MD5 a21c7e9193dd2c807a7390f4b75e1b99
BLAKE2b-256 50e0ec6c1bd30052287086e9791df6060425552ecdccac78000bc11e7d86ad3d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page