溫馨提示×

Debian下PyTorch的安裝教程有哪些

小樊
39
2025-08-26 10:52:47
欄目: 智能運維

以下是在Debian下安裝PyTorch的教程:

使用pip安裝

  1. 更新系統包列表sudo apt update。
  2. 安裝Python和pipsudo apt install python3 python3-pip。
  3. 安裝PyTorch
    • CPU版本pip3 install torch torchvision torchaudio。
    • GPU版本:先安裝對應CUDA和cuDNN,再執行pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu<cuda_version>,如pip3 install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu117(CUDA 11.7版本)。

使用conda安裝

  1. 安裝Miniconda:從官網下載安裝包安裝,如bash Miniconda3-latest-Linux-x86_64.sh。
  2. 創建并激活環境conda create -n pytorch_env python=3.9,conda activate pytorch_env。
  3. 安裝PyTorch
    • CPU版本conda install pytorch torchvision torchaudio cpuonly -c pytorch。
    • GPU版本conda install pytorch torchvision torchaudio cudatoolkit=<cuda_version> -c pytorch,如conda install pytorch torchvision torchaudio cudatoolkit=11.7 -c pytorch(CUDA 11.7版本)。

安裝完成后,可通過import torch,print(torch.__version__),print(torch.cuda.is_available())驗證安裝是否成功。

0
亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女