Docker images with architecture optimisation?

2019-05-05 23:56发布

Some libraries such as BLAS/LAPACK or certain optimisation libraries get optimised for the local machine architecture upon compilation time. Lets take OpenBlas as an example. There exist two ways to create a Docker container with OpenBlas:

  1. Use a Dockerfile in which you specify a git clone of the OpenBlas library together with all necessary compilation flags and build commands.

  2. Pull and run someone else's image of Ubuntu + OpenBlas from the Docker Hub.

Option (1) guarantees that OpenBlas is build and optimised for your machine. What about option (2)? As a Docker novice, I see images as something fixed and static, so running this image would not be optimised to my machine (which might be AMD-based instead of the maintainer's Intel CPU). What left me confused is that the image ipython/scipyserver does clone the latest OpenBlas master from Github during build.

I seem to misunderstand the concept of Docker images and/or automated builds, and I would very much appreciate a clarification.

1条回答
时光不老,我们不散
2楼-- · 2019-05-06 00:28

No, I think you're pretty much right.

The image you link to is an automated build, so OpenBlas will be getting compiled using the kernel and architecture of the Docker build server. I did notice the build script sets the following flags when building OpenBlas:

DYNAMIC_ARCH=1 NO_AFFINITY=1 NUM_THREADS=32

Which presumably makes the install portable at a performance cost. An alternative would be to have a separate image for various build configurations.

查看更多
登录 后发表回答