【help】RuntimeError: Tensor on device meta is not on the expected device cuda:0!

Author: oier991215Created Jul 5, 2023Updated Apr 15, 2025

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

报错信息:RuntimeError: Tensor on device meta is not on the expected device cuda:0! 报错位置在: keras_model.fit(train_data = dl_train, val_data = dl_val, epochs=100,patience=5, monitor='val_loss',mode='min', ckpt_path = ckpt_path, mixed_precision='fp16' ) 请问应该怎么解决呢

Expected Behavior

No response

Steps To Reproduce

按照文档配置并运行的

Environment

markdown
- OS:Ubuntu18.0
- Python:3.8
- Transformers:4.30.2
- PyTorch:2.0.1
- CUDA Support (`python -c "import torch; print(torch.cuda.is_available())"`) :True

Anything else?

No response