VSCode Development Container Template

Overview

VSCode Development Container Template

This template enables you to use a full-fledged containerized development environment for your machine learning projects - all with VSCode!

The container itself will only take care of running the code, the files/data and your credentials are brought over from and saved to your local workspace, so it all works out of the box.

Prerequisites

You should have the following installed on the machine where your containers will run, as well as on your local machine (if they are different):

If you plan to use GPU in the containers you will also need:

If you don't plan to use the GPU, then you need to make a few small adjustments described in the CPU Only section.

Additionally, you need to expose your user id as an environmental variable UID on the device where your containers will run. If you use bash or zsh, you do this by adding the following to your .bashrc or .zshrc file:

export UID

Quickstart: local

This assumes that all your files are on a local machine, where you also want to run the container. If you want to run the container on a remote machine, check out the remote section.

All you need to do is to open the repository in VSCode, press Ctrl + Shift + P and type/select "Reopen in Container".

Quickstart: remote

This instructions are for the following scenario: your files and credentials are on a remote host machine (such as an AWS server, desktop workstation), and the only use of your local machine is to connect to the host. It is required that you have the same username on both local and host machine.

The same username is required, because it will be used in the name of docker compose project, as well as the docker image. This enables multiple users on the same machine to use development containers without interfering with each other, as they will all have a separate compose project/docker image.

First, you need to set the docker.host setting in VSCode on your local machine to point at your host machine - see here for instructions. Next, you need to execute the following on both the local and host machine from the root of your repository (this you have to do just once in the lifecycle of the project)

> .env ">
echo "COMPOSE_PROJECT_NAME=${PWD##*/}_${USER}" >> .env 

Next, execute this from the root of your repository on the host machine

docker-compose -f .devcontainer/docker-compose.yml up -d

You can close the remote terminal after that. Finally, open the repository in VSCode on your local machine, press Ctrl + Shift + P and type/select "Reopen in Container".

This way, everything will work as expected - even the port 8888 of the remote container will be mapped to port 8888 in your local machine.

What's in this template

This template does a few things, and it's useful to know what they are, so you know what to adjust. I'll explain it by describing what is the function of each file in this repo. Here's a directory tree diagram:

.
├── .devcontainer
│   ├── devcontainer.json
│   ├── docker-compose.yml
│   ├── Dockerfile
│   ├── env_dev.yml
│   └── jupyter_lab_config.py
├── env.yml
├── sys_requirements.txt
└── ...
  • .devcontainer/devcontainer.json: This defines the VSCode development container. It delegates the "base" of the container itself to docker-compose.yml , and focuses on forwarding ports, installing VSCode extensions and adjusting VSCode settings.
  • .devcontainer/docker-compose.yml: This file mainly takes care of configuring how the docker container connects to the local file system. Namely, it does these things:
    • sets the user ID of the user in the container to match the local user, to avoid file permission issues
    • mounts the workspace folder to the container
    • mounts the credentials folders to the container (as read-only): for example, the .ssh and .aws folders
    • mounts some other folders (in this example the DVC cache) and sets environmental variables credentials
  • .devcontainer/env_dev.yml: This conda environment file specifies the requirements for development (they will be added to the base environment) - for example testing and linting.
  • .devcontainer/Dockerfile: This is the real "meat" of this whole thing. It creates a container based on the base CUDA image (which by itself does not have drivers or CUDA installed), installs all the system and python requirements and creates a user corresponding to your current local user. If your setup requires some heavier system modification, you should do it here.
  • .devcontainer/jupyter_lab_config.py: this sets some useful jupyter notebook/lab presets, such as a password (you should change this) and the default port.
  • env.yml: This is a conda environment, defining all the base (non-development) requirements of your project.
  • sys_requirements.txt: This is a minimal system requirements (stuff you install with apt-get ) file.

CPU Only

If you want to use this on a CPU-only device, you need to make three minor changes:

  1. In env.yml change cudatoolkit=11.0 to cpuonly.
  2. In .devcontainer/docker-compose.yml remove runtime: nvidia
  3. In Dockerfile, change the nvidia/cuda... base image to ubuntu:${UBUNTU_VERSION}
Owner
Paige Bailey
Radically improving developer productivity with machine learning @microsoft. Previously: @deepmind, @googleai.
Paige Bailey
An amazing simple Python IDE for developers!

PyHub An amazing simple Python IDE for developers! Get ready to compile and run your code in the most simplest and easiest IDE of the ancient world! T

Aniket Bhattacharjee 2 Dec 31, 2022
Clarity mode is a single-notebook interface built with existing JupyterLab components.

JupyterLab Clarity Mode Clarity mode is a single-notebook interface built with existing JupyterLab components. To install: Clone this repository Ensur

10 Jul 20, 2022
This is code for IDLE python/ Magic8Ball Code

Magic8Ball this is code for IDLE python/ Magic8Ball Code this code is for beginers i hope you can learn code form this don't ever be a script kiddie a

1 Nov 05, 2021
Joy is a tiny creative coding library in Python.

Joy Joy is a tiny creative coding library in Python. Installation The easiest way to install it is download joy.py and place it in your directory. The

FOSS United Foundation 181 Dec 04, 2022
CTO (Call Tree Overviewer) is an IDA plugin for creating a simple and efficiant function call tree graph

CTO (Call Tree Overviewer) CTO (Call Tree Overviewer) is an IDA plugin for creating a simple and efficiant function call tree graph. It can also summa

Hiroshi Suzuki 257 Dec 24, 2022
cottonformation is a Python tool providing best development experience and highest productivity

Welcome to cottonformation Documentation Full Documentatioin Here cottonformation is a Python tool providing best development experience and highest p

Sanhe 6 Jul 08, 2022
A GitHub Action hosted Python IDE!

What is this ? This is an IDE running on GitHub Actions which can help in..... Running small snippets. Running codes whenever PC is not available and

Jainam Oswal 21 Nov 09, 2022
VSCode extension to sort and refactor python imports using reorder-python-imports.

reorder-python-imports VSCode extension to sort and refactor python imports using reorder-python-imports. Unlike other import organizers, reorder-pyth

Ryan Butler 3 Aug 26, 2022
Jarvide - A powerful AI mixed with a powerful IDE.

Jarvide About Jarvide Welcome to Jarvide. A powerful AI mixed with a powerful ID

Caeden 23 Oct 28, 2022
notebookJS: seamless JavaScript integration in Python Notebooks

notebookJS enables the execution of custom JavaScript code in Python Notebooks (Jupyter Notebook and Google Colab). This Python library can be useful for implementing and reusing interactive Data Vis

jorgehpo 146 Dec 07, 2022
Integrate clang-format with Sublime Text

Sublime Text Clang Format Plugin This is a minimal plugin integrating clang-format with Sublime Text, with emphasis on the word minimal. It is not rea

Jon Palmisciano 1 Dec 17, 2021
Run context-aware commands from your source code comments

Run context-aware commands from your source code comments. Codeline allows you to run custom commands directly from source-code comments, combining th

Rory Byrne 32 Nov 09, 2021
Automatically detect obfuscated code and other state machines

Scripts to automatically detect obfuscated code and state machines in binaries.

Aaron 110 Dec 04, 2022
A comfy custom IDE where you can feel right at home

reZIDE a comfy custom IDE where you can feel right at home 🏡 Use simple, declarative configuration files to create complex IDEs with a single command

Zach 7 Jan 26, 2022
Shows Odin Lang errors in Sublime Text.

OdinErrors Shows Odin Lang errors in Sublime Text. Config Collections and defines are stored in ols.json (Hijacked from ols). { "collections": [

Gus 3 Nov 20, 2021
💻 Open recent VS Code folders and files using Ulauncher

ulauncher-vscode-recent 💻 Open recent VS Code folders and files using Ulauncher. Quickly open recently-opened VS Code project directories and files.

Mihir Chaturvedi 14 Nov 24, 2022
Blender add-on for baking your scene to textures

Bake Scene This add-on bakes your scene to textures. This is useful in many situations: Creating trim sheets Creating decals Creating hair cards Creat

5 Sep 20, 2022
Python IDE or notebook to generate a basic Kepler.gl data visualization

geospatial-data-analysis [readme] Use this code in your Python IDE or notebook to generate a basic Kepler.gl data visualization, without pre-configura

2 Sep 05, 2022
Live coding in Python with PyCharm, Emacs, Sublime Text, or even a browser

Live Coding in Python Visualize your Python code while you type it in PyCharm, Emacs, Sublime Text, or even your browser. To see how to use one of the

Don Kirkby 256 Dec 14, 2022
ROS2 Docker tutorial with VSCode

ROS2-Docker-tutorial I made this repository using athackst/vscode_ros2_workspace templete with foxy-nvidia branch. You could see more information abov

Tae Young Kim 4 Nov 03, 2022