Docker image for fastai with pytorch cpu

I’m searching for a docker image with fastai and pytorch-cpu. All the images I’ve seen has pytorch with cuda. Where can I find one with pytorch-cpu?

1 Like

I’m building it with anaconda. Can share it if you like.

Will have to remove other stuff though. Let me know.

1 Like

Can you please share it @bhoomit ?

Thank you

Give me a day. I will have to build once I remove all the “unsharable” changes.

Okay. Thank you :slight_smile:

Here you go.

Let me know if you face any issues.

1 Like

Thank you @bhoomit

@BBloggsbott: Did you end up getting this docker image to work ? Or was some finesse needed ?

@bhoomit: When I tried the docker build step, I would keep getting an error when it tries the conda activate command, complaining that conda init has not been done, or a logoff/logon was required.

Thanks for any ideas here.

Removed zstd-1.4.0-h3b9ef0a_0.tar.bz2
Removed pandas-0.24.2-py37hb3f55d8_0.tar.bz2
Removed cudatoolkit-10.0.130-0.tar.bz2
Removed mkl-2019.4-243.tar.bz2
Removed gst-plugins-base-1.14.5-h0935bb2_0.tar.bz2
WARNING: /root/.conda/pkgs does not exist
Cache location: /opt/conda/pkgs
Will remove the following packages:

libblas-3.8.0-7_openblas 21 KB
liblapack-3.8.0-7_openblas 21 KB
libcblas-3.8.0-7_openblas 21 KB
pthread-stubs-0.4-h14c3975_1001 12 KB
matplotlib-3.1.0-py37_1 17 KB

Total: 90 KB

removing libblas-3.8.0-7_openblas
removing liblapack-3.8.0-7_openblas
removing libcblas-3.8.0-7_openblas
removing pthread-stubs-0.4-h14c3975_1001
removing matplotlib-3.1.0-py37_1
no change /opt/conda/condabin/conda
no change /opt/conda/bin/conda
no change /opt/conda/bin/conda-env
no change /opt/conda/bin/activate
no change /opt/conda/bin/deactivate
no change /opt/conda/etc/profile.d/
no change /opt/conda/etc/fish/conf.d/
no change /opt/conda/shell/condabin/Conda.psm1
no change /opt/conda/shell/condabin/conda-hook.ps1
no change /opt/conda/lib/python3.7/site-packages/xonsh/conda.xsh
no change /opt/conda/etc/profile.d/conda.csh
modified /root/.bashrc

==> For changes to take effect, close and re-open your current shell. <==

CommandNotFoundError: Your shell has not been properly configured to use ‘conda activate’.
To initialize your shell, run

$ conda init <SHELL_NAME>

Currently supported shells are:

  • bash
  • fish
  • tcsh
  • xonsh
  • zsh
  • powershell

See ‘conda init --help’ for more information and options.

IMPORTANT: You may need to close and restart your shell after running ‘conda init’.

The command ‘/bin/sh -c conda env create -f /code/conda_environment.yml && conda clean --all --yes && conda init bash && conda activate fastai’ returned a non-zero code: 1

$ docker run -it fastai-docker:cpu bash
Unable to find image ‘fastai-docker:cpu’ locally
docker: Error response from daemon: pull access denied for fastai-docker, repository does not exist or may require ‘docker login’.
See ‘docker run --help’.

Sorry for this issue. It actually worked fine when I built earlier.

Now fixed:

Rebuild and let me know if you still face this issue.

@phule888, Sorry for the late response. I just changed my laptop and haven’t gotten to using the image yet. I’ll you know in a day or two.

@bhoomit I have been trying to use your image on a raspberry pi 3b+. I am getting an error on the RUN mkdir /code line, The command ‘/bin/sh -c mkdir ~/code’ returned a non-zero code: 1
Any ideas on why this is crashing?

@runninbear5 o clue about RPi, Ideally it should not matter since its a docker image. I will try to push an image to Docker Hub, see if you are able to use it.

@bhoomit That is great to hear, thank you. Let me know when you have pushed it up and where to find it so I can try running it.
Thanks again

@bhoomit Can this work for fastai==0.7.x?

This is a Dockerfile I used for my project that involves fastai.


Hi guys!

Is it possible to replace torch==1.6.0+cu101 and torchvision==0.7.0+cu1010 with torch==1.6.0+cpu torchvision==0.7.0+cpu, and mask out the environemnt variable os.environ[“CUDA_VISIBLE_DEVICES”] = “” when containerizing the app or will this break fastai?

Thought I would update you guys on what works and what doesn’t.

You can effectively change your requirements.txt by replacing torch==1.6.0+cu101, torchvision==0.7.0+cu1010 by torch==1.6.0+cpu torchvision==0.7.0+cpu respectively.

Then all you have to do is dockerize the app and you’ll be running pytorch on cpu.

Just a side note. This reduced my container size by roughly 50%!

1 Like