服务器安装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__)

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

相关推荐
Ki13813 分钟前
我的AI学习小结:从入门到放弃
人工智能·学习
迪三达5 分钟前
智能体交易员 - AI-Trader
人工智能
dog25012 分钟前
LLM(大语言模型)和高尔顿板
人工智能·语言模型·自然语言处理·高尔顿板
LaughingZhu22 分钟前
Product Hunt 每日热榜 | 2025-12-13
人工智能·经验分享·神经网络·搜索引擎·产品运营
Hello娃的22 分钟前
【量子力学】Hohenberg-Kohn 定理
人工智能·算法
学好statistics和DS28 分钟前
机器学习中所有可以调整的超参数(考试/自己调参用)
人工智能·机器学习
老马啸西风29 分钟前
成熟企业级技术平台 MVE-010-IGA(Identity Governance & Administration,身份治理与管理)平台
人工智能·深度学习·算法·职场和发展
老马啸西风42 分钟前
成熟企业级技术平台 MVE-010-app 管理平台
人工智能·深度学习·算法·职场和发展
●VON44 分钟前
小V健身助手开发手记(四):打造专属健康空间——以 PersonContent构建统一风格的个人中心
人工智能·学习·openharmony·开源鸿蒙·von