evilsocket / pwnagotchi

(⌐■_■) - Deep Reinforcement Learning instrumenting bettercap for WiFi pwning.
https://pwnagotchi.ai/
Other
7.74k stars 1.15k forks source link

[BUG] AI training on Pi3b+ #925

Open thebitsworld opened 4 years ago

thebitsworld commented 4 years ago

Describe the bug pwnagotchi work fine in auto mode. when switch from auto to AI mode, it got error in logs and not discover AP anymore.

logs: [2020-09-28 14:31:02,190] [ERROR] [ai] error while training (could not broadcast input array from shape (428) into shape (1,503)) Traceback (most recent call last): File "/usr/local/lib/python3.7/dist-packages/pwnagotchi/ai/train.py", line 177, in _ai_worker self._model.learn(total_timesteps=epochs_per_episode, callback=self.on_ai_training_step) File "/usr/local/lib/python3.7/dist-packages/stable_baselines/a2c/a2c.py", line 231, in learn runner = A2CRunner(self.env, self, n_steps=self.n_steps, gamma=self.gamma) File "/usr/local/lib/python3.7/dist-packages/stable_baselines/a2c/a2c.py", line 310, in init super(A2CRunner, self).init(env=env, model=model, n_steps=n_steps) File "/usr/local/lib/python3.7/dist-packages/stable_baselines/common/runners.py", line 19, in init self.obs[:] = env.reset() File "/usr/local/lib/python3.7/dist-packages/stable_baselines/common/vec_env/dummy_vec_env.py", line 52, in reset self._save_obs(env_idx, obs) File "/usr/local/lib/python3.7/dist-packages/stable_baselines/common/vec_env/dummy_vec_env.py", line 71, in _save_obs self.buf_obs[key][env_idx] = obs ValueError: could not broadcast input array from shape (428) into shape (1,503)

To Reproduce Steps to reproduce the behavior:

  1. fresh install pwnagotchi v1.5.3 on raspberry pi3b+
  2. wait for pwnagotchi switch from auto to AI mode.

Expected behavior pwnagotchi continue find AP, handshake in AI mod

Environment (please complete the following information):

arch-user-france1 commented 4 years ago

I don't have this issue... I'm using also a Rasperrypi 3 B +...

But if it works a long time and restart much times, it wont switch to AI anymore....

your problem may in the configuration file of pwnagotchi, in /etc/pwnagotchi/

guycalledseven commented 3 years ago

I have the same issue except I am not getting any APs at all. :-( I managed to "fix" python AI issue by loading bunch of dependencies:

sudo apt-get install libopencv-dev python-opencv python-picamera

Hope it helps.

arch-user-france1 commented 3 years ago

I've the bug, that the pwnagotchi won't switch to the ai mode. It log files say, that the error occurred while reading the brain.nn configuration file. I fixed it with removing the file. I don't know, if it is this file or the other file. But it is the "model"

Does that affect to the pwnagotchi? The ai worked perfectly after restarting the pwnagotchi

pastel-parasol commented 3 years ago

Same issue. Tried @guycalledseven 's solution, but nothing changed. Using Raspberry Pi 3A+, same error in logs.

Saru13 commented 3 years ago

Tried 1.5.5? Can we close this?

facastagnini commented 2 years ago

I have exactly the same error reported here https://github.com/evilsocket/pwnagotchi/issues/925#issue-711194618

The error

16:59:09 [INFO] [ai] model created: 16:59:09 [INFO] gamma: 0.99 16:59:09 [INFO] n_steps: 1 16:59:09 [INFO] vf_coef: 0.25 16:59:09 [INFO] ent_coef: 0.01 16:59:09 [INFO] max_grad_norm: 0.5 16:59:09 [INFO] learning_rate: 0.001 16:59:09 [INFO] alpha: 0.99 16:59:09 [INFO] epsilon: 1e-05 16:59:09 [INFO] verbose: 1 16:59:09 [INFO] lr_schedule: constant 16:59:10 [INFO] [ai] learning for 50 epochs ... 16:59:10 [ERROR] [ai] error while training (could not broadcast input array from shape (428,) into shape (1,503)) (most recent call last): File "/usr/local/lib/python3.7/dist-packages/pwnagotchi/ai/train.py", line 177, in _ai_worker self._model.learn(total_timesteps=epochs_per_episode, callback=self.on_ai_training_step) File "/usr/local/lib/python3.7/dist-packages/stable_baselines/a2c/a2c.py", line 231, in learn runner = A2CRunner(self.env, self, n_steps=self.n_steps, gamma=self.gamma) File "/usr/local/lib/python3.7/dist-packages/stable_baselines/a2c/a2c.py", line 310, in init super(A2CRunner, self).init(env=env, model=model, n_steps=n_steps) File "/usr/local/lib/python3.7/dist-packages/stable_baselines/common/runners.py", line 19, in init self.obs[:] = env.reset() File "/usr/local/lib/python3.7/dist-packages/stable_baselines/common/vec_env/dummy_vec_env.py", line 52, in reset self._save_obs(env_idx, obs) File "/usr/local/lib/python3.7/dist-packages/stable_baselines/common/vec_env/dummy_vec_env.py", line 71, in _save_obs self.buf_obs[key][env_idx] = obs could not broadcast input array from shape (428,) into shape (1,503)

Hardware

$ cat /proc/cpuinfo processor : 0 model name : ARMv7 Processor rev 4 (v7l) BogoMIPS : 38.40 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4

processor : 1 model name : ARMv7 Processor rev 4 (v7l) BogoMIPS : 38.40 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4

processor : 2 model name : ARMv7 Processor rev 4 (v7l) BogoMIPS : 38.40 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4

processor : 3 model name : ARMv7 Processor rev 4 (v7l) BogoMIPS : 38.40 Features : half thumb fastmult vfp edsp neon vfpv3 tls vfpv4 idiva idivt vfpd32 lpae evtstrm crc32 CPU implementer : 0x41 CPU architecture: 7 CPU variant : 0x0 CPU part : 0xd03 CPU revision : 4

Hardware : BCM2835 Revision : a020d3 Serial : XXXXXXXXXXXXXXX Model : Raspberry Pi 3 Model B Plus Rev 1.3

Tried 2 clean installations

In both instances, there is no /boot/brains.nn being created.

Thanks in advance for your help

tomasjanu commented 2 years ago

I have the same issue as thebitsworld and facastagnini.

Same error, no brain.nn created :(

tomasjanu commented 2 years ago

I have the same issue as thebitsworld and facastagnini.

Same error, no brain.nn created :(

Interesting observation!

Taking the microSD card from RPi 3B+ to Rpi Zero (so I didnt change anything else) and the AI works perfectly!

So now... let's find out what the AI actually does :D

XZCendence commented 2 years ago

Having this same issue :( Not sure how to fix it