安装 torch 提示 Could not find a version that satisfies the requirement torch [from versions: none]
1.背景
大家好,我是 程序员码递夫。
现在DeepSeek很火,在人工智能时代,保持竞争力和不被淘汰的关键在于不断提升自己的核心能力,适应技术发展的趋势,并找到自己独特的价值定位。作为技术人员的我们,掌握AI相关工具和技术是很基本的要求。包括:
- 学习与人工智能相关的基础知识(如机器学习、数据科学、编程等)。
- 熟悉常用AI工具和平台(如Python、TensorFlow、PyTorch等),提升自己在技术领域的竞争力。
- 不需要成为专家,但至少要了解AI的基本原理和应用场景。
2.问题
最近看着一本开源的面向小白的书《Build.a.Large.Language.Model.From.Scratch》自学 LLM ,在跑书中的代码时,需要安装 pytorch, 但我在安装时却报错
ERROR: Could not find a version that satisfies the requirement torch (from versions: none)
ERROR: No matching distribution found for torch
大概的意思是 ,没有匹配版本得 torch可下载。
3.解决办法
把我原来安装的 python-3.13.1 删除,安装低一点的版本 python-3.12.8。 然后 根据 https://pytorch.org/get-started/locally/ 的建议运行安装命令,
我这里使用了 清华大学的镜像源,
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118 -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
安装成功,问题解决。