安装torch
直接使用conda install torch==1.12.0会报错,因为 Conda 通常使用 pytorch 作为包名(而非 torch)
正确使用方法:
conda install pytorch==1.12.0 -c pytorch
使用 pip 安装
pip install torch==1.12.0
在 Conda 中查看可安装的 PyTorch 版本,可以通过以下几种方法实现:
- 使用 conda search 查询
conda search pytorch -c pytorch
- 或指定更多渠道:
conda search pytorch -c pytorch -c conda-forge
# 例如:conda search pytorch -c pytorch -c pytorch
查看已安装版本
python -c "import torch; print(torch.__version__)"