2020-07-02 01:44:19 +00:00
|
|
|
FROM google/cloud-sdk:slim
|
|
|
|
|
|
|
|
# Build args.
|
|
|
|
ARG GITHUB_REF=refs/heads/master
|
|
|
|
ARG TEST_IMAGE=0
|
|
|
|
|
2020-07-04 15:31:12 +00:00
|
|
|
# This Dockerfile installs pytorch/xla 3.7 wheels. There are also 3.6 wheels available; see below.
|
|
|
|
ENV PYTHON_VERSION=3.7
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2020-07-04 15:31:12 +00:00
|
|
|
SHELL ["/bin/bash", "-c"]
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2020-07-04 15:31:12 +00:00
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
|
|
python${PYTHON_VERSION} \
|
|
|
|
python${PYTHON_VERSION}-dev \
|
|
|
|
$( [ ${PYTHON_VERSION%%.*} -ge 3 ] && echo "python${PYTHON_VERSION%%.*}-distutils" ) \
|
|
|
|
build-essential \
|
|
|
|
cmake \
|
|
|
|
git \
|
|
|
|
curl \
|
|
|
|
wget \
|
|
|
|
ca-certificates \
|
|
|
|
libomp5 \
|
|
|
|
&& \
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2020-07-04 15:31:12 +00:00
|
|
|
# install python dependencies
|
|
|
|
wget https://bootstrap.pypa.io/get-pip.py --progress=bar:force:noscroll --no-check-certificate && \
|
|
|
|
python${PYTHON_VERSION} get-pip.py && \
|
|
|
|
rm get-pip.py && \
|
2020-07-04 14:22:58 +00:00
|
|
|
|
2020-07-04 15:31:12 +00:00
|
|
|
# Set the default python and install PIP packages
|
|
|
|
update-alternatives --install /usr/bin/python${PYTHON_VERSION%%.*} python${PYTHON_VERSION%%.*} /usr/bin/python${PYTHON_VERSION} 1 && \
|
|
|
|
update-alternatives --install /usr/bin/python python /usr/bin/python${PYTHON_VERSION} 1
|
2020-07-04 14:29:50 +00:00
|
|
|
|
2020-07-04 15:31:12 +00:00
|
|
|
RUN py_version=${PYTHON_VERSION/./} && \
|
2020-07-04 14:29:50 +00:00
|
|
|
# Python 3.7 wheels are available. Replace cp36-cp36m with cp37-cp37m
|
2020-07-04 15:31:12 +00:00
|
|
|
gsutil cp "gs://tpu-pytorch/wheels/torch-nightly-cp${py_version}-cp${py_version}m-linux_x86_64.whl" . && \
|
|
|
|
gsutil cp "gs://tpu-pytorch/wheels/torch_xla-nightly-cp${py_version}-cp${py_version}m-linux_x86_64.whl" . && \
|
|
|
|
gsutil cp "gs://tpu-pytorch/wheels/torchvision-nightly-cp${py_version}-cp${py_version}m-linux_x86_64.whl" . && \
|
|
|
|
pip install "torch-nightly-cp${py_version}-cp${py_version}m-linux_x86_64.whl" && \
|
|
|
|
pip install "torch_xla-nightly-cp${py_version}-cp${py_version}m-linux_x86_64.whl" && \
|
|
|
|
pip install "torchvision-nightly-cp${py_version}-cp${py_version}m-linux_x86_64.whl" && \
|
|
|
|
rm "torch-nightly-cp${py_version}-cp${py_version}m-linux_x86_64.whl" && \
|
|
|
|
rm "torch_xla-nightly-cp${py_version}-cp${py_version}m-linux_x86_64.whl" && \
|
|
|
|
rm "torchvision-nightly-cp${py_version}-cp${py_version}m-linux_x86_64.whl" && \
|
|
|
|
pip install mkl
|
|
|
|
|
|
|
|
ENV LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib/"
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2020-07-04 15:31:12 +00:00
|
|
|
RUN python -c "import torch; print(torch.__version__)"
|
2020-07-02 01:44:19 +00:00
|
|
|
|
|
|
|
# Install pytorch-lightning at the current PR, plus dependencies.
|
|
|
|
RUN git clone https://github.com/PyTorchLightning/pytorch-lightning.git && \
|
|
|
|
cd pytorch-lightning && \
|
|
|
|
git fetch origin $GITHUB_REF:CI && \
|
|
|
|
git checkout CI && \
|
2020-07-04 15:31:12 +00:00
|
|
|
pip install --requirement ./requirements/base.txt
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2020-07-04 15:31:12 +00:00
|
|
|
# If using this image for tests, intall more dependencies and don"t delete
|
2020-07-02 01:44:19 +00:00
|
|
|
# the source code where the tests live.
|
2020-07-04 15:31:12 +00:00
|
|
|
RUN \
|
|
|
|
# TODO: use conda sources if possible
|
|
|
|
# drop Horovod
|
|
|
|
# python -c "fname = './pytorch-lightning/requirements/extra.txt' ; lines = [ln for ln in open(fname).readlines() if not ln.startswith('horovod')] ; open(fname, 'w').writelines(lines)" && \
|
|
|
|
# pip install -r pytorch-lightning/requirements/extra.txt ; && \
|
|
|
|
if [ $TEST_IMAGE -eq 1 ] ; then \
|
2020-07-02 01:44:19 +00:00
|
|
|
pip install -r pytorch-lightning/requirements/test.txt ; \
|
|
|
|
else \
|
|
|
|
rm -rf pytorch-lightning ; \
|
|
|
|
fi
|
|
|
|
|
2020-07-04 15:31:12 +00:00
|
|
|
#RUN python -c "import pytorch_lightning as pl; print(pl.__version__)"
|
2020-07-02 01:44:19 +00:00
|
|
|
|
|
|
|
COPY docker-entrypoint.sh /usr/local/bin/
|
|
|
|
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
|
|
|
|
|
|
|
|
ENTRYPOINT ["/usr/local/bin/docker-entrypoint.sh"]
|
|
|
|
CMD ["bash"]
|