{ "cells": [ { "cell_type": "code", "execution_count": 1, "id": "b00dbc42", "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "[XPU] Cache cleared and peak memory stats reset.\n" ] } ], "source": [ "import torch\n", "\n", "def clean_device_memory():\n", " if torch.xpu.is_available():\n", " torch.xpu.empty_cache()\n", " torch.xpu.reset_peak_memory_stats()\n", " print(\"[XPU] Cache cleared and peak memory stats reset.\")\n", " elif torch.cuda.is_available():\n", " torch.cuda.empty_cache()\n", " torch.cuda.reset_peak_memory_stats()\n", " print(\"[CUDA] Cache cleared and peak memory stats reset.\")\n", " else:\n", " print(\"No XPU or CUDA device found.\")\n", "\n", "if __name__ == '__main__':\n", " clean_device_memory()\n" ] }, { "cell_type": "code", "execution_count": 2, "id": "598b91f6", "metadata": {}, "outputs": [ { "name": "stderr", "output_type": "stream", "text": [ "c:\\Python310\\lib\\site-packages\\tqdm\\auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n", " from .autonotebook import tqdm as notebook_tqdm\n" ] }, { "name": "stdout", "output_type": "stream", "text": [ "\n", "--- Starting ViT Training with Larger Batch Size ---\n", "Using device: xpu with batch size: 16\n", "Torch version: 2.7.0+xpu\n", "Current XPU memory allocated: 0.0 MB\n", "Max XPU memory allocated: 0.0 MB\n", "\n", "[1/4] Loading dataset...\n", "[DEBUG] Found 10676 real images\n", "[DEBUG] Found 76182 fake images\n", "[DEBUG] Using 10676 samples per class (balanced)\n", "[DEBUG] Final dataset size: 21352 samples\n", "[DEBUG] Batch size: 16 | Total batches: 1335\n", "\n", "[2/4] Initializing model...\n", "\n", "[Memory] Allocated: 327.30 MB | Reserved: 382.00 MB | Max: 327.30 MB\n", "\n", "[3/4] Starting training...\n", "\n", "[Epoch 1/10]\n" ] }, { "name": "stderr", "output_type": "stream", "text": [ "Training: 0%| | 0/1335 [00:00