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.56k stars 237 forks source link

Could not running simple example on XPU #362

Open harborn opened 1 year ago

harborn commented 1 year ago

Describe the issue

Hi, I have following codes:

import dpctl
import torch
import intel_extension_for_pytorch

xpu_num = len(dpctl.get_devices(backend="level_zero", device_type="gpu"))
print(f"xpu_num = {xpu_num}")

# device = torch.device("xpu:0")
device = torch.device("cpu:0")
print(f"device = {device}")
l = torch.nn.Linear(5, 5).to(device, torch.float)
print(f"type(l) = {type(l)}")
print(f"l = {l}")
i = torch.randn(5, 5, dtype=torch.float, device=device)
print(f"type(i) = {type(i)}")
print(f"i = {i}")
expected_out = l(i)
print(f"expected_out = {expected_out}")

When I enable device = torch.device("cpu:0") Runing this script, and result is:

xpu_num = 6
device = cpu:0
type(l) = <class 'torch.nn.modules.linear.Linear'>
l = Linear(in_features=5, out_features=5, bias=True)
type(i) = <class 'torch.Tensor'>
i = tensor([[ 0.1940,  0.6313,  0.7539,  0.8270,  0.4829],
        [-0.6601, -0.1555, -0.5951,  0.0552, -0.8904],
        [-0.2962,  0.2588,  0.9915,  0.1151,  1.3780],
        [ 0.7729,  1.1673,  0.0569, -0.5209, -1.3297],
        [-1.8744,  0.5630,  0.2379,  1.7550, -0.5790]])
expected_out = tensor([[ 0.1335, -0.6444, -0.4030, -0.0073,  0.2138],
        [ 0.0510,  0.1734, -0.4978, -0.9275, -0.4016],
        [ 0.1532, -1.0520,  0.1228,  0.3162,  0.1983],
        [ 0.7138,  0.0412, -1.0125, -0.7827, -0.6498],
        [-0.8450, -0.9822, -1.1371, -0.7442,  0.7524]],
       grad_fn=<AddmmBackward0>)

The results show this scripts codes running OK.

While when I enable device = torch.device("xpu:0"), result is:

xpu_num = 6
device = xpu:0
type(l) = <class 'torch.nn.modules.linear.Linear'>
l = Linear(in_features=5, out_features=5, bias=True)
type(i) = <class 'torch.Tensor'>
i = tensor([[ 0.0438,  0.4119,  0.4430, -0.9481, -0.0850],
        [-3.3893,  0.0693,  1.9792, -1.4143,  1.8235],
        [-0.2711,  0.6538, -1.3239,  1.4839, -0.5393],
        [ 1.4996, -0.5569, -0.0470,  1.7764,  0.5166],
        [ 1.7779,  0.4889,  0.6964,  2.2312,  0.2050]], device='xpu:0')
Traceback (most recent call last):
  File "/mnt/scratch/wugangsh/test_codes/python/test_ray.py", line 19, in <module>
    expected_out = l(i)
  File "/mnt/scratch/wugangsh/miniconda3/envs/ray_xpu/lib/python3.9/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl
    return forward_call(*input, **kwargs)
  File "/mnt/scratch/wugangsh/miniconda3/envs/ray_xpu/lib/python3.9/site-packages/torch/nn/modules/linear.py", line 114, in forward
    return F.linear(input, self.weight, self.bias)
RuntimeError: could not create an engine

My OS is:

> lsb_release -a
LSB Version:    n/a
Distributor ID: SUSE
Description:    SUSE Linux Enterprise Server 15 SP3
Release:        15.3
Codename:       n/a
gujinghui commented 1 year ago

@jingxu10 We saw this before due to env issue?

harborn commented 1 year ago

not env issue

jingxu10 commented 1 year ago

@jingxu10 We saw this before due to env issue?

Opened JIRAT.

tnnandi commented 9 months ago

Having the same issue. May I know if there has been any progress in identifying the source of the issue?

nec4 commented 9 months ago

