AI4Finance-Foundation / FinGPT

FinGPT: Open-Source Financial Large Language Models! Revolutionize 🔥 We release the trained model on HuggingFace.
https://ai4finance.org
MIT License
13.84k stars 1.92k forks source link

FinGPT-v1 finetune.py. ValueError: You can't train a model that has been loaded in 8-bit precision on a different device than the one you're training on. #37

Closed XiongKexin closed 1 year ago

XiongKexin commented 1 year ago

When running FinGPT-v1/training/finetune.py, there is an error:

You are adding a <class 'transformers.integrations.TensorBoardCallback'> to the callbacks of this Trainer, but there is already one. The currentlist of callbacks is
:DefaultFlowCallback
TensorBoardCallback
/data/kexin/anaconda3/envs/fingpt/lib/python3.8/site-packages/transformers/optimization.py:411: FutureWarning: This implementation of AdamW is deprecated and will be removed in a future version. Use the PyTorch implementation torch.optim.AdamW instead, or set 'no_deprecation_warning=True' to disable this warning
  warnings.warn(
Traceback (most recent call last):
  File "/data/kexin/project/FinGPT/fingpt/FinGPT-v1/training/finetune.py", line 144, in <module>
    main()
  File "/data/kexin/project/FinGPT/fingpt/FinGPT-v1/training/finetune.py", line 137, in main
    trainer.train()
  File "/data/kexin/anaconda3/envs/fingpt/lib/python3.8/site-packages/transformers/trainer.py", line 1645, in train
    return inner_training_loop(
  File "/data/kexin/anaconda3/envs/fingpt/lib/python3.8/site-packages/transformers/trainer.py", line 1756, in _inner_training_loop
    model, self.optimizer = self.accelerator.prepare(self.model, self.optimizer)
  File "/data/kexin/anaconda3/envs/fingpt/lib/python3.8/site-packages/accelerate/accelerator.py", line 1182, in prepare
    result = tuple(
  File "/data/kexin/anaconda3/envs/fingpt/lib/python3.8/site-packages/accelerate/accelerator.py", line 1183, in <genexpr>
    self._prepare_one(obj, first_pass=True, device_placement=d) for obj, d in zip(args, device_placement)
  File "/data/kexin/anaconda3/envs/fingpt/lib/python3.8/site-packages/accelerate/accelerator.py", line 1022, in _prepare_one
    return self.prepare_model(obj, device_placement=device_placement)
  File "/data/kexin/anaconda3/envs/fingpt/lib/python3.8/site-packages/accelerate/accelerator.py", line 1258, in prepare_model
    raise ValueError(
ValueError: You can't train a model that has been loaded in 8-bit precision on a different device than the one you're training on. Make sure you loaded the model on the correct device using for example 'device_map={'':torch.cuda.current_device()}you're training on. Make sure you loaded the model on the correct device using for example 'device_map={'':torch.cuda.current_device() or device_map={'':torch.xpu.current_device()}
Process finished with exit code 1

It seems like it's caused by loading in 8-bit. What should I do to fix it? Thanks for your help

oliverwang15 commented 1 year ago

Hi, XiongKexin. That may be an issue related to the accelerate module. Please try to install the modules in the requirements.txt by the following command: pip3 install -r requirements.txt

XiongKexin commented 1 year ago

Hi, XiongKexin. That may be an issue related to the accelerate module. Please try to install the modules in the requirements.txt by the following command: pip3 install -r requirements.txt

Thank you! Problem solved.

xiaozhao1795 commented 1 year ago

你运行finetune.py脚本,生成model了吗,我生成的模型怎么缺少文件