question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AttributeError: Can't get attribute 'train' on <module '__main__' (built-in)>

See original GitHub issue

wandb --version && python --version && uname

  • Weights and Biases version: wandb, version 0.8.31
  • Python version: Python 3.6.7
  • Operating System: Windows 10

Description

Running tutorial example fails. Link to the tutorial: https://colab.research.google.com/drive/181GCGp36_75C2zm7WLxr9U2QjMXXoibt

What I Did

Running tutorial example fails. Link to the tutorial: https://colab.research.google.com/drive/181GCGp36_75C2zm7WLxr9U2QjMXXoibt

The line with wandb.agent(sweep_id, train)

Gives an error:

Traceback (most recent call last):
File "<string>", line 1, in <module>
File "c:\users\Admin\appdata\local\programs\python\python36\lib\multiprocessing\spawn.py", line 105, in spawn_main exitcode = _main(fd)
File "c:\users\Admin\appdata\local\programs\python\python36\lib\multiprocessing\spawn.py", line 115, in _main self = reduction.pickle.load(from_parent)
AttributeError: Can't get attribute 'train' on <module '__main__' (built-in)>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
nhabbashcommented, Apr 20, 2020

I’ve encountered the same error using:

  • wandb, version 0.8.32
  • Python 3.7.4 (Anaconda)
  • Windows 10

I found out that the issue was with Jupyter Notebook (what I was using) not fully supporting multiprocessing. Haven’t dug out the details, but a fix that made sweeps work was putting the train function definition in an outside .py file, and after that importing it into the notebook.

1reaction
vanpeltcommented, Apr 7, 2020

Hey @Pavlov228 this is due to the train function not being defined. Did you run the cell that defined train before calling wandb.agent?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiprocessing example giving AttributeError - Stack Overflow
When I run the above code I get an AttributeError: can't get attribute 'f' on <module '__main__' (built-in)> .
Read more >
Can't get attribute 'train' on <module '__main__' (built ... - GitHub
I found out that the issue was with Jupyter Notebook (what I was using) not fully supporting multiprocessing. Haven't dug out the details,...
Read more >
Can't get attribute 'label_func' on <module '__main__'>
AttributeError : Can't get attribute 'label_func' on <module '__main__'>. i am importing the function into my_project_api.py.
Read more >
pickle.load can't get attribute python - You.com | The AI Search ...
This happens because the pickled data was saved when the script is run as __name__ == '__main__' and so it saves the location...
Read more >
AttributeError: Can't get attribute 'video_dataset' on <module ...
I have a dataset that has been preprocessed, and this error continues to occur. I've tried the if__name___=='main _': method from several ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found