Updated on 2026-07-02 GMT+08:00

Using Code Server for Code Development

Code Server is an open-source project that allows you to run Visual Studio Code on a remote server and access it entirely through a web browser. The following capabilities are supported:

  • Full VS Code experience: Supports nearly all native features including the extension marketplace, debugger, terminal, Git, and more.
  • Cross-platform access: Write code on any device using just a browser.
  • Unified development environment: Code, configurations, and dependencies are all deployed on the server, ensuring environment consistency.
  • Private deployment: Users have complete control over their data.

This topic introduces how to use Code Server in a notebook instance for code development.

Constraints

The notebook instance you create must meet the following conditions:

  • Code Server has been configured.
    • If no notebook instance has been created, select Code Server in environment settings when creating a notebook instance.
      Figure 1 Code Server

    • If a notebook instance has been created, check whether Code Server is configured in the Basic Information tab of the notebook instance details page.
      Figure 2 Notebook instance details page

  • The OSs of some container image versions do not support Code Server. The constraints are as follows:
    To view the OS of the container image, note that the preset image address is pytorch_cuda: pytorch_2.7.0-cuda_12.8-py_3.11.10-ubuntu_22.04-x86_64-20251215163925-4e5422a. The OS is ubuntu_22.04.
    Table 1 Supported OS types

    Container Image OS

    Architecture

    Code Server

    ubuntu_18.04

    x86

    Not supported

    ubuntu_20.04

    x86

    Supported

    ubuntu_22.04

    x86

    Supported

    hce_2.0/hce2.0

    Arm

    Supported

    euler_2.8.3/euler2.8.3

    Arm

    Supported

    euler_2.10/euler2.10

    Arm

    Supported

Starting Code Server

  1. Log in to the ModelArts console and perform the following operations as required:
    • New console: Choose Model Build > Notebook.
    • Old console: Choose Development Space > Notebook.
  2. In the Operation column of a running notebook instance, click Access Environment. In the WebIDE tab page of the Access Method dialog box, click Access on the right of Code Server Access.
    Figure 3 Code Server access

    After the access is successful, you can see that the GUI layout, operation logic, and functions of the Code Server are the same as those of the VS Code desktop edition.

Code Server Features

The following describes the interface layout and functions, core features, and extension marketplace of Code Server.

Interface Layout and Features

The Code Server interface is divided into the following main areas.

Table 2 Code Server areas

Area

Description

Top menu bar

Displays the name of the currently open file or folder, along with window control buttons.

Left activity bar

Contains multiple icon buttons used to switch between different views, supporting the following features:

  • Explorer: Browse and manage project files.
  • Search: Search for file content and symbols across the project.
  • Source Control: Integrated Git operations, supporting commits, branch management, difference viewing, etc.
  • Run and Debug: Configure and run debugging tasks.
  • Extensions: Manage extension installations and configurations.
  • Testing: Configure and run test cases.
  • GitLens: A powerful Git extension supporting code history, difference tracking, and more.
  • Cline: AI coding assistant, an intelligent development extension powered by LLMs.

Left side bar

Displays the specific content of the view selected in the activity bar, such as the file tree, search results, or extension lists.

Editor area

The main area for editing code, supporting multiple open tabs, code highlighting, syntax prompt, and more.

Bottom status bar

Displays information about the current file's language mode, line and column numbers, Git branch, errors/warnings, and more.

Integrated terminal

Located at the bottom; supports creating multiple terminal instances to run multiple commands simultaneously.

Core Features

  • Full extension ecosystem: Code Server uses the Open-VSX extension marketplace by default. You can search for and install the vast majority of popular open-source extensions, such as Python, GitLens, and Prettier, via on the left.
  • Built-in terminal and Git: The integrated terminal is a major highlight, allowing you to complete the entire workflow from coding to building, testing, and deployment right inside your browser, delivering an experience just like local development. Meanwhile, the source code management view integrates Git operations, making it easy to commit code, manage branches, and view differences.
  • Convenient port forwarding: When developing web applications or needing to access specific service ports on the server, you can use Code Server's built-in port forwarding feature. You can easily map remote ports to your local machine within the PORTS panel for convenient debugging.
  • Settings sync and persistence: Code Server's configurations, themes, keyboard shortcuts, and installed extensions are all saved in the configuration directory on the server. This means no matter which device you log in from, you will get a completely consistent development environment.

Extension Marketplace

The Code Server extension marketplace provides a rich selection of development tools. The notebook instance comes pre-installed with several commonly used extensions, and you can also download additional ones as needed.

Figure 4 Extension marketplace

The pre-installed extensions in the notebook instance and their descriptions are as follows.

Table 3 Pre-installed extensions

Extension

Version

Description

Python

2025.6.1

Python language support, providing features like code completion and syntax checking.

Python Debugger

2025.18.0

Python debugger, supporting breakpoint debugging, variable inspection, and more.

Python Environments

1.10.0

Automatically detects, manages, and activates different Python interpreters and virtual environments.

Code Spell Checker

4.1.0

Real-time spell checking for English words in source code, comments, and documentation, supporting camelCase and snake_case naming conventions.

EditorConfig for VS Code

0.16.6

Helps teams define and maintain consistent coding styles.

GitLens

17.1.1

A powerful Git extension supporting code history, diff tracking, and more.

isort

2023.11.0-dev

Automatically sorts, groups, and formats import statements in your code.

Jupyter

2024.8.1

Jupyter Notebook support.

Jupyter Cell Tags

0.1.9

Jupyter cell tag management.

Jupyter Keymap

1.1.2

Jupyter keyboard shortcuts.

Jupyter Notebook Renderers

1.0.19

Jupyter Notebook renderers.

Jupyter Slide Show

0.1.6

Jupyter slideshow presentation.

Pyright

1.1.400

A standard static type checker for Python, designed to improve type safety, development efficiency, and code quality in large Python codebases.

Cline

3.75.0

AI coding assistant, an intelligent development extension powered by LLMs.

You can also download other required extensions from the marketplace. Taking Markdown extensions as an example: type Markdown into the search bar, select the extension you need to download, and click Install.

Debugging Python Code

The notebook instance comes pre-installed with Python-related dependency extensions in Code Server, allowing you to start debugging Python code directly.

Preparing Code

  1. Right-click in the workspace to create a new Python file with a .py extension, for example, test.py.
    Figure 5 Creating a new Python file
  2. Copy and paste the following Python code into the file:
    import os 
    print(os.environ.get('PATH'))
    print("Hello World")
    print("Welcome to Code Server")
    Figure 6 Copying Python code

Running the Python File

Click in the upper right corner of the Python file, and the TERMINAL tab at the bottom will display the execution results.

Figure 7 TERMINAL execution results

Debugging the Python File

  1. Add a breakpoint to the Python file. Left-click to the left of the line numbers to add or remove breakpoints.
    Figure 8 Adding a breakpoint
  2. In the left activity bar, click , click Run and Debug and choose Python Debugger. In the Select a debug configuration pop-up, choose Python File: Debug the currently active Python file to enter debugging mode.
  3. The code will run and pause at the first breakpoint. You can inspect variables in the left panel or use the top control bar to retry, continue, or perform other actions.

Developing a Project

Nanochat is an open-source project released by Andrej Karpathy, a prominent figure in the AI field. It is a minimalist, complete, and low-cost training framework that allows users to train their own conversational, mini version of ChatGPT from scratch in just a few hours for less than US$100.

This section uses the nanochat project as an example to demonstrate how to quickly develop within Code Server, including file uploading, environment preparation, and project execution.

Demonstration environment configuration

  • Instance specification: 8 vCPUs | 32 GB (modelarts.vm.cpu.8u)

  • Demo image: pytorch_2_1:pytorch_2.1.0-cuda_12.1-py_3.9.11-ubuntu_22.04-x86_64-20240313165241-219655b

Loading a Project

You can choose either of the following methods to load the project.

  • Method 1: Download via Git command
    1. Open the terminal.
      Figure 9 New Terminal
    2. Run the following commands to download:
      git clone https://github.com/karpathy/nanochat.git
      cd nanochat
  • Method 2: Drag-and-drop upload
    1. Go to the working directory and open the folder.
      Figure 10 Open Folder
    2. Drag your local folder into the Code Server working directory, and the contents inside the folder will be uploaded automatically.

