mirror of
https://github.com/karpathy/llm.c.git
synced 2026-07-28 20:35:09 -04:00
Fix mem leak
This commit is contained in:
parent
a26041af12
commit
30d81cce15
1 changed files with 2 additions and 1 deletions
|
|
@ -2554,7 +2554,7 @@ void gpt2_backward(GPT2 *model, int* inputs) {
|
|||
model->grads_memory = malloc_and_point_parameters(&model->grads, model->param_elements, model->param_sizeof);
|
||||
// we're going to be clever for the activations backward pass. we don't need to exactly
|
||||
// mirror the forward pass activations and we will save memory.
|
||||
size_t bw_act_sizes[NUM_ACTIVATION_TENSORS];
|
||||
size_t bw_act_sizes[NUM_BACKWARD_TENSORS];
|
||||
fill_in_grad_act_sizes(bw_act_sizes, model->batch_size, model->seq_len, model->config);
|
||||
// count up and allocate the space
|
||||
model->num_grad_acts = 0;
|
||||
|
|
@ -2985,6 +2985,7 @@ void load_state(int* step, GPT2* model, DataLoader* loader, const char* filename
|
|||
cudaCheck(cudaMemcpy(model->m_memory, cpu_buffer, shard_num_parameters * sizeof(float), cudaMemcpyHostToDevice));
|
||||
freadCheck(cpu_buffer, sizeof(float), shard_num_parameters, state_file);
|
||||
cudaCheck(cudaMemcpy(model->v_memory, cpu_buffer, shard_num_parameters * sizeof(float), cudaMemcpyHostToDevice));
|
||||
free(cpu_buffer);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue