No such operator image::read_file

hello, When I ran main.py in PubMedCLIP with vision encoder ViT-B/32, something wrong:
PubMedCLIP/PubMedCLIP at main · sarahESL/PubMedCLIP (github.com)

-------Loading CLIP with vision encoder ViT-B/32 -------
-------Training started-------
Traceback (most recent call last):
  File "C:/Users/fhdu/PycharmProjects/PubMedCLIP/main/main.py", line 51, in <module>
    train(cfg, train_loader, val_loader, device)
  File "C:\Users\fhdu\PycharmProjects\PubMedCLIP\main\train.py", line 65, in train
    for i, (image, caption) in enumerate(train_loader):
  File "E:\SoftwareFile\Anaconda3\envs\med_vqa\lib\site-packages\torch\utils\data\dataloader.py", line 521, in __next__
    data = self._next_data()
  File "E:\SoftwareFile\Anaconda3\envs\med_vqa\lib\site-packages\torch\utils\data\dataloader.py", line 561, in _next_data
    data = self._dataset_fetcher.fetch(index)  # may raise StopIteration
  File "E:\SoftwareFile\Anaconda3\envs\med_vqa\lib\site-packages\torch\utils\data\_utils\fetch.py", line 49, in fetch
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "E:\SoftwareFile\Anaconda3\envs\med_vqa\lib\site-packages\torch\utils\data\_utils\fetch.py", line 49, in <listcomp>
    data = [self.dataset[idx] for idx in possibly_batched_index]
  File "C:\Users\fhdu\PycharmProjects\PubMedCLIP\lib\dataset\ROCOdataset.py", line 80, in __getitem__
    **image = self._load_image(index)**
  File "C:\Users\fhdu\PycharmProjects\PubMedCLIP\lib\dataset\ROCOdataset.py", line 70, in _load_image
    **image = read_image(path, mode=ImageReadMode.RGB)**
  File "E:\SoftwareFile\Anaconda3\envs\med_vqa\lib\site-packages\torchvision\io\image.py", line 222, in read_image
    data = read_file(path)
  File "E:\SoftwareFile\Anaconda3\envs\med_vqa\lib\site-packages\torchvision\io\image.py", line 42, in read_file
    data = torch.ops.image.read_file(path)
  File "E:\SoftwareFile\Anaconda3\envs\med_vqa\lib\site-packages\torch\_ops.py", line 63, in __getattr__
    op = torch._C._jit_get_operation(qualified_op_name)
RuntimeError: No such operator image::read_file

Not sure the wrong version of torch leads to this issue? my version:
torch 1.10.0 , torchvision 0.11.1

Looking forward to your answer, thanks in advance.

TorchVision depends on C+±implemented modules to provide JITed operations. Apparently, this has not been/canbot be loaded.
Do you get a warning about that?

Best regards

Thomas

thanks for your reply, I did not get such a warning you mentioned. To be honestly, I hadn’t even heard of JITed.

bro,你解决了吗,是因为版本的问题吗,为什么又删了 :joy:

Yesterday I met this error when running Tensor transforms and JIT — Torchvision main documentation, that time is midnight, so I decide to retry it tomorrow. Because I doubt I mixed two versions of pytorch, today I uninstall pytorch(by pip uninstall pytorch and conda uninstall pytorch) and reintall it(by pip install torch==1.10.1+cu102 torchvision==0.11.2+cu102 torchaudio==0.10.1 -f https://download.pytorch.org/whl/torch_stable.html), this error disappear… Now my env infos are:

C:\WINDOWS\system32>python -m torch.utils.collect_env
Collecting environment information...
PyTorch version: 1.10.1+cu102
Is debug build: False
CUDA used to build PyTorch: 10.2
ROCM used to build PyTorch: N/A

OS: Microsoft Windows 10 专业工作站版
GCC version: (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 7.3.0
Clang version: Could not collect
CMake version: version 3.22.2
Libc version: N/A

Python version: 3.8.5 (default, Sep  3 2020, 21:29:08) [MSC v.1916 64 bit (AMD64)] (64-bit runtime)
Python platform: Windows-10-10.0.19041-SP0
Is CUDA available: True
CUDA runtime version: 10.2.89
GPU models and configuration: GPU 0: NVIDIA GeForce GTX 1660 SUPER
Nvidia driver version: 511.23
cuDNN version: C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\cudnn_ops_train64_8.dll
HIP runtime version: N/A
MIOpen runtime version: N/A

Versions of relevant libraries:
[pip3] Minetorch==0.6.17
[pip3] numpy==1.19.5
[pip3] pytorch-lightning==1.5.5
[pip3] torch==1.10.1+cu102
[pip3] torch-model-archiver==0.4.2b20211023
[pip3] torch-workflow-archiver==0.1.2b20211023
[pip3] torchaudio==0.10.1+cu113
[pip3] torchcam==0.2.0
[pip3] torchfile==0.1.0
[pip3] torchinfo==1.5.4
[pip3] torchmetrics==0.6.1
[pip3] torchserve==0.4.2
[pip3] torchsummary==1.5.1
[pip3] torchtext==0.10.0
[pip3] torchvision==0.11.2+cu102
[pip3] torchviz==0.0.2
[pip3] vit-pytorch==0.23.2
[conda] blas                      1.0                         mkl
[conda] cudatoolkit               10.2.89              h74a9793_1
[conda] minetorch                 0.6.17                   pypi_0    pypi
[conda] mkl                       2021.4.0           haa95532_640
[conda] mkl-service               2.4.0            py38h2bbff1b_0
[conda] mkl_fft                   1.3.1            py38h277e83a_0
[conda] mkl_random                1.2.2            py38hf11a4ad_0
[conda] numpy                     1.21.3                   pypi_0    pypi
[conda] numpy-base                1.21.5           py38hc2deb75_0
[conda] pytorch-lightning         1.5.5                    pypi_0    pypi
[conda] tensorflow                2.3.0           mkl_py38h8557ec7_0
[conda] torch                     1.10.1+cu102             pypi_0    pypi
[conda] torch-model-archiver      0.4.2b20211023           pypi_0    pypi
[conda] torch-workflow-archiver   0.1.2b20211023           pypi_0    pypi
[conda] torchaudio                0.10.1+cu113             pypi_0    pypi
[conda] torchcam                  0.2.0                    pypi_0    pypi
[conda] torchfile                 0.1.0                    pypi_0    pypi
[conda] torchinfo                 1.5.4                    pypi_0    pypi
[conda] torchmetrics              0.6.1                    pypi_0    pypi
[conda] torchsummary              1.5.1                    pypi_0    pypi
[conda] torchvision               0.11.2+cu102             pypi_0    pypi
[conda] torchviz                  0.0.2                    pypi_0    pypi
[conda] vit-pytorch               0.23.2                   pypi_0    pypi

the torchvision upgrade from torchvision==0.10.0+cu102 to torchvision==0.11.2+cu102, I am not sure it is the issue of low version of torchvision or the issue of mixing two versions of pytorch

thx, I will try soon

I just had this problem too, after some inverstigation, I found install jpeg can solve my problem.

For ubuntu: apt-get install libjepg-dev

I am relatively new to google colab. How do you uninstall PyTorch from colab. I am facing a similar error (starting today, it was fine until yesterday!) while running my NN implementation on colab. To be exact here is the error message:

RuntimeError                              Traceback (most recent call last)
/usr/local/lib/python3.7/dist-packages/torch/_ops.py in __getattr__(self, op_name)
    197         try:
--> 198             op, overload_names = torch._C._jit_get_operation(qualified_op_name)
    199         except RuntimeError as e:

RuntimeError: No such operator image::read_file

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

AttributeError                            Traceback (most recent call last)

It seems the origin is an object called ‘_OpNamespace’ which apparently does not have the read_file attribute.