Create a Machine Learning Environment using VS Code Remote Containers

Manav
Aruva.io Tech
Published in
3 min readMar 2, 2021

My organization has recently started to Machine Learning models and the developers have been tasked to create and validate a Classification model

After some deliberation we decided to stick to Python and use Jupyter (https://jupyter.org/) server

However, a fundamental challenge encountered was when every developer has a different python version, pip version, conda version or libraries. Also configuring Jupyter with venv has been sort of challenging to say the least

There was a gap to be bridged by standardizing the developer environment, IDE setup, package installations and library management

After numerous iterations on this, a VS Code based environment with Remote Containers is our preferred way to go.

More information about VS Code Remote Containers is available here.

What will we accomplish:
A fully functional VS Code environment with the following installed and ready to go. All in a dockerized environment with no changes to base system other than installing docker.

- python v3.9.1
- pip v21.0.1
- jupyter server
- pandas
- scikit and sklearn dependencies
- numpy

I will create another post on how to create this setup from scratch for your custom implementation

Pre-Requisite:
Install Docker for your system (windows, mac or Linux) [https://www.docker.com/]
Install Visual Studio Code [https://code.visualstudio.com/]

Step 1. Configure VS Code
Open VS Code and install the `Docker` support plugin and `Remote Containers` plugin

Select Plugins tab -> Search for Remote Containers -> Install

Step 2. Clone base project from my github repository
`https://github.com/605ive/vscode-ml-jupyter-python-project.git`

Git clone the project in a directory of your choice

Step 3. Open the project folder in VS Code
This should automatically trigger VS Code to identify this as a remote-container project and prompt to `Open in Remote Container`

click -> Reopen in Container

Let this step complete — as we are installing a lot of dependencies, this step will take some time depending on your CPU, network and other factors

Step 4. Validate the `Remote Container` project is now open
Look for the `Dev Container` Activation bar on bottom left of your VS Code IDE

Bottom Left corner of your VS Code IDE

Step 5. Check python version, pip version
Fire up the terminal and ensure python and pip are now installed and available for use

vs-code terminal screen

Step 6. Open the Command Palette and create a blank Jupyter Notebook
You should be on your way with Python, pip, Jupyter server and other dependent libraries now installed

As this is dockerized environment, none of the above tools exist in you base machine and there is no need to manage multiple python interpreters using venv or other environment management tools

Happy coding!

--

--

Manav
Aruva.io Tech

We build world-class accelerators for businesses to take their idea from conceptualization to reality