[GH-ISSUE #111] ImportError: cannot import name 'is_torch_greater_or_equal_than_1_13' from 'transformers.pytorch_utils' #94

Closed
opened 2026-10-26 21:13:50 +00:00 by bsakaguchi · 3 comments
Owner

Originally created by @Jiadalee on GitHub (Jan 28, 2025).
Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-R1/issues/111

I'm using python 3.12, pytorch2.5.1, and tried the transformers 4.37.2, 4.44.2, and 4.48 versions, but still got this error (as titled)

ImportError: cannot import name 'is_torch_greater_or_equal_than_1_13' from 'transformers.pytorch_utils

The error points to the code block shown below:


ImportError Traceback (most recent call last)
Cell In[89], line 148
146 # Generate embeddings
147 print("\nStep 2: Generating embeddings...")
--> 148 embeddings = generate_embeddings(df, model_name="deepseek-ai/deepseek-r1")
150 # Store embeddings in FAISS
151 print("\nStep 3: Storing data in FAISS...")

Cell In[89], line 50, in generate_embeddings(data, model_name)
48 tokenizer = AutoTokenizer.from_pretrained(model_name)
49 #model = AutoModel.from_pretrained(model_name)
---> 50 model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1", trust_remote_code=True)
52 # Combine all fields for each row
53 combined_texts = data.apply(combine_fields, axis=1).tolist()

File ~/miniconda3/envs/myenv/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py:553, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
551 if has_remote_code and trust_remote_code:
552 class_ref = config.auto_map[cls.name]
--> 553 model_class = get_class_from_dynamic_module(
554 class_ref, pretrained_model_name_or_path, code_revision=code_revision, **hub_kwargs, **kwargs
555 )
556 _ = hub_kwargs.pop("code_revision", None)
557 cls.register(config.class, model_class, exist_ok=True)

I'm suspecting the deepseek-r1 API in Huggingface has a compatibility issue with the python or transformer versions. Pls help check it out. thanks

Originally created by @Jiadalee on GitHub (Jan 28, 2025). Original GitHub issue: https://github.com/deepseek-ai/DeepSeek-R1/issues/111 I'm using python 3.12, pytorch2.5.1, and tried the transformers 4.37.2, 4.44.2, and 4.48 versions, but still got this error (as titled) > ImportError: cannot import name 'is_torch_greater_or_equal_than_1_13' from 'transformers.pytorch_utils The error points to the code block shown below: > --------------------------------------------------------------------------- > ImportError Traceback (most recent call last) > Cell In[89], line 148 > 146 # Generate embeddings > 147 print("\nStep 2: Generating embeddings...") > --> 148 embeddings = generate_embeddings(df, model_name="deepseek-ai/deepseek-r1") > 150 # Store embeddings in FAISS > 151 print("\nStep 3: Storing data in FAISS...") > > Cell In[89], line 50, in generate_embeddings(data, model_name) > 48 tokenizer = AutoTokenizer.from_pretrained(model_name) > 49 #model = AutoModel.from_pretrained(model_name) > ---> 50 model = AutoModelForCausalLM.from_pretrained("deepseek-ai/DeepSeek-R1", trust_remote_code=True) > 52 # Combine all fields for each row > 53 combined_texts = data.apply(combine_fields, axis=1).tolist() > > File ~/miniconda3/envs/myenv/lib/python3.12/site-packages/transformers/models/auto/auto_factory.py:553, in _BaseAutoModelClass.from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs) > 551 if has_remote_code and trust_remote_code: > 552 class_ref = config.auto_map[cls.__name__] > --> 553 model_class = get_class_from_dynamic_module( > 554 class_ref, pretrained_model_name_or_path, code_revision=code_revision, **hub_kwargs, **kwargs > 555 ) > 556 _ = hub_kwargs.pop("code_revision", None) > 557 cls.register(config.__class__, model_class, exist_ok=True) I'm suspecting the deepseek-r1 API in Huggingface has a compatibility issue with the python or transformer versions. Pls help check it out. thanks
bsakaguchi 2026-10-26 21:13:50 +00:00
Author
Owner

@Jiadalee commented on GitHub (Jan 28, 2025):

I already fixed this issue. Pls refer to my comments at issue #55

<!-- gh-comment-id:2619189763 --> @Jiadalee commented on GitHub (Jan 28, 2025): I already fixed this issue. Pls refer to my comments at issue #55
Author
Owner

@github-actions[bot] commented on GitHub (Mar 1, 2025):

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!

<!-- gh-comment-id:2691748004 --> @github-actions[bot] commented on GitHub (Mar 1, 2025): This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you believe this issue is still relevant, please leave a comment to keep it open. Thank you for your contributions!
Author
Owner

@github-actions[bot] commented on GitHub (Apr 9, 2025):

false

<!-- gh-comment-id:2787911251 --> @github-actions[bot] commented on GitHub (Apr 9, 2025): false
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
deepseek-ai/DeepSeek-R1#94
No description provided.