#Trying to backward through the graph a second time (or directly access saved tensors after they have

1 messages · Page 1 of 1 (latest)

frigid groveBOT
#

This error ("Trying to backward through the graph a second time (or directly access saved tensors after they have already been freed)") is commonly caused by incompatibilities between Unsloth, transformers, and PyTorch versions, or by issues with gradient checkpointing and use_cache settings. Updating Unsloth and unsloth_zoo to the latest versions and ensuring transformers is compatible often resolves it. Also, make sure use_cache=False when using gradient checkpointing, as required by Unsloth's implementation for long context models like Llama-3.2-11B-Vision-Instruct-bnb-4bit. If the error persists, try reinstalling Unsloth and unsloth_zoo with --force-reinstall and --upgrade flags, and restart your environment before running your code again.

For more details and troubleshooting steps, see the guidance and solutions in these issues: Unsloth Issue #2866, Unsloth Issue #2434, and Unsloth Issue #2841. Would you like a step-by-step breakdown or code example for updating and configuring your environment?

Sources:

echo kraken
#
        output_dir=output_dir,
        max_steps=max_steps,
        per_device_train_batch_size=batch_size,
        gradient_accumulation_steps=8,
        warmup_steps=10,
        learning_rate=1e-4,
        logging_steps=10,
        optim="adamw_8bit",
        weight_decay=0.01,
        lr_scheduler_type="linear",
        seed=seed,
        bf16=dtype == torch.bfloat16,
        fp16=dtype == torch.float16,
        save_strategy="steps",
        save_steps=50,
        save_total_limit=2,
        report_to="none",

        remove_unused_columns=False,
        dataset_text_field="",
        dataset_kwargs={"skip_prepare_dataset": True},
        max_length=max_seq_length,
        
        dataloader_num_workers=0,
    )```
echo kraken
#

HELP ME PLEASE

echo kraken
frigid groveBOT
#

Your error is likely due to a mismatch between gradient checkpointing and use_cache settings, or an incompatibility between Unsloth, transformers, and PyTorch versions. For Llama-3.2-11B-Vision-Instruct-bnb-4bit, ensure you set model.config.use_cache = False before training, and that your Unsloth, unsloth_zoo, and transformers versions are all up to date and compatible. Restart your environment after upgrading.

If the problem persists, see Unsloth Issue #2866 and Unsloth Issue #2434 for more troubleshooting. Would you like a step-by-step guide to check and fix your setup?

Sources: