Unity-Technologies / ml-agents

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
https://unity.com/products/machine-learning-agents
Other
17.18k stars 4.16k forks source link

unityenvworker object has no attribute send #1940

Closed mattinjersey closed 5 years ago

mattinjersey commented 5 years ago

try to update from 0.7 to 0.8

getting errors as shown below, including: AttributeError: 'UnityEnvWorker' object has no attribute 'send' image

mattinjersey commented 5 years ago

part of the problem seems to be that I installed the communication_objects folder as described in an issue below. maybe it was done incorrectly.

eshvk commented 5 years ago

Please try with the latest version of ML-Agents (0.8.1) which has a hotfix to deal with communicator_objects.

mattinjersey commented 5 years ago

I have tried again. Now the communicator folder is going to the right place, which is good. But I still see the same error as above. Not working.

mattinjersey commented 5 years ago

strange because I look at the code and I can see that the UnityEnvWorker does have a method for send. So I am not sure why it doesn't see it.

jinzhaochaliang commented 5 years ago

Hello, have you solved this problem? I also encountered this problem after the update, thank you very much

mattinjersey commented 5 years ago

no not solved. I suspect it is because I am updating. There is something that needs to be deleted from previous code and I am not sure what. I have tried to remove all previous code. Thanks Matt

jinzhaochaliang commented 5 years ago

Hello, I successfully solved this problem by creating a new virtual environment through conda. my unity version is 2019.1.0f2 and ml_agents version is 0.8.0.

mattinjersey commented 5 years ago

great I have it working now. I even went back and updated conda which took a while but maybe it helped. Then I created a new virtual environment.

rjnox commented 5 years ago

I'm having the same issue with 0.8.1 but without using conda. Is there any updates on this or possible workaround?

harperj commented 5 years ago

@brianbrown3 are you able to reproduce the issue with a new virtual environment? If so could you share the steps you took so that I can try to reproduce it?

zZeepo commented 5 years ago

Hey guys, I'm running into the same error.

For the installation I followed the instructions in the /docs/Installation.md. That is the error message I receive:

  trainer_config = yaml.load(data_file)
--------------------------------
Traceback (most recent call last):
  File ".../Unity/mla/venv/bin/mlagents-learn", line 11, in <module>
    sys.exit(main())
  File ".../Unity/mla/venv/lib/python3.6/site-packages/mlagents/trainers/learn.py", line 262, in main
    run_training(0, run_seed, options, Queue())
  File ".../Unity/mla/venv/lib/python3.6/site-packages/mlagents/trainers/learn.py", line 88, in run_training
    keep_checkpoints, lesson, env.external_brains,
  File ".../Unity/mla/venv/lib/python3.6/site-packages/mlagents/envs/subprocess_environment.py", line 174, in external_brains
    self.envs[0].send('external_brains')
AttributeError: 'UnityEnvWorker' object has no attribute 'send'

Here is a list of installed packages in my virtual env:

absl-py==0.7.1
appnope==0.1.0
astor==0.8.0
atomicwrites==1.3.0
attrs==19.1.0
backcall==0.1.0
bleach==3.1.0
cloudpickle==0.8.1
cycler==0.10.0
decorator==4.4.0
defusedxml==0.6.0
docopt==0.6.2
entrypoints==0.3
gast==0.2.2
grpcio==1.11.1
html5lib==0.9999999
ipykernel==5.1.1
ipython==7.5.0
ipython-genutils==0.2.0
ipywidgets==7.4.2
jedi==0.13.3
Jinja2==2.10.1
jsonschema==3.0.1
jupyter==1.0.0
jupyter-client==5.2.4
jupyter-console==6.0.0
jupyter-core==4.4.0
kiwisolver==1.1.0
Markdown==3.1.1
MarkupSafe==1.1.1
matplotlib==3.1.0
mistune==0.8.4
mlagents==0.8.1
mlagents-envs==0.8.1
more-itertools==7.0.0
nbconvert==5.5.0
nbformat==4.4.0
notebook==5.7.8
numpy==1.14.5
pandocfilters==1.4.2
parso==0.4.0
pexpect==4.7.0
pickleshare==0.7.5
Pillow==6.0.0
pluggy==0.11.0
prometheus-client==0.6.0
prompt-toolkit==2.0.9
protobuf==3.6.1
ptyprocess==0.6.0
py==1.8.0
Pygments==2.4.0
pyparsing==2.4.0
pyrsistent==0.15.2
pytest==3.10.1
python-dateutil==2.8.0
PyYAML==5.1
pyzmq==18.0.1
qtconsole==4.4.4
Send2Trash==1.5.0
six==1.12.0
tensorboard==1.7.0
tensorflow==1.7.1
termcolor==1.1.0
terminado==0.8.2
testpath==0.4.2
tornado==6.0.2
traitlets==4.3.2
wcwidth==0.1.7
webencodings==0.5.1
Werkzeug==0.15.4
widgetsnbextension==3.4.2

I'm currently running MacOS 10.14.4

Let me know if I can assist by giving more information.

harperj commented 5 years ago

@zZeepo apologies for the late response. I haven't seen this particular error before. This is a bit strange because as you can see UnityEnvWorker should have a method send: https://github.com/Unity-Technologies/ml-agents/blob/master/ml-agents-envs/mlagents/envs/subprocess_environment.py#L29

Did you have any luck getting the installation to work? I can try again from a fresh virtual environment on OSX to see if I can reproduce.

zZeepo commented 5 years ago

@harperj Unfortunately, I was not able to resolve the issue in the meantime. Yes, it's strange, I also checked my local installation: The UnityEnvWorker has the send method.

I tried with different Unity versions and ml-agents 0.8.0 as well as 0.8.1. No luck with any of them.

Previously, I had an older version of ml-agents installed. Maybe there are some files left, which are conflicting with the new installation somehow.

mattinjersey commented 5 years ago

the virtual environment should really help here. first delete all the files shown in the sitepackages directory. then create the virtual environment exactly as directed, including the python command. then do the installation and make sure that it is running from the sitepackages associated with the virtual environment that you have created.

I have found that if you don't exactly do it right, you can end up calling some of the older files.

harperj commented 5 years ago

Yeah, related to what @mattinjersey said I'd recommend ensuring you pip uninstall ML-Agents packages outside your virtual environment and trying again.

xiaomaogy commented 5 years ago

@mattinjersey @zZeepo @brianbrown3 Also maybe you could try this

Since this might be due to a stale .pyc file.

So instead of using a new conda environment (which should definitely work, but might be bothersome), you can also try this command under the root directory of ml-agents folder.

python -m compileall .

This command will recompile all of the .pyc files.

You can refer to this page for more detail. http://effbot.org/pyfaq/how-do-i-create-a-pyc-file.htm

harperj commented 5 years ago

Hi all -- this issue has been inactive for some time so I'm going to close it. Feel free to reopen or create a new issue if you have more to discuss.

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.