This part isn’t strictly for audio i/o, but is nevertheless a normal part of Harmonai’s operations. The point of this package is to reduce code-copying between Harmonai projects.
Heads up: Huggingface accelerate support will likely be deprecated soon. We found accelerate necessary because of problems running PyTorch Lightning on multiple nodes, but those problems have now been resolved. Thus we will likely be using Lighting, so you will see that dependency being added and perhaps accelerate being removed.
Next is a little utility to replace print, where it’ll only print on the cluster headnode. Note that you can only send one string to hprint, so use f-strings. Also we use ANSI codes to color the text (currently cyan) to help it stand out from all the other text that’s probably scrolling by!
lil accelerate utility for only printing on host node
Type
Default
Details
accelerator
huggingface accelerator object
tag
str
[96m
starting color
untag
str
[0m
reset to default color
Here’s a test:
accelerator = accelerate.Accelerator()device = accelerator.devicehprint = HostPrinter(accelerator) # hprint only prints on head nodehprint(f'Using device: {device}')
Using device: cpu
PyTorch+Accelerate Model routines
For when the model is wrapped in a accelerate accelerator