Skip to content

devops : reduce Vulkan Docker image to 39.4% of its original size (now 692 MB) - #4038

Merged
danbev merged 5 commits into
ggml-org:masterfrom
turicas:enhancement/optmize-docker-image
Sep 21, 2026
Merged

danbev merged 5 commits into
ggml-org:masterfrom
turicas:enhancement/optmize-docker-image

Conversation

@turicas

@turicas turicas commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

The current Vulkan Docker image is 1.75 GB. Making it smaller not only reduces download and storage requirements, but can also make the image faster to build and distribute. This PR applies 4 changes to main-vulkan.Dockerfile, reducing the final image size from 1.75 GB to 692 MB (39.4% of the original size). The build time also decreased from 2m41s to 2m16s (84.4% of the original).

These were the main contributors to the current image size:

  • Installing recommended APT packages
  • Installing development packages in the runtime/final stage
  • Copying the entire repository and build artifacts into the runtime/final stage (including the base.en model)

I also made a couple of improvements:

  • Use apt instead of apt-get
  • Remove bash -c as the entrypoint

I'm willing to apply the same changes to the other Dockerfiles in the repository if the maintainers approve this approach. I started with the Vulkan image because it's the one I use.

Result:

$ docker image ls whispercpp-test
REPOSITORY        TAG                                   IMAGE ID       CREATED          SIZE
whispercpp-test   04-remove-entrypoint                  70eb4215ee40   11 minutes ago   692MB
whispercpp-test   03-copy-only-needed-files             57eeec07fb51   19 minutes ago   692MB
whispercpp-test   02-remove-dev-packages-from-runtime   35cde18f6236   22 minutes ago   1.37GB
whispercpp-test   01-do-not-install-recommends          5677b0c472aa   28 minutes ago   1.6GB
whispercpp-test   00-original                           2b93628d52a7   31 minutes ago   1.75GB

Notes:

  1. Regarding libsdl2-dev (removed in the second commit): commit bea43e0 (not mine) introduced this package in the runtime image, but since it's not required for production use, I think it should instead be installed by users who need it in an image derived from this one.
  2. I've run all the docker run commands from the README using the final Dockerfile in this PR and everything worked as expected (the examples were also fixed/extended).

Also:
- Replace apt-get with apt
- Explicitly install ca-certificates
Won't copy compiled tests, source code and other build artifacts.
With this change, arguments passed to `docker run` are forwarded
directly to the selected command.

Having `bash -c` in the entrypoint will cause additional arguments to be
interpreted according to shell command-string semantics, which makes
commands such as model downloaders and CLI tools behave unexpectedly
unless `--entrypoint` is specified explicitly or the whole command is
quoted.

Removing it restores the conventional Docker behavior of: `docker run
IMAGE COMMAND ARG...` passing `ARG` to `COMMAND` (not to `bash`).
@turicas turicas changed the title Reduce Vulkan Docker image to 39.4% of its original size (now 692 MB) devops : reduce Vulkan Docker image to 39.4% of its original size (now 692 MB) Sep 6, 2026
@danbev
danbev merged commit 307869a into ggml-org:master Sep 21, 2026
38 of 40 checks passed
@turicas

turicas commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

@danbev thanks for the review! Should I create one more PR for the other Dockerfiles?

@danbev

danbev commented Sep 23, 2026

Copy link
Copy Markdown
Member

Should I create one more PR for the other Dockerfiles?

I think it would be best to do them as separate PRs. Thanks!

bygreencn added a commit to bygreencn/whisper.cpp that referenced this pull request Sep 23, 2026
* ggerganov/master:
  vad : reject n_encoder_layers other than 4 in model load (ggml-org#4064)
  devops : reduce Vulkan Docker image to 39.4% of its original size (now 692 MB) (ggml-org#4038)
7h145 added a commit to 7h145/whisperer that referenced this pull request Oct 5, 2026
Upstream commit 307869a (PR#4038, merged 2026-09-21) moved executables
and model downloaders into /usr/local/bin, but only for the Vulkan
image. The CUDA image still uses /app/build/bin and /app/models.

Upstream has welcomed follow-up PRs for the other Dockerfiles, but there
is no committed plan or timetable for converging the published images on
a common layout. Moving tools to /usr/local/bin is sensible; changing
only one image leaves consumers handling an avoidable split. I'm not
impressed with how this change was coordinated.

Select tools by name and use an inline Bash entrypoint that appends the
legacy directories to the image's PATH. Existing PATH entries take
precedence; exec preserves argument boundaries and signal handling.

Keep mode-specific arguments and setup together in the command case
branches, removing nameref indirection and manual entrypoint JSON
construction.

Upstream: ggml-org/whisper.cpp#4038
7h145 added a commit to 7h145/whisperer that referenced this pull request Oct 5, 2026
Upstream commit 307869a (PR #4038, merged 2026-09-21) introduced leaner
runtime packaging and a /usr/local layout for the Vulkan image, but left
CUDA on the old layout. Having accommodated that split in whisper.sh,
follow the cleaner convention in our local SDL/CUDA image.

Use the Vulkan staging approach rather than carrying the source checkout
and build debris into the runtime image. Keep the CUDA build unchanged
and retain the dependencies needed for streaming and model downloads.
Explicitly clear NVIDIA's inherited entrypoint to match Vulkan's
conventional direct-command behavior.

Upstream welcomed follow-up PRs but has no committed convergence
timetable. Reusing its existing packaging keeps our change small and
easy to compare with a future CUDA update; broader alignment can wait.

Upstream: ggml-org/whisper.cpp#4038
@turicas
turicas deleted the enhancement/optmize-docker-image branch November 9, 2026 11:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants