Pixiv - KiraraShss
139 字
1 分钟
安装pytorch
## 使用conda创建环境
conda create -n torch python=3.12
进入环境
conda activate pytorch
安装
打开 https://pytorch.org/get-started/locally/ 官网地址,根据自己的电脑环境需要指定版本,mac的话,直接安装默认版本就行,win、linux有显卡的话,一定得安装显卡版本
mac的命令
pip install torch torchvision
win
pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu129
仅供参考,具体在官网查看
测试
mac测试
import torchtorch.__version__torch.device("mps")正常输出mps代表安装正确 没有win,一般是
import torchtorch.cuda.is_available()可以看到cuda的话,一般是正确的
最后更新于 2025-12-09,距今已过 1 天
部分内容可能已过时