Preparing the nanochat Environment

  1. Install uv

    uv is an extremely fast Python package and project management tool written in Rust, designed to be a unified, highly efficient toolchain for the Python ecosystem. The nanochat project uses uv to manage its Python environment, so you need to install uv first.

    curl -LsSf https://astral.sh/uv/install.sh | sh
    source $HOME/.local/bin/env
  2. Install the nanochat Environment.

    This tutorial demonstrates the setup based on a CPU environment, so run the following commands to install nanochat:

    export UV_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple
    uv sync --extra cpu

    Note: If you cannot access Hugging Face services, you will need to change the hardcoded data URLs inside the dataset.py file to a domestic mirror source.

Executing Model Training in a CPU Environment

This section is primarily intended to demonstrate the features of Code Server, rather than to train and fine-tune LLMs. Therefore, the number of training iterations in the script has been reduced to shorten the training time. Additionally, no hyperparameter tuning has been performed on the training results. If you wish to achieve better training performance, you can adjust the parameters or run this project in a GPU environment.

Start the training script:

# Start the execution script
bash runs/runcpu.sh

Following this, the main training workflow logs for the model will be displayed in the terminal, which include the following steps:

  1. Training data download: The dataset is downloaded to the /home/ma-user/.cache/nanochat directory by default.
  2. Tokenizer training

  3. Model initialization

  4. Self-supervised training process: You can observe the loss gradually decreasing. Starting from random initialization, the model progressively learns to predict the next token. At step 100, the model outputs repetitive, nonsensical results; by step 3000, the output shows a basic level of logic.

  5. SFT process: An anomaly in the loss can be observed during the SFT process, indicating that running SFT on CPUs requires more specialized hyperparameter tuning.

  6. Model chat

    Run the following script to get conversational output from the model:

    python -m scripts.chat_cli -p "What is the capital of France?"

AI Assistant

Cline is a Code Server extension powered by LLMs that can understand natural language instructions to automate complex development tasks such as code generation, file editing, and terminal command execution. You can use Cline as an AI coding assistant to automate environment configurations, dependency installations, and project usage, significantly boosting your development efficiency.

Configuring Model Service Information in Cline

  • Free models

    Cline offers free model usage. Select Absolutely Free, choose one of the available free models, and log in to your Cline account to start using it.

  • Third-party model providers

    Cline supports a wide range of model access options, including Huawei Cloud MaaS, Claude Code, DeepSeek, OpenAI, and more.

    Taking Huawei Cloud MaaS as an example:

    1. Search for Huawei Cloud MaaS under API Provider.
    2. For the API key, enter the API key you created on Huawei Cloud. For details about how to create one, see Creating an API Key.
    Figure 11 Configuring model information

    Once the configuration is complete, you can start chatting with the LLM directly in the chat box.

    Figure 12 Chatting with the LLM

Project Practice

This section uses the nanochat project as an example to demonstrate how to use the AI assistant Cline to improve development efficiency during project development.

  1. Create a plan:

    Enter your question in the Cline chat box, and Cline will generate an execution plan.

    Figure 13 Formulating a plan
  2. Execute the plan: Click Act to switch to Act mode, and Cline will help you execute the corresponding plan.

    Cline requires certain operation permissions to execute tasks, which can be configured using above the chat box.

    Figure 14 Act mode
    Figure 15 Setting operation permissions

    Cline will automatically execute the following workflow based on the generated plan:

    1. Download the project.

    2. Initialize the nanochat environment.

    3. Run nanochat.

    4. Open the log file, where you can see that the script is running normally.

    5. Modify the number of training steps and retrain.

      You will see that Cline stops the previous training script, automatically modifies the number of steps, and triggers the training script again.

    6. Troubleshooting:
      1. If the script stops unexpectedly after running for a while, use Cline to locate the issue. Once it identifies an out of memory (OOM) error, use Cline to resolve it and rerun the project.

      2. Have Cline modify the script to reduce the model size, and then train again.

      3. After Cline automatically adjusts the model size, the project runs successfully.