Distroless Dockerfile (and pip)

I’ve been working on distroless containers for HPC users at the University of Virginia, notably achieving 99.5% reduction in image size for LightGBM and 18% reduction for TensorFlow without loss of performance. I’m wondering if distroless is of interest to the PyTorch community.

Our distroless Dockerfile can be found here and the corresponding image is hosted on Docker Hub uvarc/pytorch:1.6.0-distroless.

The distroless image size is 771 MB which is about half the size of the 1.55 GB official runtime image. I tested that the distroless container with pip installation has the same performance (MNIST benchmark) on our GPU node as the official container with conda installation. I’m aware that the official one has many other conda packages, but I wonder if they are necessary for a minimal (and functional) container.

I’ve read this thread on conda vs pip for pytorch, but is there a specific example that can demonstrate better performance of conda over pip? (MNIST benchmark shows equal performance.)

I couldn’t add more than 2 links in the previous message. If interested:
LightGBM issue
TensorFlow discussion

CC @smth @seemethere for visibility.

So the reason why our docker image may be a bit bigger is because it contains the necessary packages in order to run with GPU support.

So that something like

docker run --rm -it --gpus all pytorch/pytorch

Will function as expected when you have a GPU that is compatible.

Thanks for your reply. I tested the distroless image on our GPU with the MNIST benchmark and it has the same performance as the official image.

As you can see from the link to our Dockerfile in my original message that it is essentially just a “pip install torch”. This already (magically) enables compatibility with GPU at runtime.

(Side note: This was not the case for TensorFlow where I had to copy a bunch of CUDA libraries from nvidia/cuda:cudnn-devel.)

This wouldn’t allow you to either rebuild PyTorch with GPU support or any custom CUDA extension, would it?
If I understand your use case correctly, you are installing the binaries with the CUDA runtime libs.

Our goal here is not to be general, but to create a minimal image without loss of performance.

Comparing with the official image (runtime, not devel), the biggest difference in size is attributed to the extra conda packages.

I just wanted to make sure that the omission of these packages does not affect performance.

I hope this clarifies our intention and question.

1 Like

Thanks for clarification. I was also mistaken in my assumption that the pytorch/pytorch container ships with nvcc, which is not the case.