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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug]: ipex install breaks non xpu devices #435

Open
saforem2 opened this issue Aug 8, 2024 · 2 comments
Open

[bug]: ipex install breaks non xpu devices #435

saforem2 opened this issue Aug 8, 2024 · 2 comments

Comments

@saforem2
Copy link

saforem2 commented Aug 8, 2024

It looks like this line:

import intel_extension_for_pytorch

from #431 breaks things on non Intel systems.

A simple (not yet tested) fix for a device-angostic approach could be something like:

import torch

try:
    import intel_extension_for_pytorch as ipex
except Exception:
    pass

DEVICE = (
    "cuda" if torch.cuda.is_available() else (
        "xpu" if torch.xpu.is_available() else (
            "mps" if torch.backends.mps.is_available() else (
                "cpu"
            )
        )
    )
)

if DEVICE == 'cuda':
    from .fused_layer_norm import MixedFusedLayerNorm as LayerNorm
    from apex.normalization import MixedFusedRMSNorm as RMSNorm
else:
    if hasattr(torch.xpu, "IpexRmsNorm"):
        from .fused_rmsnorm import RMSNorm
    else:
        from .rmsnorm import RMSNorm
    from torch.nn import LayerNorm
# ...

which I believe should work

@vadam5
Copy link

vadam5 commented Aug 13, 2024

I've also had this same issue recently. Can someone please fix this bug?

@clintg6
Copy link

clintg6 commented Aug 20, 2024

+1

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

No branches or pull requests

3 participants