Is it not possible to `load` transformer model on cpu only

Aperta
#286 3 commenti 0 reazioni 0 assegnatari Vedi su GitHub

@maxteneff ci sta già lavorando.

Dal 17/10/2026.

  • #321 di @rozetyp — chiusa senza merge
  • #327 di @maxteneff — aperta

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python, pytorch

Direzione di ricerca

Start in rectools/models/nn/transformers/base.py at __setstate__ around line 596, where loading fails on a CPU-only machine. Read the model serialization and loading path to see how device mapping is handled, then check the related transformer model tests. Done means a fitted model can be loaded for CPU inference when CUDA is unavailable.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug good first issue
What happened?

I need to run inference of BERT4Rec on a CPU-only instance, but I can't.
When I try to load the fitted model, I get a PyTorch error.

RuntimeError: Attempting to deserialize object on a CUDA device but torch.cuda.is_available() is False. If you are running on a CPU-only machine, please use torch.load with map_location=torch.device('cpu') to map your storages to the CPU.

This occurs in __setstate__ at rectools/models/nn/transformers/base.py:596, and it’s currently impossible to pass the map_location parameter when loading the model.
Is exists some workaround there?

Expected behavior

No response

Relevant logs and/or screenshots

No response

Operating System

ubuntu

Python Version

3.11

RecTools version

0.13.0

Lingua principale
Python
Stelle
457
Fork
55
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MTSWebServices/RecTools

Tutte le issue di MTSWebServices/RecTools

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.