Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

W&B Sweep - Cannot represent an object #5386

Closed
Zegorax opened this issue Oct 29, 2021 · 10 comments · Fixed by #5402
Closed

W&B Sweep - Cannot represent an object #5386

Zegorax opened this issue Oct 29, 2021 · 10 comments · Fixed by #5402
Labels
bug Something isn't working

Comments

@Zegorax
Copy link
Contributor

Zegorax commented Oct 29, 2021

🐛 Bug

When trying to run a W&B Sweep, the process fails with the following error:

Traceback (most recent call last):
  File "utils/loggers/wandb/sweep.py", line 36, in <module>
    sweep()
  File "utils/loggers/wandb/sweep.py", line 32, in sweep
    train(hyp_dict, opt, device, callbacks=Callbacks())
  File "/usr/src/app/train.py", line 84, in train
    yaml.safe_dump(vars(opt), f, sort_keys=False)
  File "/opt/conda/lib/python3.8/site-packages/yaml/__init__.py", line 306, in safe_dump
    return dump_all([data], stream, Dumper=SafeDumper, **kwds)
  File "/opt/conda/lib/python3.8/site-packages/yaml/__init__.py", line 278, in dump_all
    dumper.represent(data)
  File "/opt/conda/lib/python3.8/site-packages/yaml/representer.py", line 27, in represent
    node = self.represent_data(data)
  File "/opt/conda/lib/python3.8/site-packages/yaml/representer.py", line 48, in represent_data
    node = self.yaml_representers[data_types[0]](self, data)
  File "/opt/conda/lib/python3.8/site-packages/yaml/representer.py", line 207, in represent_dict
    return self.represent_mapping('tag:yaml.org,2002:map', data)
  File "/opt/conda/lib/python3.8/site-packages/yaml/representer.py", line 118, in represent_mapping
    node_value = self.represent_data(item_value)
  File "/opt/conda/lib/python3.8/site-packages/yaml/representer.py", line 58, in represent_data
    node = self.yaml_representers[None](self, data)
  File "/opt/conda/lib/python3.8/site-packages/yaml/representer.py", line 231, in represent_undefined
    raise RepresenterError("cannot represent an object", data)
yaml.representer.RepresenterError: ('cannot represent an object', PosixPath('yolov5s.pt'))

To Reproduce (REQUIRED)

  1. docker run -it --rm --runtime nvidia --ipc=host ultralytics/yolov5 bash
  2. python utils/loggers/wandb/sweep.py
  3. Choose 3 - Don't visualize my results (The bug happens even when choosing 1 or 2, or being already logged into W&B)

Expected behavior

The sweep should happen

Environment

If applicable, add screenshots to help explain your problem.

  • OS: Ubuntu 18
  • GPU: Tesla V100

Additional context

Since it is running in a Docker container, the OS and environment are not applicable here.

@Zegorax Zegorax added the bug Something isn't working label Oct 29, 2021
@glenn-jocher
Copy link
Member

@Zegorax thanks for the bug report!

@AyushExel can you take a look please? Thank you.

@AyushExel
Copy link
Contributor

AyushExel commented Oct 29, 2021

@Zegorax please follow the Sweeps tutorial here
You need to follow the following steps to make sweeps work

  • Set the hyperparameter limits in data/hyps/sweep.yaml and define dataset path and search strategy.
  • run wandb sweep utils/wandb_logging/sweep.yaml . You can optionally pass --project name --count max_run_count
  • The above command will output an id. Start the sweep with wandb agent sweep_id.

Also, sweeps requires that you visualize your runs with W&B

@Zegorax
Copy link
Contributor Author

Zegorax commented Oct 29, 2021

@AyushExel I already did and had the same problem. I simplified the reproduction tests here, since it is failing even with default definitions.

@AyushExel
Copy link
Contributor

@Zegorax aah okay. I can reproduce. Seems like there was some change recently because this was working fine last week. I'll have a look and get back

@AyushExel
Copy link
Contributor

@glenn-jocher this seems related to the change where opt.weights is set to ROOT/ 'yolov5s.yaml which is a Path object and cannot be serialized. But I don't see how this only fails with sweep.

@AyushExel
Copy link
Contributor

@Zegorax can you try using this branch to see if the problem is fixed? https://github.com/AyushExel/yolov5/tree/sweep
I'll make a PR to main branch if this works for you

@Zegorax
Copy link
Contributor Author

Zegorax commented Oct 29, 2021

I can confirm that it now works, thanks!

@glenn-jocher
Copy link
Member

@Zegorax good news 😃! Your original issue may now be fixed ✅ in PR #5402. To receive this update:

  • Gitgit pull from within your yolov5/ directory or git clone https://github.com/ultralytics/yolov5 again
  • PyTorch Hub – Force-reload with model = torch.hub.load('ultralytics/yolov5', 'yolov5s', force_reload=True)
  • Notebooks – View updated notebooks Open In Colab Open In Kaggle
  • Dockersudo docker pull ultralytics/yolov5:latest to update your image Docker Pulls

Thank you for spotting this issue and informing us of the problem. Please let us know if this update resolves the issue for you, and feel free to inform us of any other issues you discover or feature requests that come to mind. Happy trainings with YOLOv5 🚀!

@yin-qiyu
Copy link

yin-qiyu commented May 1, 2022

@Zegorax can you try using this branch to see if the problem is fixed? https://github.com/AyushExel/yolov5/tree/sweep I'll make a PR to main branch if this works for you

Trying to run wandb agent --project sweep-test --count 10

ERROR:

wandb: Starting wandb agent 🕵️
wandb: ERROR Error while calling W&B API: entityName required for project query (<Response [400]>)

@glenn-jocher
Copy link
Member

@yin-qiyu thanks for the bug report! @AyushExel can help with W&B-related issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants