Skip to content

Instantly share code, notes, and snippets.

@vfdev-5
Created April 28, 2020 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vfdev-5/3395399e1f581dcfa0159d46ab7056cb to your computer and use it in GitHub Desktop.
Save vfdev-5/3395399e1f581dcfa0159d46ab7056cb to your computer and use it in GitHub Desktop.
Torch XLA Image, CPU
FROM python:3.6-buster
# - Install gsutil to copy wheels from gcr
# - Install openblas
# - Download torch & xla
# - Setup Python 3.6 env for Torch XLA wheels
# - Install torch & xla
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list && \
apt-get install -y apt-transport-https ca-certificates gnupg curl && \
curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - && \
apt-get update && apt-get install -y google-cloud-sdk && \
apt-get install -y libopenblas-dev libomp5 && \
gsutil cp gs://tpu-pytorch/wheels/torch-1.5-cp36-cp36m-linux_x86_64.whl . && \
gsutil cp gs://tpu-pytorch/wheels/torch_xla-1.5-cp36-cp36m-linux_x86_64.whl .
RUN pip install mkl && \
pip install torch-1.5-cp36-cp36m-linux_x86_64.whl && \
pip install torch_xla-1.5-cp36-cp36m-linux_x86_64.whl
ENV LD_LIBRARY_PATH $LD_LIBRARY_PATH:/usr/local/lib/
ENV XRT_DEVICE_MAP "CPU:0;/job:localservice/replica:0/task:0/device:XLA_CPU:0"
ENV XRT_WORKERS "localservice:0;grpc://localhost:40934"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment