# VSCode Tutorial: Working with datasci-gpu

In this tutorial, we'll walk you through the process of setting up and using Visual Studio Code (VSCode) to work with datasci-gpu. This guide will cover connecting to the login gateway and accessing specific clusters (e.g., gpu-1-vm, gpu-2-vm, ...) after allocating resources.

Note that this method of connecting to datasci-gpu should be used for debugging and understanding your code via testing and notebooks. If you wish to run long experiments, please use the [SBATCH command](./slurm.md#batch-mode-usage).

## Prerequisites

Before you begin, make sure you have the following prerequisites installed:

- [Visual Studio Code](https://code.visualstudio.com/)
- [Remote - SSH Extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-ssh)

Quick steps to install the *Remote - SSH* extension:
1. Open Visual Studio Code
2. Click on the Extensions icon in the Activity Bar on the side of the window.
3. Search for "Remote - SSH" in the Extensions view search box.
4. Install the "Remote - SSH" extension.

## Step 1: Configuring VSCode

Once the extension is installed, follow these steps to connect to the login gateway (replace `your_username` with your actual username):

1. Press `Ctrl + Shift + P` (Windows/Linux) or `Cmd + Shift + P` (Mac) to open the command palette.
2. Type "Remote-SSH: Open SSH Configuration File ...", select it and select the desired file (recommended file: `~/.ssh/config`).
3. Insert the following part and replace `<username>` and `<path/to/private/key>` with your username and the path to your private key registered in WatGPU:

    ```
    # datasci-gpu
    Host DoNotConnect_datasciGPU
        User <username>
        IdentityFile <path/to/private/key>
        HostName datasci-gpu.cs.uwaterloo.ca

    Host gpu-1-vm
        User <username>
        IdentityFile <path/to/private/key>
        HostName gpu-1-vm
        ProxyJump DoNotConnect_datasciGPU

    Host gpu-2-vm
        User <username>
        IdentityFile <path/to/private/key>
        HostName gpu-2-vm
        ProxyJump DoNotConnect_datasciGPU

    Host gpu-3-vm
        User <username>
        IdentityFile <path/to/private/key>
        HostName gpu-3-vm
        ProxyJump DoNotConnect_datasciGPU
    ```

4. Save and refresh the Remote - SSH extension menu.

## Step 2: Allocate Resources and Connect to Cluster

After successfully connecting via ssh to `datasci-gpu.cs.uwaterloo.ca`, you'll need to allocate resources using `salloc` and then connect to a specific cluster:

1. Follow the [Interactive mode](./slurm.md#interactive-mode-usage) part of the documentation to obtain resource allocation.

2. Once resources are allocated, connect to the appropriate cluster in VSCode:

    ![](./source/clusterchoice.png)

 
That's it! You are now set up to work with datasci-gpu using Visual Studio Code.
