Skip to content

Commit

Permalink
Build torchvision from the pytorch pin in ansible (#6756) (#6960)
Browse files Browse the repository at this point in the history
Co-authored-by: Will Cromar <wcromar@google.com>
  • Loading branch information
lsy323 and will-cromar authored Apr 24, 2024
1 parent 8c33979 commit b94c014
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 29 deletions.
2 changes: 0 additions & 2 deletions infra/ansible/config/pip.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,3 @@ pip:
# Packages that will be installed with the `--nodeps` flag.
pkgs_nodeps:
release_common:
- torchvision
- pillow
8 changes: 2 additions & 6 deletions infra/ansible/e2e_tests.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,15 @@ RUN ansible-playbook -vvv playbook.yaml -e "stage=release" -e "${ansible_vars}"
# Copy test sources.
RUN mkdir -p /src/pytorch/xla
COPY --from=build /src/pytorch/xla/test /src/pytorch/xla/test
# Copy ci_commit_pins from upstream
RUN mkdir -p /src/pytorch/.github
COPY --from=build /src/pytorch/.github/ci_commit_pins /src/pytorch/.github/ci_commit_pins

# Copy and install wheels.
WORKDIR /tmp/wheels
COPY --from=build /src/pytorch/dist/*.whl ./
COPY --from=build /src/pytorch/xla/dist/*.whl ./
COPY --from=build /dist/*.whl ./

RUN echo "Installing the following wheels" && ls *.whl
RUN pip install *.whl

WORKDIR /

# Clean-up unused directories.
RUN rm -rf /ansible /tmp/wheels
RUN rm -rf /ansible /tmp/wheels
20 changes: 20 additions & 0 deletions infra/ansible/roles/build_srcs/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@
state: absent
mode: '0755'

- name: Read Torchvision pin
ansible.builtin.command: cat {{ (src_root, 'pytorch') | path_join }}/.github/ci_commit_pins/vision.txt
register: torchvision_pin

- name: Build Torchvision wheel
ansible.builtin.command:
cmd: pip wheel --no-build-isolation --no-deps "git+https://github.com/pytorch/vision.git@{{ torchvision_pin.stdout }}"
chdir: /dist
environment: "{{ env_vars }}"

- name: Find Torchvision *.whl files in /dist
ansible.builtin.find:
path: /dist
pattern: "torchvision*.whl"
register: torchvision_wheels

- name: Install Torchvision wheel
ansible.builtin.pip:
name: "{{ torchvision_wheels.files | map(attribute='path') }}"

- name: "Tests"
include_tasks: tests.yaml
tags:
Expand Down
19 changes: 0 additions & 19 deletions infra/ansible/roles/fetch_srcs/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,6 @@
dest: "{{ (src_root, 'pytorch/xla') | path_join }}"
version: "{{ xla_git_rev }}"

- name: Find *.diff files in pytorch/xla/openxla_patches
ansible.builtin.find:
path: "{{ (src_root, 'pytorch/xla/openxla_patches') | path_join }}"
pattern: "*.diff"
register: openxla_patches

- name: Apply patches to OpenXLA
ansible.posix.patch:
src: "{{ item }}"
# Use source file on the target machine instead of the one where
# the playbook is located. Has no effect when the target machine is
# localhost.
remote_src: true
strip: 1
ignore_whitespace: true
basedir: "{{ (src_root, 'pytorch/xla/third_party/xla') | path_join }}"
loop: "{{ openxla_patches.files | map(attribute='path') }}"
ignore_errors: true

- name: "Tests"
include_tasks: tests.yaml
tags:
Expand Down
2 changes: 0 additions & 2 deletions test/tpu/xla_test_job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ spec:
- bash
- -cxe
- |
# Torchvision installed from a commit requires torch, need to install after torch is compiled.
pip install --no-use-pep517 "git+https://github.com/pytorch/vision.git@$(cat /src/pytorch/.github/ci_commit_pins/vision.txt)"
pip install expecttest==0.1.6
pip install rich
pip install torch_xla[pallas] -f https://storage.googleapis.com/jax-releases/jax_nightly_releases.html -f https://storage.googleapis.com/jax-releases/jaxlib_nightly_releases.html
Expand Down

0 comments on commit b94c014

Please sign in to comment.