Skip to content

Transformers 4.57.1 not working with torch < 2.3 #41960

@iglaweb

Description

@iglaweb

System Info

In the Readme it is said

Transformers works with Python 3.9+, and PyTorch 2.1+.

I use torch 2.2.2 on Mac Sonoma 14.7 (Intel) and I get the following error:

  inputs = processor.apply_chat_template(
 File "/home/venv310/lib/python3.10/site-packages/transformers/utils/deprecation.py", line 172, in wrapped_func
   return func(*args, **kwargs)
 File "/home/venv310/lib/python3.10/site-packages/transformers/utils/deprecation.py", line 172, in wrapped_func
   return func(*args, **kwargs)
 File "/home/venv310/lib/python3.10/site-packages/transformers/processing_utils.py", line 1705, in apply_chat_template
   out = self(
 File "/home/venv310/lib/python3.10/site-packages/transformers/models/internvl/processing_internvl.py", line 229, in __call__
   video_inputs = self.video_processor(videos=videos, **video_kwargs)
 File "/home/venv310/lib/python3.10/site-packages/transformers/video_processing_utils.py", line 206, in __call__
   return self.preprocess(videos, **kwargs)
 File "/home/venv310/lib/python3.10/site-packages/transformers/video_processing_utils.py", line 387, in preprocess
   preprocessed_videos = self._preprocess(videos=videos, **kwargs)
 File "/home/venv310/lib/python3.10/site-packages/transformers/models/internvl/video_processing_internvl.py", line 126, in _preprocess
   stacked_videos = self.resize(stacked_videos, size=size, interpolation=interpolation)
 File "/home/venv310/lib/python3.10/site-packages/transformers/image_processing_utils_fast.py", line 361, in resize
   if torch.compiler.is_compiling() and is_rocm_platform():
AttributeError: module 'torch.compiler' has no attribute 'is_compiling'

'is_compiling' NOT exist in <= 2.2.2
https://github.com/pytorch/pytorch/blob/v2.2.2/torch/compiler/__init__.py

Who can help?

@zucchini-nlp @gante @stevhliu

Information

  • The official example scripts
  • My own modified scripts

Tasks

  • An officially supported task in the examples folder (such as GLUE/SQuAD, ...)
  • My own task or dataset (give details below)

Reproduction

Steps to reproduce:

  1. Install latest transformers version and torch 2.2.2
  2. Run video/image inference with InternVL3-1B model

Expected behavior

Run w/o errors with Torch 2.2.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions