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
API torch.ops.image.read_file reports RuntimeError - No such operator image::read_file #65473
Comments
for hysterical raisins 0.10 torchvision targets 1.9 torch, so there is not a version mismatch, AFAICT (cc @malfet) |
This is still probably an environment problem of some sort. What happens if you create a fresh conda environment and reinstall everything there |
I can reproduce it in fresh conda env on my MacOS. |
bumping prio |
Another new environment with totally new installed torch series packages. Microsoft Windows [Version 10.0.19042.1237] C:\Users\zhaox>conda activate torchtest (torchtest) C:\Users\zhaox>pip list astroid 2.4.2 (torchtest) C:\Users\zhaox>python
|
@ezyang but I believe it works as expected (sort of): Lines 56 to 69 in facff2e
|
Actually this works for me on stock OS X install:
But torchvision is a little older, smh
|
I've tested the following combinations on Windows: It reproduces the same every time. |
Just updated to the latest version and got the same error. |
I found the problem. There's a part of the code where
When this import fails, no exception is raised. I commented the try-except block to see what happens. In my case, it was failing to load the library, because it depended on
after digging in a bit, I found that this library comes from I installed cuda-toolkit 11 through Conda,
and I could see the libs here:
but it was still failing to find it. I'm not sure what's the right way to handle this, but the quick workaround is to do this
so that the library is found during the import. After that, everything worked just fine. If you're doing this, just make sure the path you're setting is pointing to the correct I'm not sure why this has happened, but I suspect that I've installed PyTorch thorough |
Can confirm that on windows the issue can be reproduced up to the latest nightly build. I however did not test torch==1.9.0 and torchvision==0.10.0 @Starballoon \ @malfet can you try with 1.9.1\0.10.1 and confirm it's working in that version pair? Edit: I just noticed that both me and @ashafaei are on python 3.7.x and have 1.9.x working fine |
Nothing different till the newest version 1.10.0\0.11.1 on Windows. I'm not sure if there is something wrong with the sequence of my PATH variables. Microsoft Windows [Version 10.0.19043.1348]
(c) Microsoft Corporation. All rights reserved.
C:\Users\zhaox>conda activate zxq
(zxq) C:\Users\zhaox>python
Python 3.8.10 (default, May 19 2021, 13:12:57) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.ops.image.read_file('')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Environment\Anaconda3\envs\zxq\lib\site-packages\torch\_ops.py", line 60, in __getattr__
op = torch._C._jit_get_operation(qualified_op_name)
RuntimeError: No such operator image::read_file
>>> import torchvision
>>> torch.ops.image.read_file('')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
RuntimeError: [Errno 2] No such file or directory: '' |
After importing torchvision it seems to be working, check your log output. |
Microsoft Windows [Version 10.0.19043.1387]
(c) Microsoft Corporation. All rights reserved.
C:\Users\zhaox\Desktop>conda activate zxq
(zxq) C:\Users\zhaox\Desktop>python
Python 3.8.10 (default, May 19 2021, 13:12:57) [MSC v.1916 64 bit (AMD64)] :: Anaconda, Inc. on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.ops.image.open_file('IMG_20210916_092059.png')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Environment\Anaconda3\envs\zxq\lib\site-packages\torch\_ops.py", line 60, in __getattr__
op = torch._C._jit_get_operation(qualified_op_name)
RuntimeError: No such operator image::open_file
>>> import torchvision
>>> torch.ops.image.open_file('IMG_20210916_092059.png')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Environment\Anaconda3\envs\zxq\lib\site-packages\torch\_ops.py", line 60, in __getattr__
op = torch._C._jit_get_operation(qualified_op_name)
RuntimeError: No such operator image::open_file
>>> |
Well... I'm out of options. The only thing different from my setup is that I am using Python 3.7 as the system interpreter, and not in a conda environment. |
@Starballoon it seems to me that you are having the same issue as I did. The image open file depends on libnvjpeg from cuda toolkit 11, and when it fails to load, it does so silently and you’ll only know through these operator not found messages. You can at least verify this is the problem by finding the code snippet I shared above in your TorchVision code and raise the exception instead of passing it. I’m not sure what to do on Windows, but it might work if you manually download and install the lastest cuda toolkit 11 from Nvidia. (Don’t forget to reboot, and also add the libraries to your path if the installer asks you) |
I have a working stack on windows (Windows 10, conda, python 3.9) using:
torch.ops.image.read_file() works for me, and I was able to successfully train on an image dataset with torchvision, so I'm thinking that the issue is fixed in torchvision 0.11+. @ashafaei @Starballoon Are you able to use torchvision 0.11.2, and is this issue resolved for you also? |
To Reproduce
I'm new to PyTorch and I can't find helpful infomation from google or pytorch forum about this question.
Originally I found this error trying to use API torchvision.io.read_image which calls torch.ops.image.read_file
But there is a weird phenomenon that I can not understand.
When I import torch and torchvision both, the API torch.ops.image.read_file works well but fails while torch only.
Content from CMD on Windows:
Content from bash on CentOS:
Expected behavior
It should work well that the file can be open.
Environment
Both devices have torch==1.9.0 and torchvision==0.10.0.
PyTorch version: 1.9.0+cpu
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A
OS: Microsoft Windows 10 Pro
GCC version: (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 8.1.0
Clang version: 11.0.1
CMake version: version 3.20.0-rc3
Libc version: N/A
Python version: 3.8 (64-bit runtime)
Python platform: Windows-10-10.0.19042-SP0
Is CUDA available: False
CUDA runtime version: No CUDA
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
Versions of relevant libraries:
[pip3] numpy==1.20.3
[pip3] numpydoc==1.1.0
[pip3] torch==1.9.0
[pip3] torchaudio==0.9.0
[pip3] torchvision==0.10.0
[conda] blas 1.0 mkl
[conda] mkl 2021.2.0 pypi_0 pypi
[conda] mkl-random 1.2.2 pypi_0 pypi
[conda] mkl-service 2.4.0 pypi_0 pypi
[conda] mkl_fft 1.3.0 py38h277e83a_2
[conda] numpy 1.20.3 pypi_0 pypi
[conda] numpydoc 1.1.0 pyhd3eb1b0_1
[conda] torch 1.9.0 pypi_0 pypi
[conda] torchaudio 0.9.0 pypi_0 pypi
[conda] torchvision 0.10.0 pypi_0 pypi
Additional Info
I also referred to this issue https://githubmemory.com/repo/pytorch/vision/issues/4181.
And the following is the linking check result of image.so of torchvision on a CentOS server with RTX 3090.
Another blog pointed out that questions about operators may be caused by version mismatch between torch and torchvision. So is torch==1.9.0 and torchvision==0.10.0 a mismatch combination?
cc @ezyang @gchanan @zou3519 @bdhirsh @jbschlosser @bhosmer @smessmer @ljk53 @fmassa @vfdev-5 @pmeier
The text was updated successfully, but these errors were encountered: