Skip to content

Using VSCode over SSH

langdonholmes edited this page Jul 10, 2024 · 10 revisions

Some tasks are not a good fit for JupyterHub. Developers may require bare metal access to a GPU-accelerated machine. This is the case for work that involves building and running Docker containers (see iTELL API). For these tasks, we have set up a remote development workflow using VS Code over SSH.

NOTE: Please use JupyterHub unless there is a specific reason why JupyterHub does not work for your project.

Requirements

  • Make sure you can connect to Vanderbilt's VPN.
  • Make sure your Vanderbilt account is authorized to login in to LEAR Lab Development Server 2 (10.33.2.13).

Setup

  • Connect to the Vanderbilt VPN from your client machine.
  • Verify that you can SSH into the server from your client, e.g., by running ssh VUNETID@10.33.2.13

Setup Docker

The only anticipated reason to use VSCode over SSH in lieu of JupyterHub is for development work on Docker images. To run Dockers you will need to perform the following setup:

sudo usermod -aG docker $USER

newgrp docker

docker run hello-world (to verify that you can run a docker image without using sudo)

  • Install Remote SSH Extension in your client-side VS Code and connect

Setup Git

  • On the server, the instructions for setting up your Github account are the same as they are inside JupyterHub. Instructions

Devcontainers with GPU Access

Some repositories include a devcontainer.json configuration file that builds a Docker container with GPU access. This configuration file defines a specific GPU (gpu_device=0). After starting a devcontainer, you can verify that it has GPU access by running nvidia-smi from within the VSCode terminal. There are two main reasons this command might fail:

  1. Someone else is using the GPU.
  2. VSCode failed to terminate a previous devcontainer. As a result, that devcontainer may still be occupying the GPU.

To resolve the second issue, you can SSH into the server and run the following commands:
docker ps
docker stop [container_id]

Then, in VSCode, use the "Reload Window" command and test GPU availability again.

Command to inspect running containers

docker ps --format '{{.ID}}' | xargs docker inspect | jq '.[] | "Container ID: \(.Config.Hostname) -- GPU: \(.HostConfig.DeviceRequests | .[].DeviceIDs[0]) -- Directory: \(.Config.Labels."devcontainer.local_folder")"'

Clone this wiki locally