Docker for

(Matthew Kleinsmith) #1


Paperspace has a Dockerfile for fastai on If you have nvidia docker, you can get started immediately with:

sudo docker run --runtime=nvidia -d -p 8888:8888 paperspace/fastai:cuda9_pytorch0.3.0

Any code you edit in the container however will be in the container’s file system, and will disappear if you delete the container without moving it out first. If you’d like to keep your code and data on your main file system you can follow my setup. You can also edit Paperspace’s Dockerfile accordingly to allow for this setup.

(End edit)

For those familiar with Docker, here’s a Dockerfile for the fastai library and the Dockerfile’s README for setup details.

Jeremy’s warning

I haven’t experienced any perceivable issues, but I haven’t investigated Docker’s interaction with CUDA to any detail. I’m using NVIDIA’s CUDA 9.0 image as a base image, which might be helping. @jeremy Could you elaborate on these issues? Maybe I’m suffering performance losses from Docker without realizing it.

The beginning of the README

2018-01-12: The Docker image works with the lesson1 notebook. It’s untested for other notebooks.

Why Docker

To not let dependencies slow you or anyone else down.

  • If you make a mistake while sorting out a mess of dependencies, you can just delete the Docker container and start from a fresh one; as opposed to trying to undo it on your operating system.
  • Once you sort out a mess of dependencies, you’ll never have to do it again. Even if you install a new operating system or move to a new computer, you can quickly recover your environment by downloading the corresponding Docker image or Dockerfile.
  • Also, no one else will have to go through that mess, because you can send them the Docker image or Dockerfile.

For more information, check out this Docker tutorial for data science.


How to use the Docker image

If you’ve followed the setup:

  1. Enter fastai into a terminal.
  2. Enter j8 into the container’s terminal that popped up as a result.

A Jupyter server will now be running in a fastai environment with all of fastai’s dependencies.

For those unfamiliar with Docker but would like to learn it, @hamelsmu wrote a great Docker tutorial.


I was hoping to build an image or dockerfile, built from NVIDIA’s GPU Cloud Container for Pytorch. Supposedly NVIDIA’s containers are more optimized. Additionally, as NVIDIA updates every month, things could run even better. However, when I ran some lines from the paperspace setup script (outside of the container), I wasn’t careful and something broke docker-ce. I have been able to run the class outside of my initial intentions, but still want to try it the docker way. Maybe this weekend I will start from scratch/clean ubuntu installation. Any words of advice?

(Matthew Kleinsmith) #3
  1. Could you enter docker run hello-world and paste the output here? I’d like to see if it’s so broken that it can’t run the basic hello-world image.

  2. Could you do the same with docker version? I’d like to see whether your version is up to date.

  1. Do you remember any of the lines you ran? And, are the lines from or from another file?

(Constantin) #4

As for potential performance hit regarding docker: Xu et al. did a thorough analysis in November and put simply they didn’t detect a substantial performance hit.