Skip to content

Instantly share code, notes, and snippets.

@sararob
Created September 11, 2019 19:27
Show Gist options
  • Save sararob/2e64187bfb7a46ebce3f79ba25afc02a to your computer and use it in GitHub Desktop.
Save sararob/2e64187bfb7a46ebce3f79ba25afc02a to your computer and use it in GitHub Desktop.
XGBoost custom container training Dockerfile
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the \"License\");
# you may not use this file except in compliance with the License.\n",
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an \"AS IS\" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Dockerfile
FROM python:3.6.9-buster
WORKDIR /root
# Installs xgboost and pandas
RUN pip install numpy==1.13.3 pandas==0.25.0 xgboost==0.90 scikit-learn==0.21.3
# Installs cloudml-hypertune for hyperparameter tuning.
# It’s not needed if you don’t want to do hyperparameter tuning.
RUN pip install cloudml-hypertune
# Installs google cloud sdk, this is mostly for using gsutil to export model.
RUN wget -nv \
https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz && \
mkdir /root/tools && \
tar xvzf google-cloud-sdk.tar.gz -C /root/tools && \
rm google-cloud-sdk.tar.gz && \
/root/tools/google-cloud-sdk/install.sh --usage-reporting=false \
--path-update=false --bash-completion=false \
--disable-installation-options && \
rm -rf /root/.config/* && \
ln -s /root/.config /config && \
# Remove the backup directory that gcloud creates
rm -rf /root/tools/google-cloud-sdk/.install/.backup
# Path configuration
ENV PATH $PATH:/root/tools/google-cloud-sdk/bin
# Make sure gsutil will use the default service account
RUN echo '[GoogleCompute]\nservice_account = default' > /etc/boto.cfg
# Copies the trainer code
RUN mkdir /root/trainer
COPY trainer/model.py /root/trainer/model.py
COPY trainer/rain_uk.csv /root/trainer/rain_uk.csv
# Sets up the entry point to invoke the trainer.
ENTRYPOINT ["python", "trainer/model.py"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment