[Bug] AutoModelForCausalLM.from_pretrained() causes fatal silent crash on Windows with CUDA 12.9 / RTX 3060 Ti
Author: remby83-boop
Pull request: no
Labels: name: bug

### System Info

OS: Windows 11

GPU: NVIDIA GeForce RTX 3060 Ti

NVIDIA Driver Version: 5xx.xx (CUDA 12.9)

Python Version: 3.10.x

PyTorch Version: Tested on 2.7.1+cu118, 2.8.0+cu121

Transformers Version: Tested on 4.36.2, 4.30.2

CUDA Toolkit: 12.9

### Who can help?

_No response_

### Information

- [ ] The official example scripts
- [x] My own modified scripts

### Tasks

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

### Reproduction

1. Create a clean Conda environment: conda create -n test-env python=3.10 -y

2. Activate it: conda activate test-env

3. Install PyTorch and Transformers:

pip install torch==2.8.0+cu121 torchvision==0.16.0+cu121 torchaudio==0.16.0+cu121 --index-url https://download.pytorch.org/whl/cu121
pip install transformers==4.36.2

4. Run the following test script:


# test_crash.py

```py
from transformers import AutoModelForCausalLM, AutoTokenizer
print("Step 1: Loading tokenizer...")
tokenizer = AutoTokenizer.from_pretrained("gpt2") # or "microsoft/DialoGPT-small"
print("✓ Tokenizer loaded.")
print("Step 2: Loading model...")
model = AutoModelForCausalLM.from_pretrained("gpt2", device_map="auto") # Crash occurs here
print("✓ Model loaded.") # This line is never reached
```
5. Observe the output: The script prints "✓ Tokenizer loaded." and then the process terminates silently back to the command prompt with no error.

Additional Diagnostics & Notes:

Not Model-Specific: The crash occurs with gpt2, microsoft/DialoGPT-small, and microsoft/Phi-3-mini-4k-instruct.

Not Device-Specific: The crash occurs with both device_map="auto" and device_map=None (CPU).

Sequence Classification Models Work: AutoModelForSequenceClassification.from_pretrained("distilbert-base-uncased-finetuned-sst-2-english") loads successfully, indicating the issue is isolated to the AutoModelForCausalLM class.

Environment Isolation: The issue was reproduced in a Docker container based on huggingface/transformers-pytorch-gpu:latest and in multiple clean Conda environments, ruling out local configuration issues.

Error Logs: There are no Python-level errors. The crash is silent and fatal, suggesting a segmentation fault or similar low-level issue in a native dependency (likely within the tokenizers or model architecture C++ code)

### Expected behavior

The model should load successfully onto the available device (CPU or GPU) without causing a fatal process crash.

Potential Root Cause:
The issue is likely a memory access violation or segmentation fault occurring in the native code responsible for initializing the model's architecture or loading its weights, specifically triggered by the Windows OS + NVIDIA RTX 3060 Ti + CUDA 12.9 combination.

Comments:
Hmmn, this is extremely unusual. Can you try just making some cuda tensors in `torch` and multiplying them? If that works, it's very surprising that loading a small model would fail. My guess is that a misconfigured CUDA or PyTorch is the cause here, not Transformers.

This issue has been automatically marked as stale because it has not had recent activity. If you think this still needs to be addressed please comment on this thread.

Please note that issues that do not follow the [contributing guidelines](https://github.com/huggingface/transformers/blob/main/CONTRIBUTING.md) are likely to be ignored.