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 14:29:50 +00:00
|
|
|
# This Dockerfile installs pytorch/xla 3.7 wheels. There are also 3.6
|
|
|
|
# wheels available; see below.
|
|
|
|
ENV PYTHON_VERSION=3.6
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2020-07-04 14:22:58 +00:00
|
|
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
2020-07-04 14:29:50 +00:00
|
|
|
build-essential \
|
|
|
|
cmake \
|
|
|
|
git \
|
|
|
|
curl \
|
|
|
|
ca-certificates
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2020-07-04 14:29:50 +00:00
|
|
|
# Install conda and python.
|
|
|
|
# NOTE new Conda does not forward the exit status... https://github.com/conda/conda/issues/8385
|
|
|
|
RUN curl -o ~/miniconda.sh https://repo.anaconda.com/miniconda/Miniconda3-4.7.12-Linux-x86_64.sh && \
|
|
|
|
chmod +x ~/miniconda.sh && \
|
|
|
|
~/miniconda.sh -b && \
|
|
|
|
rm ~/miniconda.sh
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2020-07-04 14:29:50 +00:00
|
|
|
ENV PATH=/root/miniconda3/bin:$PATH
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2020-07-04 14:29:50 +00:00
|
|
|
RUN conda create -y --name container python=$PYTHON_VERSION
|
2020-07-04 14:22:58 +00:00
|
|
|
|
2020-07-04 14:29:50 +00:00
|
|
|
# Run the rest of commands within the new conda env.
|
|
|
|
# Use absolute path to appease Codefactor.
|
|
|
|
SHELL ["/root/miniconda3/bin/conda", "run", "-n", "container", "/bin/bash", "-c"]
|
|
|
|
RUN conda install -y python=$PYTHON_VERSION mkl
|
|
|
|
|
|
|
|
RUN pip uninstall -y torch && \
|
|
|
|
# Python 3.7 wheels are available. Replace cp36-cp36m with cp37-cp37m
|
|
|
|
gsutil cp 'gs://tpu-pytorch/wheels/torch-nightly-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' . && \
|
|
|
|
gsutil cp 'gs://tpu-pytorch/wheels/torch_xla-nightly-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' . && \
|
|
|
|
gsutil cp 'gs://tpu-pytorch/wheels/torchvision-nightly-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' . && \
|
|
|
|
pip install 'torch-nightly-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' && \
|
|
|
|
pip install 'torch_xla-nightly-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' && \
|
|
|
|
pip install 'torchvision-nightly-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' && \
|
|
|
|
rm 'torch-nightly-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' && \
|
|
|
|
rm 'torch_xla-nightly-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' && \
|
|
|
|
rm 'torchvision-nightly-cp${PYTHON_VERSION/./}-cp${PYTHON_VERSION/./}m-linux_x86_64.whl' && \
|
|
|
|
apt-get install -y libomp5
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2020-07-04 14:29:50 +00:00
|
|
|
ENV LD_LIBRARY_PATH=root/miniconda3/envs/container/lib
|
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 14:29:50 +00:00
|
|
|
cd .. && \
|
|
|
|
pip install ./pytorch-lightning
|
2020-07-02 01:44:19 +00:00
|
|
|
|
2020-07-04 14:29:50 +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 14:29:50 +00:00
|
|
|
RUN 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 14:29:50 +00:00
|
|
|
RUN conda init bash
|
|
|
|
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"]
|