1. Prerequisite

python -V && conda --version

Python 3.12.3
conda 24.4.0

2. Conda Jupyter

# PyTorch 2.3.0 Windows Pip Python Cpu

conda create --name PyTorch -y

# conda deactivate
conda activate PyTorch

conda install jupyter ipykernel numpy pandas matplotlib -y

# 安装失败可打开新的终端,激活PyTorch后再次安装
python -m ipykernel install --user --name=PyTorch --display-name="Python PyTorch"

jupyter lab

http://127.0.0.1:12345/lab - elf

3. PyTorch Setup

  • 新建新的Notebook ☞ Select Kernel ☞ Python PyTorch

pip install torch torchvision torchaudio

4. Verification

import torch
x = torch.rand(5, 3)
print(x)

tensor([[0.1451, 0.2234, 0.2921],
        [0.9588, 0.8812, 0.3632],
        [0.3914, 0.4284, 0.6742],
        [0.4222, 0.6802, 0.2450],
        [0.8489, 0.5821, 0.5507]])
import torch
torch.cuda.is_available()

False