Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate down to a single Dockerfile #366

Merged
merged 4 commits into from Mar 7, 2018

Conversation

ojarjur
Copy link
Contributor

@ojarjur ojarjur commented Mar 6, 2018

This change eliminates the duplication between the two Dockerfiles
(one for CPU-only instances and one for GPU-enabled instances) by
eliminating the second file.

The two files were meant to differ in two ways:

  1. The base image used (ubuntu vs. nvidia/cuda)
  2. The tensorflow package installed (tf-nightly vs. tf-nightly-gpu)

It turns out that we can just make both of those arguments (defined
by an ARG statement with a default value), and then the two
files can be merged into one.

The default values chosen for the args are the ones for the CPU
image, so running docker build . without any --build-arg flags
will produce the CPU image.

To build a GPU image, pass in the corresponding values for the
BASE_IMAGE and TF_PACKAGE arguments using --build-arg flags.

This fixes #321


This change is Reviewable

This change eliminates the duplication between the two Dockerfiles
(one for CPU-only instances and one for GPU-enabled instances) by
eliminating the second file.

The two files were meant to differ in two ways:

1. The base image used (ubuntu vs. nvidia/cuda)
2. The tensorflow package installed (tf-nightly vs. tf-nightly-gpu)

It turns out that we can just make both of those arguments (defined
by an `ARG` statement with a default value), and then the two
files can be merged into one.

The default values chosen for the args are the ones for the CPU
image, so running `docker build .` without any `--build-arg` flags
will produce the CPU image.

To build a GPU image, pass in the corresponding values for the
`BASE_IMAGE` and `TF_PACKAGE` arguments using `--build-arg` flags.

This fixes kubeflow#321
@ojarjur
Copy link
Contributor Author

ojarjur commented Mar 6, 2018

/cc inc0
/cc jlewi

@k8s-ci-robot k8s-ci-robot requested review from inc0 and jlewi March 6, 2018 21:10
Copy link

@inc0 inc0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm I haven't tested it - don't have gpu so can't really, but it looks awesome. Great job!

@ojarjur
Copy link
Contributor Author

ojarjur commented Mar 6, 2018

... Actually, hold off on this for now; the TF_PACKAGE isn't being resolved correctly for some reason.

I'll update this PR when it is ready for review.

FROM ubuntu:latest

ARG BASE_IMAGE=ubuntu:latest
ARG TF_PACKAGE=tf-nightly
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ARG should be moved down to right before it is used.

@ojarjur
Copy link
Contributor Author

ojarjur commented Mar 6, 2018

I got the TF_PACKAGE issue resolved; this PR should be ready for review now.

@jlewi
Copy link
Contributor

jlewi commented Mar 7, 2018

This is great.

Our release process actually uses this
script
https://github.com/kubeflow/kubeflow/blob/master/components/tensorflow-notebook-image/build_image.sh

which is invoked by argo here
https://github.com/kubeflow/kubeflow/blob/master/components/tensorflow-notebook-image/releaser/components/workflows.libsonnet#L136

Could you update these so that the release process will still work?

@jimexist
Copy link
Member

jimexist commented Mar 7, 2018

/lgtm

@k8s-ci-robot k8s-ci-robot removed the lgtm label Mar 7, 2018
@jlewi
Copy link
Contributor

jlewi commented Mar 7, 2018

This is great thank you so much.

/lgtm
/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inc0, Jimexist, jlewi

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid code duplication in Dockerfiles for Jupyter notebook images
5 participants