Creating the Best Prototyping Workspace

Contents

Introduction

↑ back to contents ↑

Conda and Jupyter Lab are probably the best combination for easily manage packages and test code snippets while prototyping, especially in Machine and Deep Learning fields. For instance, some models could require Tensorflow 1.15, others Tensorflow 2.0, older ones Caffe2, or some other framework, and with such a setup, you can easily switch environments and python versions with a simple click.

Since I am working a lot with Docker on remote servers, I need also a ready-to-use Docker image. Hence, I built an image integrating Jupyter, Conda, and some little tools which I think could provide the “best prototyping workspace” with a very low effort. Indeed, the davidelanz/jupyter docker image provides a quick, dockerized setup for Jupyter Lab with multiple Conda environments.

  Features
The image comes with jupyterlab_code_formatter already installed
The image comes with LSP Python language server for JupyterLab (jedi 0.17.2) already installed
The image comes already with a Python3.7 Conda environment with OpenCV support called opencv-py3.7

Mount the image from DockerHub

↑ back to contents ↑

Download the image from davidelanz/jupyter, then mount the container (the image exposes JupyterLab on the 8888 port):

docker pull davidelanz/jupyter
docker run \
    -p <CONTANER_PORT>:8888 \
    -v <EXTERNAL_FOLDER>:/workspace \
    --name <CONTAINER_NAME> davidelanz/jupyter

Your workspace will be available at http://localhost:<CONTANER_PORT>.

Build from GitHub

↑ back to contents ↑

The image can be directly built from the GitHub repository:

$ git clone https://github.com/davidelanz/jupyter-docker
$ cd jupyter-docker/
$ docker build . -t davidelanz/jupyter

Manage Conda environments

↑ back to contents ↑

The image comes already with a Python3.7 environment with OpenCV support called opencv-py3.7.

You can create a new environment as follows (you can easily do it from the JupyterLab console):

conda create -y --name <DESIRED_ENV_NAME> python=<DESIRED_PYTHON_VERSION>

Then you can load it to JupyterLab as follows:

conda activate <DESIRED_ENV_NAME> && \
    conda install -y ipykernel && \
    python -m ipykernel install --name <DESIRED_ENV_NAME> --user

With Jupyter installed you get the list of currently installed kernels with:

jupyter kernelspec list

If you want to uninstall an unwanted kernel:

jupyter kernelspec uninstall <UNWANTED_KERNEL>