Hello, I am also experiencing this exact issue with Intel Max1100 using the FP32 example from the official documentation (https://intel.github.io/intel-extension-for-pytorch/xpu/latest/tutorials/examples.html#complete-float32-example) using torch version 2.0.1a0+cxx11.abi and intel for pytorch version 2.0.120+xpu. Is there currently any update on a solution?

jingxu10 commented 9 months ago

@tnnandi @nec4 Could you help to dump env info with https://github.com/intel/intel-extension-for-pytorch/raw/main/scripts/collect_env.py?

nec4 commented 9 months ago

Of course: here is the output:

Collecting environment information...
PyTorch version: 2.0.1a0+cxx11.abi
PyTorch CXX11 ABI: Yes
IPEX version: 2.0.120+xpu
IPEX commit: aa0a2a4dc
Build type: Release

OS: Rocky Linux 8.8 (Green Obsidian) (x86_64)
GCC version: (GCC) 8.5.0 20210514 (Red Hat 8.5.0-18)
Clang version: N/A
IGC version: N/A
CMake version: version 3.20.2
Libc version: glibc-2.28

Python version: 3.9.18 (tags/v3.9.18-26-g6b320c3b2f6-dirty:6b320c3b2f6, Sep 28 2023, 00:35:27)  [GCC 13.2.0] (64-bit runtime)
Python platform: Linux-4.18.0-477.27.1.el8_8.x86_64-x86_64-with-glibc2.28
Is XPU available: True
DPCPP runtime version: N/A
MKL version: N/A
GPU models and configuration:
[0] _DeviceProperties(name='Intel(R) Data Center GPU Max 1550', platform_name='Intel(R) Level-Zero', dev_type='gpu, support_fp64=1, total_memory=65536MB, max_compute_units=512, gpu_eu_count=512)
[1] _DeviceProperties(name='Intel(R) Data Center GPU Max 1550', platform_name='Intel(R) Level-Zero', dev_type='gpu, support_fp64=1, total_memory=65536MB, max_compute_units=512, gpu_eu_count=512)
[2] _DeviceProperties(name='Intel(R) Data Center GPU Max 1550', platform_name='Intel(R) Level-Zero', dev_type='gpu, support_fp64=1, total_memory=65536MB, max_compute_units=512, gpu_eu_count=512)
[3] _DeviceProperties(name='Intel(R) Data Center GPU Max 1550', platform_name='Intel(R) Level-Zero', dev_type='gpu, support_fp64=1, total_memory=65536MB, max_compute_units=512, gpu_eu_count=512)
[4] _DeviceProperties(name='Intel(R) Data Center GPU Max 1550', platform_name='Intel(R) Level-Zero', dev_type='gpu, support_fp64=1, total_memory=65536MB, max_compute_units=512, gpu_eu_count=512)
[5] _DeviceProperties(name='Intel(R) Data Center GPU Max 1550', platform_name='Intel(R) Level-Zero', dev_type='gpu, support_fp64=1, total_memory=65536MB, max_compute_units=512, gpu_eu_count=512)
[6] _DeviceProperties(name='Intel(R) Data Center GPU Max 1550', platform_name='Intel(R) Level-Zero', dev_type='gpu, support_fp64=1, total_memory=65536MB, max_compute_units=512, gpu_eu_count=512)
[7] _DeviceProperties(name='Intel(R) Data Center GPU Max 1550', platform_name='Intel(R) Level-Zero', dev_type='gpu, support_fp64=1, total_memory=65536MB, max_compute_units=512, gpu_eu_count=512)
Intel OpenCL ICD version: 23.22.26516.32-682.el8_8
Level Zero version: 1.3.26516.32-682.el8_8

CPU:
Architecture:        x86_64
CPU op-mode(s):      32-bit, 64-bit
Byte Order:          Little Endian
CPU(s):              224
On-line CPU(s) list: 0-223
Thread(s) per core:  2
Core(s) per socket:  56
Socket(s):           2
NUMA node(s):        2
Vendor ID:           GenuineIntel
CPU family:          6
Model:               143
Model name:          Intel(R) Xeon(R) Platinum 8480L
Stepping:            7
CPU MHz:             2000.000
BogoMIPS:            4000.00
L1d cache:           48K
L1i cache:           32K
L2 cache:            2048K
L3 cache:            107520K
NUMA node0 CPU(s):   0-55,112-167
NUMA node1 CPU(s):   56-111,168-223
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 smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid dca sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb cat_l3 cat_l2 cdp_l3 invpcid_single intel_ppin cdp_l2 ssbd mba ibrs ibpb stibp ibrs_enhanced fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid cqm rdt_a avx512f avx512dq rdseed adx smap avx512ifma clflushopt clwb intel_pt avx512cd sha_ni
avx512bw avx512vl xsaveopt xsavec xgetbv1 xsaves cqm_llc cqm_occup_llc cqm_mbm_total cqm_mbm_local split_lock_detect avx_vnni avx512_bf16 wbnoinvd dtherm ida arat pln pts avx512vbmi umip pku ospke waitpkg avx512_vbmi2 gfni vaes vpclmulqdq avx512_vnni avx512_bitalg tme avx512_vpopcntdq la57 rdpid bus_lock_detect cldemote movdiri movdir64b enqcmd fsrm md_clear serialize tsxldtrk pconfig arch_lbr amx_bf16 avx512_fp16 amx_tile amx_int8 flush_l1d arch_capabilities

Versions of relevant libraries:
[pip3] intel-extension-for-pytorch==2.0.120+xpu
[pip3] numpy==1.24.3
[pip3] pytorch-hpc==0.0
[pip3] torch==2.0.1a0+cxx11.abi
[pip3] torchvision==0.15.2a0+cxx11.abi
[conda] intel-extension-for-pytorch 2.0.120              py39_xpu_1    intel
[conda] mkl                       2024.0.0            intel_49656    intel
[conda] mkl-dpcpp                 2024.0.0            intel_49656    intel
[conda] mkl-include               2024.0.0            intel_49656    intel
[conda] mkl-service               2.4.0           py39h3539a15_40    intel
[conda] mkl_fft                   1.3.6           py39h1d81ff8_61    intel
[conda] mkl_random                1.2.2           py39h5a378b4_81    intel
[conda] mkl_umath                 0.1.1           py39h2b1685c_91    intel
[conda] numpy                     1.24.3           py39ha320b8e_5    intel
[conda] numpy-base                1.24.3           py39hbac2b65_5    intel
[conda] onemkl-sycl-blas          2024.0.0            intel_49656    intel
[conda] onemkl-sycl-datafitting   2024.0.0            intel_49656    intel
[conda] onemkl-sycl-dft           2024.0.0            intel_49656    intel
[conda] onemkl-sycl-lapack        2024.0.0            intel_49656    intel
[conda] onemkl-sycl-rng           2024.0.0            intel_49656    intel
[conda] onemkl-sycl-sparse        2024.0.0            intel_49656    intel
[conda] onemkl-sycl-stats         2024.0.0            intel_49656    intel
[conda] onemkl-sycl-vm            2024.0.0            intel_49656    intel
[conda] pytorch                   2.0.1                py39_xpu_2    intel
[conda] pytorch-hpc               0.0                      pypi_0    pypi
[conda] torchvision               0.15.2               py39_xpu_1    intel
nec4 commented 8 months ago

Is there any update on this issue?

jingxu10 commented 8 months ago

We are working on verifying if the issue can be reproduced on the latest 2.1.10+xpu version or not.

jingxu10 commented 8 months ago

We cannot reproduce the issue with the latest 2.1.10+xpu with basekit 2024.0 on driver 736.25. Would you run with the latest version?

nec4 commented 7 months ago

Hello - we have had a chance to update our drivers and I can confirm that the 2.1.10+xpu with basekit 2024.0 works. Thanks! However, it seems that only the pip installation solution works currently works for us - the equivalent conda installation on the same machine results in a similar error (from this page: https://intel.github.io/intel-extension-for-pytorch/index.html#installation?platform=gpu&version=v2.1.10%2Bxpu).

uniartisan commented 3 months ago

I have the same issue, however I'm using the pip version.

result = torch.matmul(x, x_trans) Traceback (most recent call last): File "", line 1, in RuntimeError: could not create an engine

Collecting environment information...
PyTorch version: 2.1.0.post2+cxx11.abi
PyTorch CXX11 ABI: Yes
IPEX version: 2.1.30+xpu
IPEX commit: 474a6b3cb
Build type: Release

OS: Ubuntu 22.04.4 LTS (x86_64)
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: N/A
IGC version: 2024.1.0 (2024.1.0.20240308)
CMake version: N/A
Libc version: glibc-2.35

Python version: 3.10.14 (main, May  6 2024, 19:42:50) [GCC 11.2.0] (64-bit runtime)
Python platform: Linux-6.5.0-35-generic-x86_64-with-glibc2.35
Is XPU available: True
DPCPP runtime version: 2024.1
MKL version: 2024.1
GPU models and configuration: 
[0] _DeviceProperties(name='Intel(R) Arc(TM) A770 Graphics', platform_name='Intel(R) Level-Zero', dev_type='gpu', driver_version='1.3.28202', has_fp64=0, total_memory=15473MB, max_compute_units=512, gpu_eu_count=512)
Intel OpenCL ICD version: N/A
Level Zero version: 1.3.28202.52-821~22.04

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):                             24
On-line CPU(s) list:                0-23
Vendor ID:                          GenuineIntel
Model name:                         13th Gen Intel(R) Core(TM) i7-13700KF
CPU family:                         6
Model:                              183
Thread(s) per core:                 2
Core(s) per socket:                 16
Socket(s):                          1
Stepping:                           1
CPU max MHz:                        5400.0000
CPU min MHz:                        800.0000
BogoMIPS:                           6835.20
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 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 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 hfi vnmi umip pku ospke waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize arch_lbr ibt flush_l1d arch_capabilities
Virtualization:                     VT-x
L1d cache:                          640 KiB (16 instances)
L1i cache:                          768 KiB (16 instances)
L2 cache:                           24 MiB (10 instances)
L3 cache:                           30 MiB (1 instance)
NUMA node(s):                       1
NUMA node0 CPU(s):                  0-23
Vulnerability Gather data sampling: Not affected
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; BHI BHI_DIS_S
Vulnerability Srbds:                Not affected
Vulnerability Tsx async abort:      Not affected

Versions of relevant libraries:
[pip3] intel-extension-for-pytorch==2.1.30+xpu
[pip3] intel-extension-for-pytorch-deepspeed==2.1.30
[pip3] numpy==1.26.4
[pip3] pytorch-lightning==2.2.4
[pip3] torch==2.1.0.post2+cxx11.abi
[pip3] torchaudio==2.1.0.post2+cxx11.abi
[pip3] torchmetrics==1.4.0.post0
[pip3] torchvision==0.16.0.post2+cxx11.abi
[conda] intel-extension-for-pytorch 2.1.30+xpu               pypi_0    pypi
[conda] intel-extension-for-pytorch-deepspeed 2.1.30                   pypi_0    pypi
[conda] numpy                     1.26.4                   pypi_0    pypi
[conda] pytorch-lightning         2.2.4                    pypi_0    pypi
[conda] torch                     2.1.0.post2+cxx11.abi          pypi_0    pypi
[conda] torchaudio                2.1.0.post2+cxx11.abi          pypi_0    pypi
[conda] torchmetrics              1.4.0.post0              pypi_0    pypi
[conda] torchvision               0.16.0.post2+cxx11.abi          pypi_0    pypi

I have upgrade my system thesedays:

Upgrade: containerd.io:amd64 (1.6.31-1, 1.6.32-1), intel-oneapi-compiler-shared-2024.1:amd64 (2024.1.0-963, 2024.1.2-995), intel-oneapi-icc-eclipse-plugin-cpp-2024.1:amd64 (2024.1.0-963, 2024.1.2-995), intel-oneapi-openmp-common-2024.1:amd64 (2024.1.0-963, 2024.1.2-995), intel-oneapi-compiler-dpcpp-cpp-runtime-2024.1:amd64 (2024.1.0-963, 2024.1.2-995), intel-oneapi-openmp-2024.1:amd64 (2024.1.0-963, 2024.1.2-995), intel-oneapi-compiler-shared-runtime-2024.1:amd64 (2024.1.0-963, 2024.1.2-995), intel-oneapi-compiler-dpcpp-eclipse-cfg-2024.1:amd64 (2024.1.0-963, 2024.1.2-995), intel-oneapi-compiler-shared-common-2024.1:amd64 (2024.1.0-963, 2024.1.2-995), intel-oneapi-compiler-dpcpp-cpp-common-2024.1:amd64 (2024.1.0-963, 2024.1.2-995), intel-oneapi-dpcpp-cpp-2024.1:amd64 (2024.1.0-963, 2024.1.2-995), intel-oneapi-compiler-cpp-eclipse-cfg-2024.1:amd64 (2024.1.0-963, 2024.1.2-995)

I just reboot my system and upgrade it, so sad..

I tried to downgrade these pacakages, It fixed

jingxu10 commented 3 months ago

currently ipex has to work on a specific version of driver.

uniartisan commented 3 months ago

Yes, but the installation drivers and the associated one API in the documentation will be installed to this version on the premise of a fresh install (their dependencies are allowed)

李致远

---Original--- From: "Jing @.> Date: Fri, May 24, 2024 06:32 AM To: @.>; Cc: "Zhiyuan @.**@.>; Subject: Re: [intel/intel-extension-for-pytorch] Could not running simple example on XPU (Issue #362)

currently ipex has to work on a specific version of driver.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

jingxu10 commented 3 months ago

Seems like the issue got fixed. Can we close this ticket?

MordragT commented 3 months ago

Do you have OCL_ICD_FILENAMES set (or sourced the respective vars of one api) ? Because I had a similar problem by forgetting that inside my systemd unit environments.

jingxu10 commented 3 weeks ago

We will add basekit dependency packages as the install_requires packages of ipex so that manually installation and env sourcing of them are not required in 2.3.110. This version will be released next week.