Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

AppleSilicon binaries are build without OpenMP support #114721

Closed
malfet opened this issue Nov 29, 2023 · 8 comments 路 Fixed by pytorch/builder#1697
Closed

AppleSilicon binaries are build without OpenMP support #114721

malfet opened this issue Nov 29, 2023 · 8 comments 路 Fixed by pytorch/builder#1697
Assignees
Labels
high priority oncall: releng In support of CI and Release Engineering triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Milestone

Comments

@malfet
Copy link
Contributor

malfet commented Nov 29, 2023

馃悰 Describe the bug

% python -c "import os;import torch;print(os.uname().sysname, os.uname().machine, torch.__version__, torch.backends.openmp.is_available())"
Darwin arm64 2.1.1 False

Versions

2.1.x, nightly

cc @ezyang @gchanan @zou3519 @kadeng

@malfet malfet added high priority oncall: releng In support of CI and Release Engineering labels Nov 29, 2023
@malfet malfet added this to the 2.2.0 milestone Nov 29, 2023
@garyyaoresearch
Copy link

garyyaoresearch commented Nov 29, 2023

Hi, wondering about what steps you propose to take and how can I contribute to this issue?
Same issue on M2.
print(os.uname().sysname, os.uname().machine, torch.__version__, torch.backends.openmp.is_available()) Darwin arm64 2.2.0a0+gita076a74 False

@malfet malfet self-assigned this Nov 29, 2023
@malfet malfet changed the title M1 wheels (and probably conda) are build without OpenMP support AppleSilicon binaries are build without OpenMP support Nov 29, 2023
pytorchmergebot pushed a commit that referenced this issue Nov 29, 2023
@malfet
Copy link
Contributor Author

malfet commented Nov 29, 2023

@garyyaoresearch sorry, edited the title, I've used M1 as alias for Apple Silicon, but yes, they are not the same.
Can you run some CPU benchmarks on your M2 and see whether all cores are used during those tests. If it is indeed the case, perhaps we don't need OpenMP support. (Though OpenMP can still be faster)

@malfet
Copy link
Contributor Author

malfet commented Nov 29, 2023

Fun fact: it is enabled in nightlies (I assume as result of #110432 ):

% python -c "import os;import torch;print(os.uname().sysname, os.uname().machine, torch.__version__, torch.backends.openmp.is_available())"
Darwin arm64 2.2.0.dev20231129 True

@garyyaoresearch
Copy link

garyyaoresearch commented Nov 30, 2023

@garyyaoresearch sorry, edited the title, I've used M1 as alias for Apple Silicon, but yes, they are not the same. Can you run some CPU benchmarks on your M2 and see whether all cores are used during those tests. If it is indeed the case, perhaps we don't need OpenMP support. (Though OpenMP can still be faster)

Hey no problem. Happy to help :). In running test_sparse.py, nn/test_convolution.py, it seems like all cores are used, but not to full capacity (observed max 350% cpu for 8 cores). In addition, https://discuss.pytorch.org/t/pytorch-unable-to-fully-utilize-cpu-when-performing-svd/192524, indicates such as well.

I think the next steps might be to compare performance against nightly with OpenMP enabled. Do you that will be helpful?

@garyyaoresearch
Copy link

garyyaoresearch commented Nov 30, 2023

Fun fact: it is enabled in nightlies (I assume as result of #110432 ):

% python -c "import os;import torch;print(os.uname().sysname, os.uname().machine, torch.__version__, torch.backends.openmp.is_available())"
Darwin arm64 2.2.0.dev20231129 True

I tried this, but a regular conda install of the nightly doesn't have openmp available. Will try building nightly from binary and also look into the build process.

@drisspg drisspg added triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module and removed triage review labels Dec 4, 2023
@atalman atalman modified the milestones: 2.2.0, 2.2.1 Jan 9, 2024
@huydhn
Copy link
Contributor

huydhn commented Feb 5, 2024

So it's not enabled on MacOS nightly for 3.11:

python -c "import os;import torch;print(os.uname().sysname, os.uname().machine, torch.__version__, torch.backends.openmp.is_available())"
Darwin arm64 2.3.0.dev20240205 False

but it's on Linux aarch64:

 python -c "import os;import torch;print(os.uname().sysname, os.uname().machine, torch.__version__, torch.backends.openmp.is_available())"
Linux aarch64 2.2.0 True

@huydhn
Copy link
Contributor

huydhn commented Feb 6, 2024

Surprisingly, 3.9 wheel works fine

python -c "import os;import torch;print(os.uname().sysname, os.uname().machine, torch.__version__, torch.backends.openmp.is_available())"
Darwin arm64 2.3.0.dev20240205 True
python -c "import os;import torch;print(os.uname().sysname, os.uname().machine, torch.__version__, torch.backends.openmp.is_available())"
Darwin arm64 2.2.0 True

Need to do a bit of auditing with 3.1[0-2] Only 3.11 binary has this issue. It smells like a bug somewhere in the build here.

@huydhn
Copy link
Contributor

huydhn commented Feb 21, 2024

Confirm that this has been fixed on the latest 2.2.1 RC on all python versions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
high priority oncall: releng In support of CI and Release Engineering triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants