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

Can't import ipex in a pytest session #416

Open
fcharras opened this issue Aug 30, 2023 · 1 comment
Open

Can't import ipex in a pytest session #416

fcharras opened this issue Aug 30, 2023 · 1 comment
Labels
NotAnIssue XPU/GPU XPU/GPU specific issues

Comments

@fcharras
Copy link

Describe the bug

Create a file import_ipex.py with the following content:

import intel_extension_for_pytorch as ipex

then run it with pytest:

$ pytest ./import_ipex.py

then pytest fails at the collection step:

================================================================================== test session starts ===================================================================================
platform linux -- Python 3.10.12, pytest-7.4.0, pluggy-1.2.0
rootdir: /root/sklearn-pytorch-engine
configfile: setup.cfg
plugins: scikit-learn-1.4.dev0
collected 0 items / 2 errors                                                                                                                                                                                                               

================================================================================================================== ERRORS ==================================================================================================================
_________________________________________________________________________________________________ ERROR collecting scripts/import_ipex.py __________________________________________________________________________________________________
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/doctest.py:547: in collect
    module = import_path(
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/pathlib.py:565: in import_path
    importlib.import_module(module_name)
/root/mambaforge/envs/torch_igpu/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1050: in _gcd_import
    ???
<frozen importlib._bootstrap>:1027: in _find_and_load
    ???
<frozen importlib._bootstrap>:1006: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:688: in _load_unlocked
    ???
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:178: in exec_module
    exec(co, module.__dict__)
import_ipex.py:1: in <module>
    import intel_extension_for_pytorch as ipex
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/intel_extension_for_pytorch/__init__.py:95: in <module>
    from . import xpu
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/intel_extension_for_pytorch/xpu/__init__.py:594: in <module>
    override_assert_equal()
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/intel_extension_for_pytorch/xpu/overrides.py:67: in override_assert_equal
    from torch.testing._internal.common_utils import TestCase
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/torch/testing/_internal/common_utils.py:57: in <module>
    import expecttest
E   ModuleNotFoundError: No module named 'expecttest'
_________________________________________________________________________________________________ ERROR collecting scripts/import_ipex.py __________________________________________________________________________________________________
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/runner.py:341: in from_call
    result: Optional[TResult] = func()
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/runner.py:372: in <lambda>
    call = CallInfo.from_call(lambda: list(collector.collect()), "collect")
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/python.py:531: in collect
    self._inject_setup_module_fixture()
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/python.py:545: in _inject_setup_module_fixture
    self.obj, ("setUpModule", "setup_module")
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/python.py:310: in obj
    self._obj = obj = self._getobj()
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/python.py:528: in _getobj
    return self._importtestmodule()
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/python.py:617: in _importtestmodule
    mod = import_path(self.path, mode=importmode, root=self.config.rootpath)
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/pathlib.py:565: in import_path
    importlib.import_module(module_name)
/root/mambaforge/envs/torch_igpu/lib/python3.10/importlib/__init__.py:126: in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
<frozen importlib._bootstrap>:1050: in _gcd_import
    ???
<frozen importlib._bootstrap>:1027: in _find_and_load
    ???
<frozen importlib._bootstrap>:1006: in _find_and_load_unlocked
    ???
<frozen importlib._bootstrap>:688: in _load_unlocked
    ???
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/_pytest/assertion/rewrite.py:178: in exec_module
    exec(co, module.__dict__)
import_ipex.py:1: in <module>
    import intel_extension_for_pytorch as ipex
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/intel_extension_for_pytorch/__init__.py:95: in <module>
    from . import xpu
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/intel_extension_for_pytorch/xpu/__init__.py:568: in <module>
    serialization.register_package(30, _xpu_tag, _xpu_deserialize)
/root/mambaforge/envs/torch_igpu/lib/python3.10/site-packages/torch/serialization.py:93: in register_package
    _package_registry.sort()
E   TypeError: '<' not supported between instances of 'function' and 'function'
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Interrupted: 2 errors during collection !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
======================================================================================================= 1 warning, 2 errors in 1.81s =======================================================================================================

so that it's impossible to run tests with the xpu backend with pytest. (outside of pytest it works perfectly fine in my environment).

Versions

Collecting environment information...
PyTorch version: 2.0.1a0+gite9ebda2
PyTorch CXX11 ABI: Yes
IPEX version: 2.0.110+git509a378
IPEX commit: 509a3789d
Build type: Release

OS: Ubuntu 22.04.2 LTS (x86_64)
GCC version: (Ubuntu 11.3.0-1ubuntu1~22.04.1) 11.3.0
Clang version: N/A
IGC version: 2023.2.0 (2023.2.0.20230622)
CMake version: version 3.22.1
Libc version: glibc-2.35

Python version: 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0] (64-bit runtime)
Python platform: Linux-6.4.12-arch1-1-x86_64-with-glibc2.35
Is XPU available: True
DPCPP runtime version: N/A
MKL version: N/A
GPU models and configuration: 
[0] _DeviceProperties(name='Intel(R) Iris(R) Xe Graphics', platform_name='Intel(R) Level-Zero', dev_type='gpu, support_fp64=0, total_memory=12544MB, max_compute_units=96, gpu_eu_count=96)
Intel OpenCL ICD version: 23.22.26516.18
Level Zero version: 1.3.26516.18

CPU:
Architecture:                       x86_64
CPU op-mode(s):                     32-bit, 64-bit
Address sizes:                      39 bits physical, 48 bits virtual
Byte Order:                         Little Endian
CPU(s):                             8
On-line CPU(s) list:                0-7
Vendor ID:                          GenuineIntel
Model name:                         11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
CPU family:                         6
Model:                              140
Thread(s) per core:                 2
Core(s) per socket:                 4
Socket(s):                          1
Stepping:                           1
CPU max MHz:                        4700.0000
CPU min MHz:                        400.0000
BogoMIPS:                           5608.00
Flags:                              fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l2 invpcid_single cdp_l2 ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves split_lock_detect dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req vnmi avx512vbmi umip pku ospke avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg avx512_vpopcntdq rdpid movdiri movdir64b fsrm avx512_vp2intersect md_clear ibt flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          192 KiB (4 instances)
L1i cache:                          128 KiB (4 instances)
L2 cache:                           5 MiB (4 instances)
L3 cache:                           12 MiB (1 instance)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-7
Vulnerability Gather data sampling: Mitigation; Microcode
Vulnerability Itlb multihit:        Not affected
Vulnerability L1tf:                 Not affected
Vulnerability Mds:                  Not affected
Vulnerability Meltdown:             Not affected
Vulnerability Mmio stale data:      Not affected
Vulnerability Retbleed:             Not affected
Vulnerability Spec rstack overflow: Not affected
Vulnerability Spec store bypass:    Mitigation; Speculative Store Bypass disabled via prctl
Vulnerability Spectre v1:           Mitigation; usercopy/swapgs barriers and __user pointer sanitization
Vulnerability Spectre v2:           Mitigation; Enhanced / Automatic IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] intel-extension-for-pytorch==2.0.110+git509a378
[pip3] numpy==1.24.4
[pip3] sklearn-pytorch-engine==0.1.0.dev0
[pip3] torch==2.0.1a0+gite9ebda2
[pip3] torchaudio==2.0.2+31de77d
[pip3] torchvision==0.15.2a0+fa99a53
[conda] intel-extension-for-pytorch 2.0.110+git509a378          pypi_0    pypi
[conda] mkl                       2023.2.0            intel_49495    intel
[conda] mkl-dpcpp                 2023.2.0            intel_49495    intel
[conda] numpy                     1.24.4          py310ha4c1d20_0    conda-forge
[conda] sklearn-pytorch-engine    0.1.0.dev0               pypi_0    pypi
[conda] torch                     2.0.1a0+gite9ebda2          pypi_0    pypi
[conda] torchaudio                2.0.2+31de77d            pypi_0    pypi
[conda] torchvision               0.15.2a0+fa99a53          pypi_0    pypi
@fcharras
Copy link
Author

While looking for workarounds, I somehow surfaced a pytorch error hinting that the package expecttest is missing, and after running

$ pip install expecttest

it seems to be fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NotAnIssue XPU/GPU XPU/GPU specific issues
Projects
None yet
Development

No branches or pull requests

2 participants