Skip to content

[iOS][GPU] Add iOS GPU workflow #1200

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 25, 2020
Merged

[iOS][GPU] Add iOS GPU workflow #1200

merged 1 commit into from
Oct 25, 2020

Conversation

xta0
Copy link
Contributor

@xta0 xta0 commented Oct 22, 2020

No description provided.

- Eskimo dog, husky

You may notice that the results are slighly different from the `results <https://pytorch.org/mobile/ios/#install-libtorch-via-cocoapods>`_ we got from the CPU model as shown in the iOS tutorial. This is because by default Metal uses fp16 rather than fp32 to compute. The precision loss is expected.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we point to the GPU performance gain results at pytorch/pytorch#46600 or do a quick summary here?


IOS_ARCH=arm64 USE_PYTORCH_METAL=1 ./scripts/build_ios.sh

Note ``IOS_ARCH`` tells the script to build a arm64 version of Libtorch. This is because in PyTorch, Metal is only available for the iOS devices that support the Apple A9 chip or above. Once the build finished, follow the `Build PyTorch iOS libraries from source <https://pytorch.org/mobile/ios/#build-pytorch-ios-libraries-from-source>`_ section from the iOS tutorial to setup the XCode settings properly. Don't forget to copy the `./mobilenetv2_metal.pt` to your XCode project.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IOS_ARCH=arm64 USE_PYTORCH_METAL=1 ./scripts/build_ios.sh

Note ``IOS_ARCH`` tells the script to build a arm64 version of Libtorch. This is because in PyTorch, Metal is only available for the iOS devices that support the Apple A9 chip or above. Once the build finished, follow the `Build PyTorch iOS libraries from source <https://pytorch.org/mobile/ios/#build-pytorch-ios-libraries-from-source>`_ section from the iOS tutorial to setup the XCode settings properly. Don't forget to copy the `./mobilenetv2_metal.pt` to your XCode project.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In TorchModule.mm we also need to change one line to make the build work:

//#import <LibTorch/LibTorch.h>
#import <torch/script.h>

@brianjo brianjo merged commit c8c5c4d into pytorch:1.7-release Oct 25, 2020
brianjo added a commit that referenced this pull request Oct 27, 2020
* [iOS][GPU] Add iOS GPU workflow (#1200)

* pt mobile script and optimize recipe (#1193)

* pt mobile script and optimize recipe

* 1 pt mobile new recipes summary and 5 recipes

* updated recipes_index.rst

* thumbnail png fix for ios recipe in recipes_index.rst

* edits based on feedback

* Updating 1.7 branch (#1205)

* Update event tracking (#1188)

* Update beginner_source/audio_preprocessing_tutorial.py (#1199)

* Typo in beginner_source/audio_preprocessing_tutorial.py

Typo in beginner_source/audio_preprocessing_tutorial.py

fron > from

* update title.

* fix file access.

Co-authored-by: JuHyuk Park <creduo@gmail.com>

* Update audio_preprocessing_tutorial.py (#1202)

Adds a comment for running this tutorial in Google Colab.

Co-authored-by: Pat Mellon <16585245+patmellon@users.noreply.github.com>
Co-authored-by: Vincent QB <vincentqb@users.noreply.github.com>
Co-authored-by: JuHyuk Park <creduo@gmail.com>

Co-authored-by: Tao Xu <taox@fb.com>
Co-authored-by: Jeff Tang <jeffxtang@fb.com>
Co-authored-by: Pat Mellon <16585245+patmellon@users.noreply.github.com>
Co-authored-by: Vincent QB <vincentqb@users.noreply.github.com>
Co-authored-by: JuHyuk Park <creduo@gmail.com>
rodrigo-techera pushed a commit to Experience-Monks/tutorials that referenced this pull request Nov 29, 2021
* [iOS][GPU] Add iOS GPU workflow (pytorch#1200)

* pt mobile script and optimize recipe (pytorch#1193)

* pt mobile script and optimize recipe

* 1 pt mobile new recipes summary and 5 recipes

* updated recipes_index.rst

* thumbnail png fix for ios recipe in recipes_index.rst

* edits based on feedback

* Updating 1.7 branch (pytorch#1205)

* Update event tracking (pytorch#1188)

* Update beginner_source/audio_preprocessing_tutorial.py (pytorch#1199)

* Typo in beginner_source/audio_preprocessing_tutorial.py

Typo in beginner_source/audio_preprocessing_tutorial.py

fron > from

* update title.

* fix file access.

Co-authored-by: JuHyuk Park <creduo@gmail.com>

* Update audio_preprocessing_tutorial.py (pytorch#1202)

Adds a comment for running this tutorial in Google Colab.

Co-authored-by: Pat Mellon <16585245+patmellon@users.noreply.github.com>
Co-authored-by: Vincent QB <vincentqb@users.noreply.github.com>
Co-authored-by: JuHyuk Park <creduo@gmail.com>

Co-authored-by: Tao Xu <taox@fb.com>
Co-authored-by: Jeff Tang <jeffxtang@fb.com>
Co-authored-by: Pat Mellon <16585245+patmellon@users.noreply.github.com>
Co-authored-by: Vincent QB <vincentqb@users.noreply.github.com>
Co-authored-by: JuHyuk Park <creduo@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants