Hey there @MaestSi! How many threads are you specifying in this script? You can trade in some speed for more RAM.
I would suggest looking into this, there are a few tree-building options in q2-phylogeny:
https://docs.qiime2.org/2019.7/plugins/available/phylogeny/
There is a good community tutorial, here: