# Wandb.watch in accelerate library

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-watch-in-accelerate-library%2F19402%3E%5C
**Category:** 🤗Accelerate\
**Created:** [June 20, 2022, 10:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-watch-in-accelerate-library%2F19402 "2022-06-20T22:12:49Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![aclifton314](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/aclifton314/32/55465_2.png) [@aclifton314](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Faclifton314)%5C
**Post date:** [June 20, 2022, 10:12pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-watch-in-accelerate-library%2F19402%2F1 "2022-06-20T22:12:49Z")

</div>

When I’m nominally using `wandb`, in there documentation for pytorch integration there is a suggested call to the `watch` method:

```python
wandb.watch(my_model, log='all', log_freq=8)

```

With the following enviroment variable set:

```auto
export WANDB_WATCH="all"

```

I’m able to record the values of the gradients and the parameter values throughout training. Is there a way to record the gradients and parameter values throughout training by using the accelerate library?

---

<div class="post-metadata">

**Author:** ![morgan](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/morgan/32/2293_2.png) [@morgan](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmorgan)%5C
**Post date:** [June 22, 2022, 10:04am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-watch-in-accelerate-library%2F19402%2F2 "2022-06-22T10:04:18Z")

</div>

Did you try calling `wandb.watch()` just after initialising the wandb run in Acclerate? It might still work as long as its called before you start logging in your script

---

<div class="post-metadata">

**Author:** ![muellerzr](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/muellerzr/32/21583_2.png) [@muellerzr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmuellerzr)%5C
**Post date:** [June 23, 2022, 8:19pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-watch-in-accelerate-library%2F19402%2F3 "2022-06-23T20:19:01Z")

</div>

> [@morgan](#):
>
> It might still work as long as its called before you start logging in your script

For code of what @morgan means, it’d look something like this:

```python
accelerate = Accelerator(log_with="wandb")

accelerate.init_trackers("my_projectname")
wandb.watch()

```

---

<div class="post-metadata">

**Author:** ![aclifton314](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/aclifton314/32/55465_2.png) [@aclifton314](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Faclifton314)%5C
**Post date:** [June 30, 2022, 6:00pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-watch-in-accelerate-library%2F19402%2F4 "2022-06-30T18:00:37Z")

</div>

@morgan @muellerzr That works perfectly! I tested it out and you can call `wandb.watch()` even right before the training loop starts (before one starts logging metrics to wandb).

---

<div class="post-metadata">

**Author:** ![aclifton314](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/aclifton314/32/55465_2.png) [@aclifton314](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Faclifton314)%5C
**Post date:** [June 30, 2022, 6:50pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-watch-in-accelerate-library%2F19402%2F5 "2022-06-30T18:50:30Z")

</div>

One last thing. I noticed that if I run `accelerator` on multiple gpu (say 3) and choose my tracker to be `wandb` that it will output 3 files to sync to `wandb`. Is there a way to some how aggregate all those files into one to get a single view of the entire training loop?

---

<div class="post-metadata">

**Author:** ![morgan](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/morgan/32/2293_2.png) [@morgan](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fmorgan)%5C
**Post date:** [July 18, 2022, 4:16pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-watch-in-accelerate-library%2F19402%2F6 "2022-07-18T16:16:15Z")

</div>

@aclifton314 we’re aware of this and will be working on it, for now you could pass a `group` argument to the wandb init kwargs, then you can group by this value in the UI. [Group Runs - Documentation](https://docs.wandb.ai/guides/track/advanced/grouping)

---

<div class="post-metadata">

**Author:** ![kerkathy](https://avatars.discourse-cdn.com/v4/letter/k/ee7513/32.png) [@kerkathy](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fkerkathy)%5C
**Post date:** [May 1, 2024, 5:29pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fwandb-watch-in-accelerate-library%2F19402%2F7 "2024-05-01T17:29:05Z")

</div>

> [@aclifton314](#):
>
> @morgan @muellerzr That works perfectly! I tested it out and you can call `wandb.watch()` even right before the training loop starts (before one starts logging metrics to wandb).

did you put auguments in watch()? I mean

```auto
accelerate.init_trackers("my_projectname")
wandb.watch(model, ...)

```
