Hello Trinity-ers,
I had an issue were if many reads were being assembled on an HPC cluster, I'd run into this wall and found a way around it with major assistance of Tiago Hori from UNL and Mengxing Cheng from FIU. This issue pops up when you have a "largish" number of reads. It didn't come up with 20 million PE reads bit it did after 60 M PE reads.
>>>>>> terminate called after throwing an instance of 'jellyfish::large_hash::array_base<jellyfish::mer_dna_ns::mer_base_static<unsigned long, 0>, unsigned long, atomic::gcc, jellyfish::large_hash::array<j$
what(): Failed to allocate 67527304624 bytes of memory
Error, cmd: /home/applications/trinity/2.0.3/trinity-plugins/jellyfish/bin/jellyfish count -t 32 -m 25 -s 17531127145 both.fa died with ret 134 at /home/applications/trinity/2.0.3/Trinity line 2110.
Trinity run failed. Must investigate error above. <<<<<<
The issue is Jellyfish takes its RAM memory allocation from Butterfly settings, and the memory allocation needs to match what's requested per core (called CPU in the Thrinity pipeline, or thread sometimes elsewhere) and the total memory to be used. This is actually stated in the Trinity "extensive" options showed if you type the "--show_full_usage_info" flag, but if you're like me and didn't read it carefully you probably missed it. In my defense it is worded a bit confusing: "--bflyCalculateCPU :Calculate CPUs based on 80% of max_memory divided by maxbflyHeapSpaceMax"
You basically need to multiple the memory in "--bflyHeapSpaceInit" TIMES the number of CPUs "--bflyCPU" <--> "--CPU" to be EQUAL = "--max_memory"
For example, if you have say 128GB in a node with 16 cores at your HPC cluster to play with: --bflyHeapSpaceInit 4G * --CPU 16 = --max_memory 64G
In this example, even though you can use up to 128GB, what you request Jellyfish and Butterfly is to have 64GB because 4*16= 64.
NOTE: this is because memory is per core, not total on the butterfly options. It's also important the "--bflyHeapSpaceMax" is set higher, in this case say 5G that would still be under the maximum memory on your node (128GB). If you set "--bflyHeapSpaceMax" to also be 4 then Trinity will crash, because initial and max heap space cannot be the same. So don't be greedy! In this case you're not going to run out of memory because your node has 128GB of RAM. The max amount of memory per CPU with this set up would be 7G so maxheap is 8G because 8GB*16CPUs = 128GB. If you want to use more CPUs you need to reduce the amount of RAM for each (32 CPU could only use 4GB maxheap in this example).
Now, THIS IS VITAL! Make sure you can access enough memory at your HPC cluster. Following the "1GB per million reads" rule in Trinity will give you a good ballpark to know how much you'd need. That becomes problematic if your cluster has a limit and you need 400GB of RAM but your limit per user or account is 128GB. If you tell Jellyfish and Butterfly to help themselves to 400GB when that's not available then it'll crash. Make sure that if you're submitting your jobs through a script that you're accessing the appropriate resources otherwise your analysis will die. If you have large limits you can be greedier but you must follow the formula explained above.
So the word is, figure out how much RAM memory you can access on your cluster, estimate how much you really need, do the math (initheap * #CPUs = max mem), and you'll likely avoid issues. BTW, I use a Mac to test out runs and then send them to the cluster. I will be posting how to compile Trinity and full Trinotate on your Mac after some tweaking. It works even with the latest version of java (>=1.8). This issue won't pop up on a personal computer since the RAM amount is little (32 at most on Macs).
Happy Trinity-ing!
-- Hernán, Crustacean-bound Postdoc at FIU