Running your own kernel

If you need to work with different language then Python, the Jupyter ecosystem provides you with a vast selection of other kernels. You can now run them in Deepnote! We provide examples for R, Julia and Bash.

R kernel

For new projects

Just go to project with R version 3.5.2 or R version 4.0.3

These links create a project from our R template.

Or for existing projects

Edit the Dockerfile in the environment tab with this initialisation code, build the custom environment cache and restart the machine.

# R version 3.5.2
FROM deepnote/python:3.7
RUN sudo apt-get update && \
sudo apt-get install -y r-base libcurl4-openssl-dev libssl-dev libxml2-dev
RUN pip install notebook
RUN sudo R -e "install.packages('IRkernel', repos='http://cran.rstudio.com/')"
RUN R -e "IRkernel::installspec()"
RUN sudo echo "setwd('~/work')" > ~/.Rprofile
ENV R_LIBS_USER "~/work/.R/library"
# Set default kernel to R
ENV DEFAULT_KERNEL_NAME "ir"
# R version 4.0.3
FROM deepnote/python:3.7
RUN echo "deb http://cloud.r-project.org/bin/linux/debian buster-cran40/" | sudo tee -a /etc/apt/sources.list && \
sudo apt-key adv --keyserver keys.gnupg.net --recv-key 'E19F5F87128899B192B1A2C2AD5F960A256A04AF' && \
sudo apt update && \
sudo apt install -y -t buster-cran40 r-base libcurl4-openssl-dev libssl-dev libxml2-dev
RUN pip install notebook
RUN sudo R -e "install.packages('IRkernel', repos='http://cran.rstudio.com/')"
RUN R -e "IRkernel::installspec()"
RUN sudo echo "setwd('~/work')" > ~/.Rprofile
ENV R_LIBS_USER "~/work/.R/library"
ENV DEFAULT_KERNEL_NAME "ir"

Deepnote uses the environment variable DEFAULT_KERNEL_NAME that you set in the Dockerfile and uses it to create new notebooks with that kernel.

Installing R packages

In the linked R templates

You can simply use the install.packages and library commands the way you normally would.

In your custom environments

R packages take a long time to install, sometimes 10-20 minute for a larger package set. Reinstalling all of them at every hardware restart would lead to a lot of waiting.

One option is to bake them into the Dockerfile by installing at build time.

A second option is setting the env. variableR_LIBS_USER="/home/jovyan/work/.R/library" which ensures that the packages are installed in the work folder, which gets persisted. You can simply copy the corresponding ENV line into your Dockerfile. Note, the directory must exist before it can be used for installation, so consider also adding ! mkdir -p ./.R/library into your init.ipynb (see Custom initialization).

Julia kernel

Edit the Dockerfile in the environment tab with this initialisation code, build the custom environment cache and restart the machine.

FROM gcr.io/deepnote-200602/templates/deepnote
RUN wget https://julialang-s3.julialang.org/bin/linux/x64/1.4/julia-1.4.2-linux-x86_64.tar.gz && \
tar -xvzf julia-1.4.2-linux-x86_64.tar.gz && \
sudo mv julia-1.4.2 /usr/lib/ && \
sudo ln -s /usr/lib/julia-1.4.2/bin/julia /usr/bin/julia && \
rm julia-1.4.2-linux-x86_64.tar.gz && \
julia -e "using Pkg;pkg\"add IJulia\""
ENV DEFAULT_KERNEL_NAME "julia-1.4"

Bash kernel

Edit the Dockerfile in the environment tab with this initialisation code, build the custom environment cache, and restart the machine.

FROM gcr.io/deepnote-200602/templates/deepnote
RUN pip install bash_kernel && python -m bash_kernel.install
ENV DEFAULT_KERNEL_NAME "bash"

Scala 2.12.12 kernel (Almond 0.10.9)

Edit the Dockerfile in the environment tab with this initialization code, build the custom environment cache, and restart the machine.

FROM gcr.io/deepnote-200602/templates/deepnote
RUN wget -qO - https://adoptopenjdk.jfrog.io/adoptopenjdk/api/gpg/key/public | sudo apt-key add -
RUN sudo apt update
RUN sudo apt install -y software-properties-common
RUN sudo add-apt-repository --yes https://adoptopenjdk.jfrog.io/adoptopenjdk/deb/
RUN sudo apt update
RUN sudo mkdir /usr/share/man/man1
RUN sudo apt install -y adoptopenjdk-8-hotspot
RUN curl -Lo coursier https://git.io/coursier-cli
RUN chmod +x coursier
RUN ./coursier launch --fork almond:0.10.9 --scala 2.12.12 -- --install
RUN rm -f coursier
ENV DEFAULT_KERNEL_NAME "scala"

Or clone this project from Deepnote.

Racket kernel

Edit the Dockerfile in the environment tab with this initialization code, build the custom environment cache, and restart the machine.

FROM gcr.io/deepnote-200602/templates/deepnote
# The following snippet is licensed under MIT license
# SEE: https://github.com/jackfirth/racket-docker
RUN sudo apt-get update && \
sudo apt-get install -y libzmq5
ENV RACKET_INSTALLER_URL=http://mirror.racket-lang.org/installers/7.8/racket-7.8-x86_64-linux-natipkg.sh
ENV RACKET_VERSION=7.8
RUN wget --output-document=racket-install.sh -q ${RACKET_INSTALLER_URL} && \
echo "yes\n1\n" | sudo sh racket-install.sh --create-dir --unix-style --dest /usr/ && \
rm racket-install.sh
ENV SSL_CERT_FILE="/etc/ssl/certs/ca-certificates.crt"
ENV SSL_CERT_DIR="/etc/ssl/certs"
RUN sudo raco setup
RUN raco pkg config --set catalogs \
"https://download.racket-lang.org/releases/${RACKET_VERSION}/catalog/" \
"https://pkg-build.racket-lang.org/server/built/catalog/" \
"https://pkgs.racket-lang.org" \
"https://planet-compats.racket-lang.org"
RUN raco pkg install --auto iracket
RUN raco iracket install
ENV DEFAULT_KERNEL_NAME "racket"

Thanks, @dkvasnickajr for sharing this!

You can clone this project from Deepnote.