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
Check your Python version. Note the version number (e.g., 3.13.x) as it will be needed in the next step.
python3 --version
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
Create a virtual environment (this keeps your project dependencies separate):
python3 -m venv venv
Activate the virtual environment:
source venv/bin/activate
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
Install JupyterLab:
pip install jupyterlab
Launch JupyterLab, optionally specifying your working directory. Replacing /home/kai
with your desired directory.
jupyter lab --notebook-dir /home/kai
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!