microsoft / microsoft/LLMLingua

[BUG] LLMLingua fails on Windows with PyTorch CPU: "Torch not compiled with CUDA enabled"

Open
#216 2 comments 0 reactions 1 assignee View on GitHub

@iofu728 is already working on this.

Since Jul 3, 2025.

question
Dominant language
Python
Stars
6.7k
Forks
428
Avg merge
2d 4h
Merged PRs (30d)
1

Description

Description:
I'm trying to use LLMLingua on Windows 10 with PyTorch CPU (no GPU/CUDA available).
When initializing the model microsoft/llmlingua-2-xlm-roberta-large-meetingbank (or any other), I get the following error:

AssertionError: Torch not compiled with CUDA enabled

Steps to reproduce:

  1. Install PyTorch CPU (pip install torch --index-url https://download.pytorch.org/whl/cpu)
  2. Install llmlingua and transformers (pip install llmlingua transformers)
  3. Run:
    from llmlingua import PromptCompressor
    compressor = PromptCompressor(model_name="microsoft/llmlingua-2-xlm-roberta-large-meetingbank", use_llmlingua2=True)
    
  4. The error occurs even if os.environ['CUDA_VISIBLE_DEVICES'] = '-1' is set before any import.

Environment:

  • Windows 10
  • Python 3.11
  • torch 2.6.0+cpu
  • llmlingua 0.2.2
  • transformers 4.51.3

Full error output:

AssertionError: Torch not compiled with CUDA enabled

(The traceback points to an internal call in transformers/llmlingua trying to access CUDA.)

Notes:

  • The environment has no GPU or CUDA.
  • The error occurs even with the latest version of all libraries.
  • The same code works on Linux (according to other users).

Question:
How can I force LLMLingua to use CPU only on Windows?
Is there any workaround or model version that works on pure CPU in Windows?

Thanks for your help!

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.