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
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
pyiron - an integrated development environment (IDE) for computational materials science.

pyiron pyiron - an integrated development environment (IDE) for computational materials science. It combines several tools in a common platform: Atomi

pyiron 20 Dec 22, 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
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
A Sublime Text package that allows a user to view all the available core/plugin commands for Sublime Text and Sublime Merge, along with their documentation/source.

CommandsBrowser A Sublime Text package that allows a user to view all the available core/plugin commands for Sublime Text and Sublime Merge, along wit

Sublime Instincts 26 Nov 15, 2022
Launch a ready-to-code Wagtail Live development environment with a single click.

Wagtail Live Gitpod Launch a ready-to-code Wagtail Live development environment with a single click. Steps: Click the Open in Gitpod button. Relax: a

Coen van der Kamp 6 Oct 29, 2021
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
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
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
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
VSCode Development Container Template

VSCode Development Container Template This template enables you to use a full-fledged containerized development environment for your machine learning

Paige Bailey 10 Oct 10, 2022
Mu - A Simple Python Code Editor

A small, simple editor for beginner Python programmers. Written in Python and Qt5.

Mu 1.2k Jan 03, 2023
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
Gaphor is a UML and SysML modeling application written in Python.

Gaphor is a UML and SysML modeling application written in Python. It is designed to be easy to use, while still being powerful. Gaphor implements a fully-compliant UML 2 data model, so it is much mor

Gaphor 1.3k Jan 07, 2023
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
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
Spyder - The Scientific Python Development Environment

Spyder is a powerful scientific environment written in Python, for Python, and designed by and for scientists, engineers and data analysts. It offers a unique combination of the advanced editing, ana

Spyder IDE 7.3k Jan 08, 2023
Python 3 patcher for Sublime Text v4107-4114 Windows x64

sublime-text-4-patcher Python 3 patcher for Sublime Text v4107-4114 Windows x64 Credits for signatures and patching logic goes to https://github.com/l

187 Dec 27, 2022
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