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

Đang mở
#286 3 bình luận 0 reaction 0 người được giao Xem trên GitHub

@maxteneff đang làm issue này rồi.

Từ ngày 17/10/2026.

  • #321 của @rozetyp — đã đóng, không merge
  • #327 của @maxteneff — đang mở

Đánh giá

Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức phù hợp với người mới
35/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
python, pytorch
Lĩnh vực
backend, machine-learning

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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

Ngôn ngữ chính
Python
Star
457
Fork
55
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của MTSWebServices/RecTools

Tất cả issue của MTSWebServices/RecTools

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.