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.55k stars 236 forks source link

Torchvision: reading an image does not work. #656

Closed RafinRono closed 2 months ago

RafinRono commented 3 months ago

Describe the issue

While importing torchvision or intel_extension_for_pytorch, the following warning is thrown:

E:\Intel\oneAPI\intelpython3\envs\idp\lib\site-packages\torchvision\io\image.py:13: UserWarning: Failed to load image Python extension: 'Could not find module 'E:\Intel\oneAPI\intelpython3\envs\idp\Lib\site-packages\torchvision\image.pyd' (or one of its dependencies). Try using the full path with constructor syntax.'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?

My code to produce the above error:

import torchvision

image = torchvision.io.read_image('images/clock.jpeg')

Using the function torchvision.io.read_image throws the following exception:

warn(
Traceback (most recent call last):
  File "E:\Intel\oneAPI\intelpython3\envs\idp\lib\site-packages\torch\_ops.py", line 757, in __getattr__
    op, overload_names = torch._C._jit_get_operation(qualified_op_name)
RuntimeError: No such operator image::read_file

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "J:\Coding\Codes\python\cvpr\test.py", line 10, in <module>
    image = torchvision.io.read_image('images/clock.jpeg')
  File "E:\Intel\oneAPI\intelpython3\envs\idp\lib\site-packages\torchvision\io\image.py", line 258, in read_image
    data = read_file(path)
  File "E:\Intel\oneAPI\intelpython3\envs\idp\lib\site-packages\torchvision\io\image.py", line 52, in read_file
    data = torch.ops.image.read_file(path)
  File "E:\Intel\oneAPI\intelpython3\envs\idp\lib\site-packages\torch\_ops.py", line 761, in __getattr__
    raise AttributeError(
AttributeError: '_OpNamespace' 'image' object has no attribute 'read_file'

And the python environment information:

E:\Intel\oneAPI\intelpython3\envs\idp\python.exe J:\Coding\Codes\python\cvpr\collect_env.py 
E:\Intel\oneAPI\intelpython3\envs\idp\lib\site-packages\torchvision\io\image.py:13: UserWarning: Failed to load image Python extension: 'Could not find module 'E:\Intel\oneAPI\intelpython3\envs\idp\Lib\site-packages\torchvision\image.pyd' (or one of its dependencies). Try using the full path with constructor syntax.'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(
intel_extension_for_pytorch version:          2.1.30.post0 
intel_extension_for_pytorch git sha:          97b37e23d
submodule oneDNN sha:      d5ddbc851aa75e36ed9f651e01185443bfa903ff
submodule ideep sha:      ad79d0e1fa6b80db3c79a788896b9630d4e93940
None
Collecting environment information...
PyTorch version: 2.1.0.post2+cxx11.abi
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 10 Pro
GCC version: (Rev7, Built by MSYS2 project) 13.1.0
Clang version: Could not collect
CMake version: Could not collect
Libc version: N/A

Python version: 3.10.13 | packaged by conda-forge | (tags/v3.10.13-25-g07fbd8e9251-dirty:07fbd8e9251, Dec 28 2023, 15:38:17) [MSC v.1929 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.19045-SP0
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Revision=8450

Versions of relevant libraries:
[pip3] intel_extension_for_pytorch==2.1.30.post0
[pip3] numpy==1.26.4
[pip3] torch==2.1.0.post2+cxx11.abi
[pip3] torchaudio==2.1.0.post2+cxx11.abi
[pip3] torchvision==0.16.0.post2+cxx11.abi
[conda] intel-extension-for-pytorch 2.1.30.post0             pypi_0    pypi
[conda] mkl                       2024.1.0              intel_692    intel
[conda] mkl-service               2.4.0           py310hdbef2b3_44    intel
[conda] mkl_fft                   1.3.8           py310h547562d_70    intel
[conda] mkl_random                1.2.4           py310hac2aed5_90    intel
[conda] mkl_umath                 0.1.1           py310haccc53e_100    intel
[conda] numpy                     1.26.4          py310heace663_1    intel
[conda] numpy-base                1.26.4          py310h818a380_1    intel
[conda] torch                     2.1.0.post2+cxx11.abi          pypi_0    pypi
[conda] torchaudio                2.1.0.post2+cxx11.abi          pypi_0    pypi
[conda] torchvision               0.16.0.post2+cxx11.abi          pypi_0    pypi

Process finished with exit code 0

CPU information didn't appear in collect_env.py. I have a AMD Ryzen 7 5800X 8-core Processor.

Note: I do have oneAPI DPC++ Compiler and MKL installed and verified the details of xpu:

[0]: _DeviceProperties(name='Intel(R) Arc(TM) A750 Graphics', platform_name='Intel(R) Level-Zero', dev_type='gpu', driver_version='1.3.29283', has_fp64=0, total_memory=7934MB, max_compute_units=448, gpu_eu_count=448)
akashdhamasia12 commented 3 months ago

Thanks for reporting the issue, will try to replicate and get back.

akashdhamasia12 commented 2 months ago

Hi, this is not an IPEX issue, but you can solve this issue by installing: conda install libpng libjpeg-turbo -c pytorch

Please let me know if i can close this ticket. Thank you.

RafinRono commented 2 months ago

Hi, this is not an IPEX issue, but you can solve this issue by installing: conda install libpng libjpeg-turbo -c pytorch

Please let me know if i can close this ticket. Thank you.

Okay, I'll try it once I return to my pc. Thanks.