服务器安装pytorch-阿里云-centos7

原文阅读:【巨人肩膀社区·专栏·分享】服务器安装pytorch-阿里云-centos7

1、创建一个虚拟环境

复制代码
conda create -n pytorch python=3.10

安装成功:

但是使用上面的命令会失败(疑问?),使用下面的这个可以:

复制代码
source activate pytorch

如果版本太高会报这个错:

复制代码
Collecting package metadata (current_repodata.json): done
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.
Collecting package metadata (repodata.json): done
Solving environment: failed

PackagesNotFoundError: The following packages are not available from current channels:

  - python=3.12.5

Current channels:

  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/noarch
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/linux-64
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r/noarch
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/linux-64
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

2、配置安装PyTorch命令

PyTorch

复制代码
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cpu -i https://mirrors.bfsu.edu.cn/pypi/web/simple --trusted-host mirrors.bfsu.edu.cn

其中-i https://mirrors.bfsu.edu.cn/pypi/web/simple --trusted-host mirrors.bfsu.edu.cn是临时切换pip3下载源,其他部分都是从PyTorch官网配置后复制的。

安装成功截图:

3、验证pip3 list

复制代码
import torch
print(torch.__version__)

成功打印出了版本号就说明安装成功啦。

相关推荐
糖炒栗子03262 分钟前
让 AI 在大项目中做修改的标准操作模板
人工智能
oioihoii3 分钟前
大模型输出的“隐性结构塌缩”问题及对策
人工智能
TechMasterPlus3 分钟前
Harness Engineer:把 AI 变成可复用工程能力的实践指南
大数据·人工智能
AI工具测评与分析5 分钟前
红仿大师功能波动致歉说明!手把手教程 + 备用工具一次配齐
人工智能·玫瑰克隆·红仿大师
OpenBayes贝式计算8 分钟前
一键移除复杂物体!Netflix VOID 让视频消除拥有「物理直觉」;告别乱码与解析难题,MDPBench 数据集为「真实复杂场景」文档解析而生
人工智能·机器学习·图像识别
搬砖的小明202610 分钟前
Google BwA 杭州场(Gemma 4 专题全国首发)线下活动记录
人工智能
向量引擎12 分钟前
向量引擎中转站偷走我半条命后终于把API密钥这件事整明白了
人工智能·aigc·api·ai编程·ai写作·key·api调用
龙萱坤诺14 分钟前
智创聚合API上线 Claude Opus 4.7,编码与多模态能力全面拉满
人工智能·ai编程·claude·ai开发
沪漂阿龙14 分钟前
深度拆解LangChain Chains与LCEL:从Runnable到生产级AI工作流
人工智能·langchain
大模型RAG和Agent技术实践15 分钟前
项目实战:深入剖析 Dify 知识库管理系统的 RBAC 权限设计与实现
人工智能·dify·rag