Home > Backend Development > Python Tutorial > Install PyTorch and JupyterLab on Ubuntu

Install PyTorch and JupyterLab on Ubuntu

Mary-Kate Olsen
Release: 2025-01-12 12:09:43
Original
459 people have browsed it

Let's get you set up with PyTorch and JupyterLab on Ubuntu! This guide provides a streamlined approach to installing and configuring everything you need.

First, ensure your Ubuntu system is up-to-date:

sudo apt update && sudo apt -y upgrade
Copy after login

Check your Python version. Note the version number (e.g., 3.13.x) as it will be needed in the next step.

python3 --version
Copy after login

Install the appropriate python3.xx-venv package, matching your Python version. If your Python version is 3.13.x, replace 3.12 below with 3.13.

sudo apt install -y python3.12-venv
Copy after login

Create a virtual environment (this keeps your project dependencies separate):

python3 -m venv venv
Copy after login

Activate the virtual environment:

source venv/bin/activate
Copy after login

Install PyTorch with CUDA 11.8 support. (Remember to adjust cu118 if you're using a different CUDA version or a CPU-only build; see the PyTorch website for options).

pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
Copy after login

Install JupyterLab:

pip install jupyterlab
Copy after login

Launch JupyterLab, optionally specifying your working directory. Replacing /home/kai with your desired directory.

jupyter lab --notebook-dir /home/kai
Copy after login

Install PyTorch and JupyterLab on Ubuntu

You're all set! Open your preferred web browser (like Firefox) and navigate to the URL JupyterLab provides in your terminal to begin working. Remember to deactivate the virtual environment when you're finished using deactivate.

The above is the detailed content of Install PyTorch and JupyterLab on Ubuntu. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template