Help Center/ ModelArts/ DevEnviron/ Local IDE/ Local IDE (VS Code)/ Remotely Debugging in VS Code
Updated on 2024-06-12 GMT+08:00

Remotely Debugging in VS Code

Prerequisites

A notebook instance has been accessed through VS Code.

Step 1 Upload Local Code to the Cloud Development Environment

  1. On the VS Code page, choose File > Open Folder to access the cloud path.
    Figure 1 Open Folder
  2. Select a path and click OK.
    Figure 2 Selecting a file path
  3. In the displayed directory structure on the left of the IDE, drag the code and files you want to upload to the corresponding folders. Then, the code is uploaded to the cloud development environment.

Step 2 Debug Code Remotely

Open the code file to be debugged in VS Code. Before running the code, click the default Python version in the lower left part and select a version as required.

Figure 3 Selecting a Python version
  • Click the execution button to run the code. The code output is shown on the TERMINAL tab page.
  • If a training job takes a long time to execute, run the job at the backend through the nohup command. This prevents the disconnection of an SSH session or a network failure from affecting job execution. The following shows an example nohup command:
    nohup your_train_job.sh > output.log 2>&1  &  tail -f  output.log
  • To debug the code, perform the following operations:
    1. Choose Run > Run and Debug on the left.
    2. Select the default Python code file.
    3. Click on the left of the code to set breakpoints.
    4. Debug the code according to the debug procedure which is displayed above the code, and the debug information is displayed on the left of the page.