intel / intel-extension-for-pytorch

A Python package for extending the official PyTorch that can easily obtain performance on Intel platform
Apache License 2.0
1.57k stars 241 forks source link

`import intel_extension_for_pytorch` breaks `cv2.imshow()` #444

Closed Wovchena closed 11 months ago

Wovchena commented 11 months ago

Describe the bug

The reproducer hangs:

import torch
import cv2
import intel_extension_for_pytorch
import numpy as np

def main():
    cv2.imshow('asdf', np.empty([100, 100], np.uint8))
    cv2.waitKey(0)

if __name__ == '__main__':
    main()

Versions

Collecting environment information... PyTorch version: 2.0.1a0+gite9ebda2 PyTorch CXX11 ABI: Yes IPEX version: N/A IPEX commit: N/A Build type: N/A

OS: Ubuntu 20.04.5 LTS (x86_64) GCC version: (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0 Clang version: N/A IGC version: 2023.2.0 (2023.2.0.20230622) CMake version: version 3.27.0 Libc version: glibc-2.31

Python version: 3.8.10 (default, May 26 2023, 14:05:08) [GCC 9.4.0] (64-bit runtime) Python platform: Linux-5.15.0-78-generic-x86_64-with-glibc2.29 Is XPU available: N/A DPCPP runtime version: 2023.2.0 MKL version: 2023.2.0 GPU models and configuration: N/A Intel OpenCL ICD version: 22.35.24055+i815~u20.04 Level Zero version: 1.3.24055+i815~u20.04

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Byte Order: Little Endian Address sizes: 46 bits physical, 48 bits virtual CPU(s): 24 On-line CPU(s) list: 0-23 Thread(s) per core: 1 Core(s) per socket: 16 Socket(s): 1 NUMA node(s): 1 Vendor ID: GenuineIntel CPU family: 6 Model: 151 Model name: 12th Gen Intel(R) Core(TM) i9-12900K Stepping: 2 CPU MHz: 3200.000 CPU max MHz: 5200.0000 CPU min MHz: 800.0000 BogoMIPS: 6374.40 Virtualization: VT-x L1d cache: 384 KiB L1i cache: 256 KiB L2 cache: 10 MiB NUMA node0 CPU(s): 0-23 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 store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected 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 smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb intel_pt sha_ni xsaveopt xsavec xgetbv1 xsaves split_lock_detect avx_vnni dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp hwp_pkg_req umip pku ospke waitpkg gfni vaes vpclmulqdq tme rdpid movdiri movdir64b fsrm md_clear serialize pconfig arch_lbr flush_l1d arch_capabilities

Versions of relevant libraries: [pip3] intel-extension-for-pytorch==2.0.110+gitbda79ca [pip3] mypy-extensions==1.0.0 [pip3] numpy==1.24.4 [pip3] pytorch-lightning==1.9.2 [pip3] pytorchcv==0.0.67 [pip3] torch==2.0.1a0+gite9ebda2 [pip3] torchaudio==2.0.2+31de77d [pip3] torchmetrics==0.10.3 [pip3] torchtext==0.14.1 [pip3] torchvision==0.15.2a0+fa99a53 [conda] N/A

kta-intel commented 11 months ago

This issue does not seem to be reproducible on my system.

Just to confirm, cv2.imshow('asdf', np.empty([100, 100], np.uint8)) does not create an image at all? And this issue doesn't happen when import intel_extension_for_pytorch is commented out?

Wovchena commented 11 months ago

That's right

kta-intel commented 11 months ago

I see. Are you able to reproduce the issue on a different system? I was not able to on my end on two different systems

Also, intel_extension_for_pytorch==2.1.0+cpu was recently released. Can you try upgrading and see if the issue persists?

Wovchena commented 11 months ago

I don't have other Ubuntu.

I installed py -m pip install intel_extension_for_pytorch==2.1.0 (there's no intel_extension_for_pytorch==2.1.0+cpu) and the issue is still reproducible. Here are the logs:

py repr.py 
/home/wov/.local/lib/python3.8/site-packages/torchvision/io/image.py:13: UserWarning: Failed to load image Python extension: '/home/wov/.local/lib/python3.8/site-packages/torchvision/image.so: undefined symbol: _ZN5torch3jit17parseSchemaOrNameERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE'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(
2023-10-20 11:13:43.620006: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2023-10-20 11:13:43.621166: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-10-20 11:13:43.642736: I tensorflow/tsl/cuda/cudart_stub.cc:28] Could not find cuda drivers on your machine, GPU will not be used.
2023-10-20 11:13:43.643019: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-10-20 11:13:44.004218: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT

Replacing import intel_extension_for_pytorch with import torchvision gives the similar behavior. So the problem is broken torchvision which is imported by intel_extension_for_pytorch.