Instale PyTorch y compruebe que se importa
Ejecute pip install torch y una comprobación de funcionamiento de una línea
Instale PyTorch y compruebe que se importa es una lección gratuita de Deep Learning Academy en CoddyKit. Esta es la lección 1 de 4. Puedes leer la lección completa abajo gratuitamente — luego la practicas en el navegador con un editor de código integrado y un tutor de IA 24/7. Forma parte de la ruta de aprendizaje de Deep Learning Academy, y tu progreso se sincroniza en la web y la app de CoddyKit. El curso de Deep Learning Academy incluye 4 lecciones en total.
Partes de esta lección aún no han sido traducidas y se muestran en inglés.
Why PyTorch First
Before you train anything, you need a toolkit. PyTorch is the library you will use to build and train every model in this course. 🔧
It's Just a Python Package
PyTorch installs like any other Python package, so you grab it with pip. No special compiler or magic setup is needed to get started.
The Install Command
This single pip install line pulls down PyTorch and its companion packages so your environment is ready to build models.
pip install torch torchvision torchaudioWhat torchvision Adds
The torchvision package ships datasets, image transforms, and pretrained models, so you rarely start an image project from scratch.
Import It in Code
Once installed, you bring PyTorch into any script with one line. The convention is to import torch and use it directly, no alias needed.
import torchThe One-Line Sanity Check
To prove the install worked, print the version. If a number appears instead of an error, PyTorch is alive and ready.
import torch
print(torch.__version__)Reading the Version
A version like 2.3.0 means a successful install. The first number is the major version, which signals big, sometimes breaking, changes.
When Import Fails
A ModuleNotFoundError means Python cannot find torch. Usually you installed into a different environment than the one running your code.
Use a Virtual Environment
A virtual environment keeps PyTorch and its versions isolated per project, so one upgrade never breaks another app on your machine.
python -m venv .venvActivate, Then Install
Always activate the environment before you pip install, so the package lands where your scripts will actually look for it.
source .venv/bin/activateCPU Build Is Enough for Now
The default CPU build runs everything in this course. You only need a GPU-specific install later, once your models grow larger.
Quick Check
Let's confirm you know the fastest way to test the install.
Recap
You installed PyTorch with pip in a virtual environment and confirmed it works by printing its version. Your workshop is open for business. 🎉
Preguntas frecuentes
¿La lección «Instale PyTorch y compruebe que se importa» es gratis?
Sí — el texto completo de «Instale PyTorch y compruebe que se importa» es gratis para leer aquí en la web. Para practicarla de forma interactiva (editor de código integrado y tutor de IA 24/7) y desbloquear el resto del curso de Deep Learning Academy, actualiza a CoddyKit PRO. El curso de Deep Learning Academy incluye 4 lecciones en total.
¿Qué aprenderé en «Instale PyTorch y compruebe que se importa»?
Ejecute pip install torch y una comprobación de funcionamiento de una línea Practicas Deep Learning Academy con código real que ejecutas directamente en el navegador, y un tutor de IA 24/7 responde tus preguntas mientras trabajas en la lección.
¿Necesito experiencia previa para empezar Deep Learning Academy?
No se requiere experiencia previa. Deep Learning Academy en CoddyKit está estructurado para principiantes hasta estudiantes avanzados, así que puedes empezar aquí o desde el inicio y avanzar a tu ritmo. Esta es la lección 1 de 4.
¿Cuánto tiempo toma la lección «Instale PyTorch y compruebe que se importa»?
La mayoría de las lecciones de CoddyKit toman alrededor de 5–10 minutos. Cada una es compacta e interactiva, así que avanzas constantemente y retomas exactamente por donde dejaste en la web y la app.
¿Puedo escribir y ejecutar código en esta lección de Deep Learning Academy?
Sí. Cada lección de Deep Learning Academy incluye un editor de código integrado, así que escribes y ejecutas código real directamente en tu navegador y obtienes retroalimentación instantánea de IA — sin configuración local necesaria.
Todas las lecciones de este curso
- Instale PyTorch y compruebe que se importa
- CPU frente a GPU frente a MPS: elija un dispositivo
- Notebooks, scripts y semillas reproducibles
- Su primer torch.tensor