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
428 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:

<code class="language-bash">sudo apt update && sudo apt -y upgrade</code>
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.

<code class="language-bash">python3 --version</code>
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.

<code class="language-bash">sudo apt install -y python3.12-venv</code>
Copy after login

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

<code class="language-bash">python3 -m venv venv</code>
Copy after login

Activate the virtual environment:

<code class="language-bash">source venv/bin/activate</code>
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).

<code class="language-bash">pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118</code>
Copy after login

Install JupyterLab:

<code class="language-bash">pip install jupyterlab</code>
Copy after login

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

<code class="language-bash">jupyter lab --notebook-dir /home/kai</code>
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!

source:php.cn
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