相关文章推荐
Sorry, you must verify to complete this action. Please click the verification link in your email. You may re-send via your profile .

Hello,

I have tried to install intel_extension_for_pytorch but have encountered an error while trying to import it:

/bin/sh: 1: source: not found
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last) Cell In[8], line 16 14 # Import packages and print device properties 15 import torch ---> 16 import intel_extension_for_pytorch as ipex 18 print(f"IPEX version: {ipex.__version__}") 19 for i in range(torch.xpu.device_count()): File ~/.local/lib/python3.9/site-packages/intel_extension_for_pytorch/__init__.py:93 89 raise err 91 kernel32.SetErrorMode(prev_error_mode) ---> 93 from .utils._proxy_module import * 94 from . import cpu 95 from . import xpu File ~/.local/lib/python3.9/site-packages/intel_extension_for_pytorch/utils/_proxy_module.py:43 39 # --- [ CPU proxys: 40 _register_proxy_ops('interaction_forward') ---> 43 if not hasattr(intel_extension_for_pytorch._C, 'FP32MathMode'): 44 intel_extension_for_pytorch._C.__dict__['FP32MathMode'] = proxy_math_mode 47 # --- [ XPU proxys: AttributeError: partially initialized module 'intel_extension_for_pytorch' has no attribute '_C' (most likely due to a circular import)

I have followed the instructions to install intel_extension_for_pytorch from https://intel.github.io/intel-extension-for-pytorch/#installation?platform=gpu&version=v2.1.30%2bxpu&os=linux%2fwsl2&package=pip
it installs without any errors.

My code:

#import sys
import subprocess
# Create virtual environment
#subprocess.run([sys.executable, '-m', 'venv', 'octan2'])
# Install packages into virtual environment
#!octan2/bin/python -m pip install torch==2.1.0.post2 torchvision==0.16.0.post2 torchaudio==2.1.0.post2 intel-extension-for-pytorch==2.1.30.post0 oneccl_bind_pt==2.1.300+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/
# Activate the virtual environment (only affects current shell, won't persist across cells)
activate_cmd = 'source octan2/bin/activate'  # Adjust for your OS if needed
subprocess.run(activate_cmd, shell=True)
# Import packages and print device properties
import torch
import intel_extension_for_pytorch as ipex
print(f"IPEX version: {ipex.__version__}")
for i in range(torch.xpu.device_count()):
    print(f"[{i}]: {torch.xpu.get_device_properties(i)}")

I am using the free idc training instance and i have selected the pytorch gpu kernel.

Thanks in advance.

Hi kukevarius,


Thank you for your patience.


Could you please confirm whether you are currently using Jupyter Notebook in the SLURM "Training and Workshop "environment or whether you are using the machine specifically assigned to you?

If you are using "Training and Workshop," please note that the Intel Pytorch Extension cannot be installed due to its design limitations. If you are using the machine assigned to you, could you kindly provide us with the following information for our records:


System Instance ID:

System Instance type:

Regions:

Start date:

End date:



Regards,

Elmer


Hi kukevarius,

Thank you for reaching out to us.


Before we proceed to investigate, please share with us which training you are having issues with.


Furthermore, please try the solution below and provide the issue you replicate along with a full screenshot.

The intel extension for pytorch require a very specific version of torch and torchvision that includes a patch. You may refer the link below.

https://intel.github.io/intel-extension-for-pytorch/xpu/latest/tutorials/installation.html


To verify the version, please share with us if use PyTorch:

"pip3 show torch"

or if use conda:

"conda list -f pytorch"


Besides, please help to source the oneAPI Base Toolkit Environments using the right directories:

# Source oneAPI Base Toolkit

$ source /opt/intel/oneapi/compiler/latest/env/vars.sh

$ source /opt/intel/oneapi/mkl/latest/env/vars.sh

$ source /opt/intel/oneapi/ccl/latest/env/vars.sh

$ source /opt/intel/oneapi/mpi/latest/env/vars.sh



Regards,

Elmer


Hello sorry for the late reply,

pip3 show torch
Name: torch
Version: 2.0.1a0+cxx11.abi
Summary: Tensors and Dynamic neural networks in Python with strong GPU acceleration
Home-page: https://pytorch.org/
Author: PyTorch Team
Author-email: packages@pytorch.org
License: BSD-3
Location: /home/ubb083db7da1ae7febbf5cf6a4045f19/.local/lib/python3.9/site-packages
Requires: filelock, jinja2, networkx, sympy, typing-extensions
Required-by: accelerate, sentence-transformers, torchvision

How to reproduce:

create  a new venv with venv

activate that venv

install torch xpu in the venv

pip install torch==2.1.0.post2 torchvision==0.16.0.post2 torchaudio==2.1.0.post2 intel-extension-for-pytorch==2.1.30.post0 oneccl_bind_pt==2.1.300+xpu --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/

run the code:

import torch
import intel_extension_for_pytorch as ipex
print(f"IPEX version: {ipex.__version__}")
for i in range(torch.xpu.device_count()):
    print(f"[{i}]: {torch.xpu.get_device_properties(i)}")


Expected result

'list of xpu devices'

Result:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[13], line 15
     12 subprocess.run(activate_cmd, shell=True)
     14 # Import packages and print device properties
---> 15 import torch
     16 import intel_extension_for_pytorch as ipex
     18 print(f"IPEX version: {ipex.__version__}")
File ~/.local/lib/python3.9/site-packages/torch/__init__.py:229
    227     if USE_GLOBAL_DEPS:
    228         _load_global_deps()
--> 229     from torch._C import *  # noqa: F403
    231 # Appease the type checker; ordinarily this binding is inserted by the
    232 # torch._C module initialization code in C
    233 if TYPE_CHECKING:
ImportError: /home/ubb083db7da1ae7febbf5cf6a4045f19/.local/lib/python3.9/site-packages/torch/lib/libtorch_cpu.so: undefined symbol: iJIT_NotifyEvent

Screenshot of the notebook below.

Again sorry for the late reply.

Hi kukevarius,


Thank you for your patience.


Could you please confirm whether you are currently using Jupyter Notebook in the SLURM "Training and Workshop "environment or whether you are using the machine specifically assigned to you?

If you are using "Training and Workshop," please note that the Intel Pytorch Extension cannot be installed due to its design limitations. If you are using the machine assigned to you, could you kindly provide us with the following information for our records:


System Instance ID:

System Instance type:

Regions:

Start date:

End date:



Regards,

Elmer


Community support is provided Monday to Friday. Other contact methods are available here .

Intel does not verify all solutions, including but not limited to any file transfers that may appear in this community. Accordingly, Intel disclaims all express and implied warranties, including without limitation, the implied warranties of merchantability, fitness for a particular purpose, and non-infringement, as well as any warranty arising from course of performance, course of dealing, or usage in trade.

For more complete information about compiler optimizations, see our Optimization Notice .

 
推荐文章