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

AttributeError: 'SharedArray' object has no attribute 'dtype' #110

Closed
SOMEAIDI opened this issue Oct 11, 2021 · 14 comments
Closed

AttributeError: 'SharedArray' object has no attribute 'dtype' #110

SOMEAIDI opened this issue Oct 11, 2021 · 14 comments

Comments

@SOMEAIDI
Copy link

when I try the tutorial of pistonball, I met this attribute error. But I have no idea that what should do. So what should I do to deal with the error?

@jkterry1
Copy link
Member

Could you please provide system specs (OS, python verison, etc.) and give me your pip freeze? And did you use this file exactly? https://github.com/PettingZoo-Team/PettingZoo/blob/master/tutorials/13_lines.py

@benblack769
Copy link
Contributor

Just a heads up, this is a common problem for windows users, see #100 for someone who had a similar issue.

@SOMEAIDI
Copy link
Author

SOMEAIDI commented Oct 13, 2021

Could you please provide system specs (OS, python verison, etc.) and give me your pip freeze? And did you use this file exactly? https://github.com/PettingZoo-Team/PettingZoo/blob/master/tutorials/13_lines.py

Thanks for your reply.
I perform my code on windows.And my code is :

    env = pistonball_v4.parallel_env(n_pistons=20, time_penalty=-0.1, continuous=True, random_drop=True,
                                     random_rotate=True, ball_mass=0.75, ball_friction=0.3, ball_elasticity=1.5, max_cycles=125)

    env = ss.color_reduction_v0(env, mode='B')

    env = ss.resize_v0(env, x_size=84, y_size=84)

    env = ss.frame_stack_v1(env, 3)

    env = ss.concat_vec_envs_v0(env, 8, num_cpus=1, base_class='stable_baselines3')

It doesn't work at all.And the error is about stable_baseline3 , "You should use natureCNN" is the attribute error.
But I find that when I remove some code :

    env = pistonball_v4.parallel_env(n_pistons=20, time_penalty=-0.1, continuous=True, random_drop=True,
                                     random_rotate=True, ball_mass=0.75, ball_friction=0.3, ball_elasticity=1.5, max_cycles=125)

    # env = ss.color_reduction_v0(env, mode='B')

    env = ss.resize_v0(env, x_size=84, y_size=84)

    # env = ss.frame_stack_v1(env, 3)

    env = ss.concat_vec_envs_v0(env, 8, num_cpus=1, base_class='stable_baselines3')

Now it works correctly, but I have no idea why this happen . So is Supersuit not suitable for windows ?

@benblack769
Copy link
Contributor

So when you set num_cpus to 1, that should have solved the error in #100. Is that the case?

This error about natureCNN is a bit les clear to me, but it sounds like something you are doing to the preprocessing is confusing SB3. If you could post some complete (with imports and everything) code that you expect to work, but intsead the code fails, I can help you see what is going wrong.

@jkterry1
Copy link
Member

Closing as it's been awhile, please let us know if you need anything else.

@ic
Copy link

ic commented Oct 23, 2021

For your information, same problem today on MacOS, with the same tutorial.

PettingZoo==1.13.1
SuperSuit==3.3.0

python 3.9.7

#100 solves the problem by reducing num_cpus to 1 (sadly 16 cores eagerly available :-)).

@jkterry1 jkterry1 reopened this Oct 23, 2021
@jkterry1
Copy link
Member

@benblack769 I was getting this error too

@benblack769
Copy link
Contributor

@jkterry1 I'll prioritize this. Of course, in the meantime, you can simply turn off multiprocessing by setting num_cpus=1

@benblack769
Copy link
Contributor

This was a change in python3.8 caused by changes in the core MacOS system. See the following trail:

It might be necessary to make changes to the 13 lines tutorial as well as changes to supersuit to get this to work (putting the code after a __name__ == "__main__" guard).

@jkterry1
Copy link
Member

@benblack769 this was only happening to me in Ubuntu

@benblack769
Copy link
Contributor

@jkterry1 If you could give more details as to what your setup was when this error was triggered that would be great. Typically, this would happen with "spawn" multiprocessing, which is a default on MacOS or Windows, but "fork" multiprocessing is the default on linux.

@wittenator
Copy link

wittenator commented Nov 7, 2021

Out of curiosity:
Why is the loading and setting for pickling of the SharedArray asymmetrical at this part of the code:

def __getstate__(self):
?

I had a similar error and if I am not entirely mistaken that fixed that error for me.

@benblack769
Copy link
Contributor

Ah. That would be a bug.

@benblack769
Copy link
Contributor

@wittenator Thanks for pointing this out! I didn't know that it was possible for process shared data to be passed to spawn environments, but I guess they can. I went ahead and tested it in the PR and it seems to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants