Closed karalleyna closed 2 years ago
@gerdm PTAL
@karalleyna You can also use https://github.com/probml/JSL/blob/main/jsl/demos/ekf_vs_ukf_mlp.py, which is the same code, but without the movie making.
Hi team, shall I try working on this?
Hi @BitterKanegul. Feel free to work on this. It would be good if you make tests for multiple versions of Matplotlib. It seems that using matplotlib version 3.4.3
works fine.
Yeah sure! Thank you!
@karalleyna, could you tell me which version of matplotlib are you using? I've ran the code on my local computer (matplotlib version 3.4.3
) and on a VM (version 3.5.1
) and I can't seem to replicate the error.
Sorry for the late response. Mine is 3.2.1
.
I tried replicating your error with the same Matplotlib 3.2.1
and Python 3.8
and could not replicate your error.
I also get an error running the code on my macbook (python 3.8.5, matplotlib '3.3.2'). I think it is some issue related to ffmpeg. (See error log below). Fortunatley I was abble to get it to run in colab, and made https://github.com/probml/JSL/blob/main/jsl/demos/ekf_mlp_anim.ipynb.
@gerdm Maybe you can try using Celluliod to make the movie? This might be a more portable solution. (See this colab for a demo.)
Unfortunately the current colab is unbelievably slow, even in GPU mode - it takes several minutes just to make 10 frames.
Also, when I run python demos/ekf_vs_ukf_mlp.py
on my laptop, it is painflully slow.
(It didn't used to be so slow, I'm not sure what has changed...)
@gerdm Please investigate why EKF is so slow (eg use a profiler, and/or use @jit ).
kpmurphy-macbookpro1% python demos/ekf_mlp_anim.py
WARNING:absl:No GPU/TPU found, falling back to CPU. (Set TF_CPP_MIN_LOG_LEVEL=0 and rerun for more info.)
WARNING:matplotlib.animation:MovieWriter stderr:
dyld[26302]: Library not loaded: @rpath/libopenh264.5.dylib
Referenced from: /opt/anaconda3/lib/libavcodec.58.91.100.dylib
Reason: tried: '/opt/anaconda3/lib/libopenh264.5.dylib' (no such file), '/opt/anaconda3/lib/libopenh264.5.dylib' (no such file), '/opt/anaconda3/lib/libopenh264.5.dylib' (no such file), '/opt/anaconda3/lib/libopenh264.5.dylib' (no such file), '/opt/anaconda3/lib/libopenh264.5.dylib' (no such file), '/opt/anaconda3/lib/libopenh264.5.dylib' (no such file), '/opt/anaconda3/lib/libopenh264.5.dylib' (no such file), '/opt/anaconda3/lib/libopenh264.5.dylib' (no such file), '/opt/anaconda3/lib/libopenh264.5.dylib' (no such file), '/opt/anaconda3/bin/../lib/libopenh264.5.dylib' (no such file), '/opt/anaconda3/lib/libopenh264.5.dylib' (no such file), '/opt/anaconda3/bin/../lib/libopenh264.5.dylib' (no such file), '/usr/local/lib/libopenh264.5.dylib' (no such file), '/usr/lib/libopenh264.5.dylib' (no such file)
Traceback (most recent call last):
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/animation.py", line 251, in saving
yield self
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/animation.py", line 1145, in save
writer.grab_frame(**savefig_kwargs)
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/animation.py", line 363, in grab_frame
self.fig.savefig(self._frame_sink(), format=self.frame_format,
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/figure.py", line 2311, in savefig
self.canvas.print_figure(fname, **kwargs)
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 2210, in print_figure
result = print_method(
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/backend_bases.py", line 1639, in wrapper
return func(*args, **kwargs)
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/backends/backend_agg.py", line 456, in print_raw
fh.write(renderer.buffer_rgba())
BrokenPipeError: [Errno 32] Broken pipe
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "demos/ekf_mlp_anim.py", line 90, in <module>
main(f, fz, filepath)
File "demos/ekf_mlp_anim.py", line 70, in main
ani.save(filepath, dpi=200, bitrate=-1, fps=10)
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/animation.py", line 1145, in save
writer.grab_frame(**savefig_kwargs)
File "/opt/anaconda3/lib/python3.8/contextlib.py", line 131, in __exit__
self.gen.throw(type, value, traceback)
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/animation.py", line 253, in saving
self.finish()
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/animation.py", line 354, in finish
self.cleanup()
File "/opt/anaconda3/lib/python3.8/site-packages/matplotlib/animation.py", line 390, in cleanup
raise subprocess.CalledProcessError(
subprocess.CalledProcessError: Command '['ffmpeg', '-f', 'rawvideo', '-vcodec', 'rawvideo', '-s', '1280x960', '-pix_fmt', 'rgba', '-r', '10', '-loglevel', 'error', '-i', 'pipe:', '-vcodec', 'h264', '-pix_fmt', 'yuv420p', '-y', './samples_hist_ekf.mp4']' died with <Signals.SIGABRT: 6>.
Thanks for the detailed error log @murphyk . I use Ubuntu 18.04 LTS will try to see if I can replicate it using anaconda. In the meantime, seems ffmpeg's libh264 not found error /opt/anaconda3/lib/libopenh264.5.dylib' (no such file)
has been posted by others too. In case this helps someone, one could try updating ffmpeg using conda or adding symlink.
@maheswarantp Messing with ffmpeg seems like a pain. Can you try to rewrite the code to use https://github.com/jwkvam/celluloid as a way of making animations instead? This may be more portable.
@murphyk sure, I am working on it
I have added Celluloid based animations for this example. The issue that @murphyk mentioned /opt/anaconda3/lib/libopenh264.5.dylib' (no such file)
may be fixed by the use of celluloid, not 100% sure, as it is built on top of matplotlib. Celluloid uses matplotlib.ArtisticAnimation for animation as compared to matplotlib.FuncAnimation in the earlier version.
I believe the performance issues has been reduced with celluloid based ekf_mlp. It has been tested on CPU as well as GPU on colab and it takes 4 minutes and 9 minutes respectively (not sure why GPU is slow) for 200 frames. Not sure if the performance improvement is a priority, if it is, I can do a deeper dive and profile the code.
When I run
ekf_mlp_anim.py
, I'm getting the following error: