ModuleNotFoundError: No module named 'intel_extension_for_pytorch'
Describe the issue
I am new to using pytorch on a gpu. I have been trying to use the intel_extension_for_pytorch on my windows 11 system with Intel Iris Xe graphics. I have installed the driver from https://www.intel.com/content/www/us/en/download/785597/intel-arc-iris-xe-graphics-windows.html and oneAPI base toolkit for windows.
However, I am getting ModuleNotFoundError while trying to import intel_extension_for_pytorch.
Can someone pls guide me.
Hi, per your description it seems that you just installed the dependencies but not ipex itself. Please run the following command for installing ipex.
python -m pip install torch==2.1.0a0 torchvision==0.16.0a0 torchaudio==2.1.0a0 intel-extension-for-pytorch==2.1.10 --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/
And before importing ipex in python env, please source the env variable setting scripts:
call {DPCPPROOT}\env\vars.bat
call {MKLROOT}\env\vars.bat
If you still get errors in sanity test after ipex installation, please double check if oneAPI basekit version is correct (should be 2024.0 for latest ipex version).
Thanks for your inputs. I have done all the above. I get the following error now:
OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\prash\AppData\Roaming\Python\Python311\site-packages\intel_extension_for_pytorch\bin\intel-ext-pt-gpu.dll" or one of its dependencies.
The intel-ext-pt-gpu.dll file is there in the said path.
Thanks for the trials. I'll try to reproduce and try to find the root cause.
Hi @prashanthrgs I cannot reproduce the issue you met. Would you please check if you are following the guide and try again?
conda create -n ipex_test python=3.10
conda activate ipex_test
conda install pkg-config libuv # please install it in your conda environment, it is needed.
python -m pip install torch==2.1.0a0 torchvision==0.16.0a0 torchaudio==2.1.0a0 intel-extension-for-pytorch==2.1.10 --extra-index-url https://pytorch-extension.intel.com/release-whl/stable/xpu/us/
(ipex_test) C:\Users\test>"C:\Program Files (x86)\Intel\oneAPI\compiler\2024.0\env\vars.bat"
(ipex_test) C:\Users\test>"C:\Program Files (x86)\Intel\oneAPI\mkl\2024.0\env\vars.bat"
(ipex_test) C:\Users\test>python -c "import torch; import torchvision; import torchaudio; import intel_extension_for_pytorch as ipex; print(f'torch_version: {torch._version}'); print(f'torchvision_version: {torchvision.version}'); print(f'torchaudio_version: {torchaudio.version}'); print(f'ipex_version: {ipex.version_}');"
C:\Users\test\miniconda3\envs\ipex_test\lib\site-packages\torchvision\io\image.py:13: UserWarning: Failed to load image Python extension: ''If you don't plan on using image functionality from `torchvision.io`, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have `libjpeg` or `libpng` installed before building `torchvision` from source?
warn(
torch_version: 2.1.0a0+cxx11.abi
torchvision_version: 0.16.0a0+cxx11.abi
torchaudio_version: 2.1.0a0+cxx11.abi
ipex_version: 2.1.10+xpu
would you try install VS2022 build tools and see if the reported error can be mitigated?
Also, please use "developer command prompt for vs 2022" or "anaconda prompt", instead of "powershell prompt".
Note: neither “windows powershell” or “anaconda powershell prompt” does not work, if using conda prompt, we need to use "anaconda prompt"
I have tried the above steps using Anaconda Prompt. I get the following error:
Traceback (most recent call last):
File "
Attached is the entire sequence of steps performed from Anaconda Prompt. Anaconda Prompt.txt
Please activate DPCPP compiler & oneMKL env variables in advance
call "C:\Program Files (x86)\Intel\oneAPI\compiler\latest\env\vars.bat"
call "C:\Program Files (x86)\Intel\oneAPI\mkl\latest\env\vars.bat"
After activating them:
C:\Users\prash.conda\envs\ipex_test\lib\site-packages\torchvision\io\image.py:13: UserWarning: Failed to load image Python extension: ''If you don't plan on using image functionality from torchvision.io, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have libjpeg or libpng installed before building torchvision from source?
warn(
Traceback (most recent call last):
File "
Seems a copy-paste error. For checking versions the format is {pkg_name}.__version__ (2 underline symbol at the front and back of 'version'). e.g. torch.__version__
@prashanthrgs Hello, right, in the last step the sanity check code is
https://intel.github.io/intel-extension-for-pytorch/index.html#installation?platform=gpu&version=v2.1.10%2Bxpu
call {DPCPPROOT}\env\vars.bat
call {MKLROOT}\env\vars.bat
`python -c "import torch; import intel_extension_for_pytorch as ipex; print(torch.__version__); print(ipex.__version__); [print(f'[{i}]: {torch.xpu.get_device_properties(i)}') for i in range(torch.xpu.device_count())];"`
or
python -c "import torch; import torchvision; import torchaudio; import intel_extension_for_pytorch as ipex; print(f'torch_version: {torch.**__version__**}'); print(f'torchvision_version: {torchvision.__version__}'); print(f'torchaudio_version: {torchaudio.__version__}'); print(f'ipex_version: {ipex.__version__}');"
not the one :
python -c "import torch; import torchvision; import torchaudio; import intel_extension_for_pytorch as ipex; print(f'torch_version: {torch**._version**}'); print(f'torchvision_version: {torchvision.version}'); print(f'torchaudio_version: {torchaudio.version}'); print(f'ipex_version: {ipex.version_}');"
(Did you copy it from somewhere of our doc, please let us know, maybe we can fix it there.)
thank you!
Thanks @ZailiWang for your assistance. I was able to start using ipex.
Hello, it seems I am having the same problems as the previous user with the usage of the ipex library (I also have Intel iRISXe Graphics on Windows 11) .
Other than a few basic changes (such as the change from 2024.0 to 2024.1 in the paths passed to the prompt), I get the same errors:
- OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\test.conda\envs\ipex_test\lib\site-packages\torch\lib\backend_with_compiler.dll" or one of its dependencies.
- OSError: [WinError 127] The specified module could not be found. Error loading "C:\Users\test.conda\envs\ipex_test\lib\site-packages\torch\lib\backend_with_compiler.dll" or one of its dependencies.
I have installed VS2022, Intel® oneAPI DPC++ Compiler and Intel® oneAPI Base Toolkit as asked in the installation page and haven't had any warnings or errors in those installations, I have restarted the PC as suggested by the installer and now I am trying to install pytorch, pytorchvision and ipex, but something is not working.
To make it easier for you to help me I have also attached a file txt containing all my prompts. Ipex_Problems_1.txt Ipex_Problems_2.txt Thank you in advance for the support.