wandb.errors.UsageError: api_key not configured (no-tty). call wandb.login(key=[your_api_key])

在使用Transformers进行模型训练时遇到了wandb的报错,错误信息提示缺少api_key配置。这通常意味着wandb无法找到有效的API密钥进行日志记录。解决方案包括正确设置环境变量或在代码中提供API密钥,或者在非交互式环境中手动登录wandb。
摘要由CSDN通过智能技术生成

模型训练遇到wandb有关报错怎么办???

 26%|██▋       | 500/1889 [01:27<03:32,  6.54it/s]wandb: ERROR api_key not configured (no-tty). call wandb.login(key=[your_api_key])
Traceback (most recent call last):
  File "C:\Program Files\JetBrains\PyCharm 2023.1\plugins\python\helpers\pydev\pydevconsole.py", line 367, in runcode
    loop.run_until_complete(coro)
  File "D:\Miniconda3\lib\asyncio\base_events.py", line 616, in run_until_complete
    return future.result()
  File "<input>", line 69, in <module>
  File "D:\Miniconda3\lib\site-packages\transformers\trainer.py", line 1662, in train
    return inner_training_loop(
  File "D:\Miniconda3\lib\site-packages\transformers\trainer.py", line 2006, in _inner_training_loop
    self._maybe_log_save_evaluate(tr_loss, model, trial, epoch, ignore_keys_for_eval)
  File "D:\Miniconda3\lib\site-packages\transformers\trainer.py", line 2273, in _maybe_log_save_evaluate
    self.log(logs)
  File "D:\Miniconda3\lib\site-packages\transformers\trainer.py", line 2612, in log
    self.control = self.callback_handler.on_log(self.args, self.state, self.control, logs)
  File "D:\Miniconda3\lib\site-packages\transformers\trainer_callback.py", line 390, in on_log
    return self.call_event("on_log", args, state, control, logs=logs)
  File "D:\Miniconda3\lib\site-packages\transformers\trainer_callback.py", line 397, in call_event
    result = getattr(callback, event)(
  File "D:\Miniconda3\lib\site-packages\transformers\integrations.py", line 804, in on_log
    self.setup(args, state, model)
  File "D:\Miniconda3\lib\site-packages\transformers\integrations.py", line 738, in setup
    self._wandb.init(
  File "D:\Miniconda3\lib\site-packages\wandb\sdk\wandb_init.py", line 1171, in init
    raise e
  File "D:\Miniconda3\lib\site-packages\wandb\sdk\wandb_init.py", line 1148, in init
    wi.setup(kwargs)
  File "D:\Miniconda3\lib\site-packages\wandb\sdk\wandb_init.py", line 289, in setup
    wandb_login._login(
  File "D:\Miniconda3\lib\site-packages\wandb\sdk\wandb_login.py", line 298, in _login
    wlogin.prompt_api_key()
  File "D:\Miniconda3\lib\site-packages\wandb\sdk\wandb_login.py", line 228, in prompt_api_key
    raise UsageError("api_key not configured (no-tty). call " + directive)
wandb.errors.UsageError: api_key not configured (no-tty). call wandb.login(key=[your_api_key])
┌───────────────────── Traceback (most recent call last) ─────────────────────┐
│ C:\Program Files\JetBrains\PyCharm                                          │
│ 2023.1\plugins\python\helpers\pydev\pydevconsole.py:367 in runcode          │
│                                                                             │
│   364 │   │   │   │   coro = func()                                         │
│   365 │   │   │   │   if inspect.iscoroutine(coro):                         │
│   366 │   │   │   │   │   loop = asyncio.get_event_loop()                   │
│ > 367 │   │   │   │   │   loop.run_until_complete(coro)                     │
│   368 │   │   │   except SystemExit:                                        │
│   369 │   │   │   │   raise                                                 │
│   370 │   │   │   except RuntimeError as err:                               │
│                                                                             │
│ D:\Miniconda3\lib\asyncio\base_events.py:616 in run_until_complete          │
│                                                                             │
│    613 │   │   if not future.done():                                        │
│    614 │   │   │   raise RuntimeError('Event loop stopped before Future com │
│    615 │   │                                                                │
│ >  616 │   │   return future.result()                                       │
│    617 │                                                                    │
│    618def stop(self):                                                  │
│    619 │   │   """Stop running the event loop.                              │
│ in <module>:69                                                              │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\transformers\trainer.py:1662 in train       │
│                                                                             │
│   1659 │   │   inner_training_loop = find_executable_batch_size(            │
│   1660 │   │   │   self._inner_training_loop, self._train_batch_size, args. │
│   1661 │   │   )                                                            │
│ > 1662 │   │   return inner_training_loop(                                  │
│   1663 │   │   │   args=args,                                               │
│   1664 │   │   │   resume_from_checkpoint=resume_from_checkpoint,           │
│   1665 │   │   │   trial=trial,                                             │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\transformers\trainer.py:2006 in             │
│ _inner_training_loop                                                        │
│                                                                             │
│   2003 │   │   │   │   │   self.state.epoch = epoch + (step + 1 + steps_ski │
│   2004 │   │   │   │   │   self.control = self.callback_handler.on_step_end │
│   2005 │   │   │   │   │                                                    │
│ > 2006 │   │   │   │   │   self._maybe_log_save_evaluate(tr_loss, model, tr │
│   2007 │   │   │   │   else:                                                │
│   2008 │   │   │   │   │   self.control = self.callback_handler.on_substep_ │
│   2009                                                                      │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\transformers\trainer.py:2273 in             │
│ _maybe_log_save_evaluate                                                    │
│                                                                             │
│   2270 │   │   │   self._globalstep_last_logged = self.state.global_step    │
│   2271 │   │   │   self.store_flos()                                        │
│   2272 │   │   │                                                            │
│ > 2273 │   │   │   self.log(logs)                                           │
│   2274 │   │                                                                │
│   2275 │   │   metrics = None                                               │
│   2276 │   │   if self.control.should_evaluate:                             │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\transformers\trainer.py:2612 in log         │
│                                                                             │
│   2609 │   │                                                                │
│   2610 │   │   output = {**logs, **{"step": self.state.global_step}}        │
│   2611 │   │   self.state.log_history.append(output)                        │
│ > 2612 │   │   self.control = self.callback_handler.on_log(self.args, self. │
│   2613 │                                                                    │
│   2614 │   def _prepare_input(self, data: Union[torch.Tensor, Any]) -> Unio │
│   2615 │   │   """                                                          │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\transformers\trainer_callback.py:390 in     │
│ on_log                                                                      │
│                                                                             │
│   387 │                                                                     │
│   388def on_log(self, args: TrainingArguments, state: TrainerState, co │
│   389 │   │   control.should_log = False                                    │
│ > 390 │   │   return self.call_event("on_log", args, state, control, logs=l │
│   391 │                                                                     │
│   392def on_prediction_step(self, args: TrainingArguments, state: Trai │
│   393 │   │   return self.call_event("on_prediction_step", args, state, con │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\transformers\trainer_callback.py:397 in     │
│ call_event                                                                  │
│                                                                             │
│   394 │                                                                     │
│   395def call_event(self, event, args, state, control, **kwargs):      │
│   396 │   │   for callback in self.callbacks:                               │
│ > 397 │   │   │   result = getattr(callback, event)(                        │
│   398 │   │   │   │   args,                                                 │
│   399 │   │   │   │   state,                                                │
│   400 │   │   │   │   control,                                              │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\transformers\integrations.py:804 in on_log  │
│                                                                             │
│    801 │   │   if self._wandb is None:                                      │
│    802 │   │   │   return                                                   │
│    803 │   │   if not self._initialized:                                    │
│ >  804 │   │   │   self.setup(args, state, model)                           │
│    805 │   │   if state.is_world_process_zero:                              │
│    806 │   │   │   logs = rewrite_logs(logs)                                │
│    807 │   │   │   self._wandb.log({**logs, "train/global_step": state.glob │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\transformers\integrations.py:738 in setup   │
│                                                                             │
│    735 │   │   │   │   │   init_args["name"] = args.run_name                │
│    736 │   │   │                                                            │
│    737 │   │   │   if self._wandb.run is None:                              │
│ >  738 │   │   │   │   self._wandb.init(                                    │
│    739 │   │   │   │   │   project=os.getenv("WANDB_PROJECT", "huggingface" │
│    740 │   │   │   │   │   **init_args,                                     │
│    741 │   │   │   │   )                                                    │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\wandb\sdk\wandb_init.py:1171 in init        │
│                                                                             │
│   1168except Error as e:                                               │
│   1169 │   │   if logger is not None:                                       │
│   1170 │   │   │   logger.exception(str(e))                                 │
│ > 1171 │   │   raise e                                                      │
│   1172except KeyboardInterrupt as e:                                   │
│   1173 │   │   assert logger                                                │
│   1174 │   │   logger.warning("interrupted", exc_info=e)                    │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\wandb\sdk\wandb_init.py:1148 in init        │
│                                                                             │
│   1145 │   run: Optional[Union[Run, RunDisabled]] = None                    │
│   1146try:                                                             │
│   1147 │   │   wi = _WandbInit()                                            │
│ > 1148 │   │   wi.setup(kwargs)                                             │
│   1149 │   │   assert wi.settings                                           │
│   1150 │   │   except_exit = wi.settings._except_exit                       │
│   1151 │   │   try:                                                         │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\wandb\sdk\wandb_init.py:289 in setup        │
│                                                                             │
│    286 │   │   │   settings.update(init_settings, source=Source.INIT)       │
│    287 │   │                                                                │
│    288 │   │   if not settings._offline and not settings._noop:             │
│ >  289 │   │   │   wandb_login._login(                                      │
│    290 │   │   │   │   anonymous=kwargs.pop("anonymous", None),             │
│    291 │   │   │   │   force=kwargs.pop("force", None),                     │
│    292 │   │   │   │   _disable_warning=True,                               │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\wandb\sdk\wandb_login.py:298 in _login      │
│                                                                             │
│   295 │   │   return logged_in                                              │
│   296 │                                                                     │
│   297if not key:                                                       │
│ > 298 │   │   wlogin.prompt_api_key()                                       │
│   299 │                                                                     │
│   300# make sure login credentials get to the backend                  │301 │   wlogin.propogate_login()                                          │
│                                                                             │
│ D:\Miniconda3\lib\site-packages\wandb\sdk\wandb_login.py:228 in             │
│ prompt_api_key                                                              │
│                                                                             │
│   225 │   │   │   │   if self._settings._cli_only_mode                      │
│   226 │   │   │   │   else "wandb.login(key=[your_api_key])"                │
│   227 │   │   │   )                                                         │
│ > 228 │   │   │   raise UsageError("api_key not configured (no-tty). call " │
│   229 │   │                                                                 │
│   230 │   │   self.update_session(key, status=status)                       │
│   231 │   │   self._key = key                                               │
└─────────────────────────────────────────────────────────────────────────────┘
UsageError: api_key not configured (no-tty). call 
wandb.login(key=[your_api_key])

当然是把它卸载掉了!!!!!!!!!!!!!!

在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

宿夏星

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值