{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "import os\n", "#!pip install torch torchvision torchaudio\n", "import torch\n", "import torch.nn as nn\n", "import torch.optim as optim\n", "from torchvision import datasets, transforms, models\n", "from torch.utils.data import DataLoader\n", "from sklearn.metrics import accuracy_score\n", "import matplotlib.pyplot as plt\n" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CUDA não disponível. Treinando na CPU.\n" ] } ], "source": [ "import torch\n", "if torch.cuda.is_available():\n", " print(\"CUDA disponível. Treinando na GPU.\")\n", " device = torch.device(\"cuda\")\n", "else:\n", " print(\"CUDA não disponível. Treinando na CPU.\")\n", " device = torch.device(\"cpu\")" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Using device: cpu\n" ] } ], "source": [ "device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n", "print(f\"Using device: {device}\")\n" ] } ], "metadata": { "kernelspec": { "display_name": "base", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.11.4" } }, "nbformat": 4, "nbformat_minor": 2 }