To run a neural network, how much memory does one need? Is it enought to load the first two layers from disk, calculate the activations for all nodes, discard the first layer, load the third layer from disk, calculate all the activations for all nodes, discard the second layer etc? Then memory needs to be big enough to hold to 2 layers?
Llama2.c: Inference llama 2 in one file of pure C
11–20 of 173 posts
Re: Llama2.c: Inference llama 2 in one file of pure C
#12To run a neural network, how much memory does one need? Is it enought to load the first two layers from disk, calculate the activations for all nodes, discard the first layer, load the third layer from disk, calculate all the activations for all nodes, discard the second layer etc? Then memory needs to be big enough to hold to 2 layers?
Re: Llama2.c: Inference llama 2 in one file of pure C
#13What are some uses for this?
- learning how to implement various deep learning operations in C
- generally removing abstraction from "AI" to give a better sense of what is happening in inference
- as a template to follow for custom projects
- as a basis for learning about applying hardware specific optimizations (say, trying to rewrite to use BLAS)
- because it's cool
Re: Llama2.c: Inference llama 2 in one file of pure C
#14ohh thats some really nice readable c-code
Re: Llama2.c: Inference llama 2 in one file of pure C
#15neat! note that gcc's default optimisation level is 0, which really isn't what people normally want. adding -O2 to the gcc command line should improve performance quite a bit.
-Ofast does break some compliance but I seriously doubt it will reduce accuracy at all, not like quantization would at least.
Re: Llama2.c: Inference llama 2 in one file of pure C
#16To run a neural network, how much memory does one need? Is it enought to load the first two layers from disk, calculate the activations for all nodes, discard the first layer, load the third layer from disk, calculate all the activations for all nodes, discard the second layer etc? Then memory needs to be big enough to hold to 2 layers?
Re: Llama2.c: Inference llama 2 in one file of pure C
#17Re: Llama2.c: Inference llama 2 in one file of pure C
#18To run a neural network, how much memory does one need? Is it enought to load the first two layers from disk, calculate the activations for all nodes, discard the first layer, load the third layer from disk, calculate all the activations for all nodes, discard the second layer etc? Then memory needs to be big enough to hold to 2 layers?
You don't have to do the loading/discarding explicitly. You could just mmap the entire network and let the os handle that.
Re: Llama2.c: Inference llama 2 in one file of pure C
#19Re: Llama2.c: Inference llama 2 in one file of pure C
#20To run a neural network, how much memory does one need? Is it enought to load the first two layers from disk, calculate the activations for all nodes, discard the first layer, load the third layer from disk, calculate all the activations for all nodes, discard the second layer etc? Then memory needs to be big enough to hold to 2 layers?
You don't have to do the loading/discarding explicitly. You could just mmap the entire network and let the os handle that.
Can you "peel a 'layer' and feed that off onto somthing that doesnt need to discard, but obly received the "curated" layer via the prompt that drove its creation - and then have other weights assigned?
Again - I am infant on this line of questions, so please educate me (the other me myselfs)