Platform: Docker (Free; non-beginner)

sudo apt update
sudo apt install texlive-full

Seems to solve the xelatex error, but be warned this way oversolves the problem and is around 4gb. Probably something similar to texlive-xelatex as a package would solve this but for anyone following this thread too, this will add pdf and tex output support.

1 Like

Awesome! Thank you for looking into that. If it’s adding 4Gb to the image, I hesitant to add it by default. For those who really need to print, your install it pretty easy…

Thanks!

Thanks to zerotosingularity for creating this thread and uploading fastai2 docker containers. I’ve tried his docker container https://hub.docker.com/repository/docker/zerotosingularity/fastai2 and can confirm that it’s working for course-v4. His docker container starts up jupyter notebook whose root directory is some volume external to the docker container.

I’ve also been able to create a docker container which runs course-v4. I’m new to docker so approached the problem by writing a bunch of shell scripts. The scripts are a work-in-progress.

Goals:

  1. Scripts will allow easy installation of fastai2 onto an Ubuntu system.
  2. Scripts will enable quick and easy changes to configs (docker, conda, pip, fastai, my code) without messing up the base system.
  3. The docker container will have GPU access and similar performance to native.
  4. The docker container will have rwx access to my development volume allowing easy development from within and between docker containers.
  5. Any project work done within a container will be easy to backup.
  6. The docker container uses my userid and group for seamless non-root permissions access.
  7. The scripts will be serially re-runable and make minimal assumptions about state.
  8. Docker related scripts will eventually be made into a dockerfile.

The work-in-progress scripts are at https://github.com/BSalita/docker_ubuntu_fastai2

I just published my script to deploy fastai2 image classification models with docker. Please let me know if there are things than can be improved :slight_smile: .

2 Likes

I can’t seem to edit the original post, but there are official Docker images available now. You can find them here:

https://hub.docker.com/u/fastdotai

We’ll keep our images available so feel free to use them if you like:

https://hub.docker.com/u/seemeai

1 Like

This is how I setup the course documents with Docker on Ubuntu using the official docker images. Using volumes so that my work is saved:

Note: You should already have installed nvidia compatible docker, nvidia drivers, and git should be available.

  1. Create directory in my root folder called fastainotebooks: mkdir fastainotebooks
  2. Change directory into the notebooks folder: cd fastainotebooks
  3. Use git clone to create the basic notebooks: git clone https://github.com/fastai/course-v4.git
  4. Use git clone to create the complete notebooks: git clone https://github.com/fastai/fastbook.git
  5. Run the container changing the number of gb of memory you want to direct to it and replacing username here with your linux username (type pwd if you are not sure): docker run --gpus all --shm-size 24g --ulimit memlock=-1 -p 8888:8888 -v /home/YOUR_USERNAME_HERE/fastainotebooks:/workspace/coursenbs fastdotai/fastai ./run_jupyter.sh

You should now be able to access the course notebooks in your container and any edits you make to the notebooks will be saved back to your volume. Note that you have to clone the git notebooks, because the official containers contain the previous courses notebooks, but it’s good to have the local notebooks on a volume on your machine anyways, so that any edits you make will be saved.

You can also save the run command in an sh file by saving the command on the second line of a text file with #!/bin/bash on the first line and saving the file as sh, and then you can just run the sh instead of having to run the entire large docker command.

2 Likes

Hi @zerotosingularity if i use ubuntu on my laptop (i have an integrated intel graphic card), does the docker give access to the gpu? or do we need to have the gpu on machine?

Looks good Florian, and good work, I have also previously release fastai v1 and now v2, started pack for deploying vision models via docker, I guess difference is I have avoided nginx route completely, which may or may not be great solution depending upon use case. Here is V2 post => Deployment ready template for creating responsive web app for Fastai2 Vision models

2 Likes

Sorry for the late reply, I missed the notification on this.

If you pass the --gpus all flag when you start the container, it will have access to your GPU inside the container. I have updated the Docker hub documentation to reflect that.

That being said, you will need a NVidia GPU to use PyTorch/fast.ai.

I have to run the following commands to get the course notebook to work with the official docker containers:

  1. Open a terminal in jupyter lab from the main menu (not in your notebook, where you select the notebook) by clicking new on the right and then selecting terminal
  2. Install graphviz binaries: apt-get install graphviz
  3. Change directory to course-v4 or fastbook cloned git repository, in my case I used the volume in my previous post: cd coursenbs/fastbook
  4. Use pip to install requirements: pip install -r requirements.txt
  5. Restart any running notebook and make sure notebooks you open are trusted

Note: You have to do this every time you relaunch the docker container!

@hamelsmu adding you in the thread, you might be able to fix :slight_smile: :grinning:

He’s really great. After I wrote my first post, he created a separate docker file for the course with the notebooks already cloned into them.

I keep meaning to write a docker compose file for it, instead of using the run command, but I haven’t had time.

2 Likes

It’s a great community of people indeed!

With respect to the repo already cloned, I prefer to keep files you will likely edit outside of the container and add them via a volume.

All your changes will persist even if you restart the container. I usually just mount my home-folder on my AI machine so I have all my projects…

I set this up months ago … https://github.com/miramar-labs/fastai-devbox

1 Like

I see you do that too :grinning::grinning:

As a suggestion, you can add the fastai and pytorch cache folder as a volume, you you don’t need to redownload pretrained model weights for example…

Hello all ( @chusc @zerotosingularity) we have created official Dockerfiles for your development environment which you can see on the README here:

This includes very detailed instructions on how to use with a GPU and how to start a notebook etc, along with some utlities baked in. @jeremy and myself are in the process of refactoring the Docker containers and currently have 2 different DockerHub orgs one called fastdotai and another called fastai. For right now, you can use what is listed in the README as the other stuff we are using for CI. At some point we will consolidate everything a bit more and refresh the README when it changes, but these should be ready to use and working!

A docker-compose file could be a good idea. We already have a docker-compose file in most repos already but that is to support GitHub codespaces on CPU, we could try to find a way to orchestrate the Makefile so that you could run Docker-compose on GPUs and have everything just work (this would also be helpful for me). Tagging @jeremy as well for visibility, incase he has an opinion.

I agree that Docker compose files make it more tractable to use Docker as your development environment so you don’t have to mess with all the mount commands and can start multiple services concurrently (notebook, docs site, etc. )

Thanks for the feedback! Those are a great resource and glad they are available/officially supported.

With respect tot @mlabs’ question, you might need to look at graphviz needed to be installed with apt-get?

On a topic level, although I have added a reference to the official fastai docker containers, it might be a good idea to convert this topic, or create a new topic specifically for “Official Docker images” or something like that, which might be less confusing for people looking for fastai+docker guidance.

What do you think?

@hamelsmu I looked at your docker run examples on github/fastai/docker-containers and want to add that pytorch github docs suggest using a --shm-size parameter.

I found using shm-size and ulimit memlock=-1 were important when running fast-ai v1, I think I was running the paperspace fastai v1 container. Obviously people use docker containers in many different environments, but for desktop dev and run or compose, shm-size around 1/2 your ram and hopefully greater than your vram and memlock=-1 are a good idea.

I think docker dev is going to be the best way to run this on your desktop shortly, because Windows 10 WSL2 GPU/CUDA docker support is in fast ring beta. Soon you’ll be able to run this on any windows gaming machine with an nvidia graphics card by just installing a wsl2 distro and docker and running a command.