在Arm/Linux下安装python的pytorch库

部署运行你感兴趣的模型镜像

在Arm/Linux下安装python的pytorch库

通过pip安装torch库,报以下错误。

nvidia@nx:~/pengjing/pytorch_packget$ sudo pip3 install torch
The directory '/home/nvidia/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/nvidia/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting torch
  Could not find a version that satisfies the requirement torch (from versions: )
No matching distribution found for torch

根据最终找到的解决办法,问题可能出在pip的版本较低。导致无法自动安装 torch 库。

分析问题过程:

搜索到相关链接
arm64下安装pytorch,torchvision,torchaudio以及它们之间的版本对应关系

根据该文档的要求的步骤一步步做,下载好torch-1.11.0-cp38-cp38-manylinux2014_aarch64.whl与torchvision-0.12.0-cp38-cp38-manylinux2014_aarch64.whl文件,并进行pip安装时,报以下错误:

nvidia@nx:~/pengjing/pytorch_packget$ sudo pip3 install torch-1.11.0-cp37-cp37m-manylinux2014_aarch64.whl 
The directory '/home/nvidia/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/nvidia/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
torch-1.11.0-cp37-cp37m-manylinux2014_aarch64.whl is not a supported wheel on this platform.

提示说该轮子不被该平台支持。

做到这,我就纳闷了,明明是aarch64架构python轮子,为什么说不被支持呢? 我想这个包肯定是没什么问题,并且可以用于ARM平台上,应该是漏掉了什么。

想到这我,我就去 torch-1.11.0-cp37-cp37m-manylinux2014_aarch64.whl 这个库的下载地址,找寻线索,希望能够找到背后的原因。

在这个下载地址页面,我看到了这样一句话

Download the file for your platform. If you’re not sure which to choose, learn more about installing packages.

哈哈,这不就是我当前遇到的问题嘛,随即进入 installing packages.这个链接。

其实进到这个页面,也摸不到方向,但可以肯定的是问题可以在这个页面里搜索到解决方案,以及问题背后的原因

然后我又看了看这个库文件名称 torch-1.11.0-cp37-cp37m-manylinux2014_aarch64.whl(因为库文件名称往往对应于被支持平台的信息);其中有关键字:cp37、cp37m、manylinux2014、aarch64。

cp37、cp37m:python3.7版本
aarch64:库运行平台架构。这个可以通过 uname -a 命令可以看出linux平台架构(核对过,是aarch64架构)
manylinux2014:这个关键字目前还不知道含义。

随即进入 installing packages 检索(右上角搜索框) manylinux2014 的含义,检索出如下内容:
Manylinux compatibility support
哈哈,看到没,这个manylinux2014是要求pip >=19.3、auditwheel>=3.0.0。我马上通过 pip3 -V或者pip3 show pip看了下自己pip的版本。
在这里插入图片描述
瞬间发现我的pip版本原来是9.0.1,不能满足 manylinux2014 的要求。解决办法显而易见就是:更新 pip 版本

pip是一个python的包管理工具,实际上它也可以被看待为是一个包。而且可以通过vi /usr/bin/pip 编辑pip所代表的python版本
在这里插入图片描述

解决过程:

参考文章:
使用Python pip怎么升级pip

  1. 更新pip
python3.7 -m pip install --upgrade pip

2.查看pip版本

pip3 show pip

3.安装torch库

sudo pip3 install torch-1.11.0-cp38-cp38-manylinux2014_aarch64.whl
sudo pip3 install torchvision-0.12.0-cp38-cp38-manylinux2014_aarch64.whl
sudo pip3 install torchaudio

4.结果顺利安装成功在这里插入图片描述

您可能感兴趣的与本文相关的镜像

PyTorch 2.5

PyTorch 2.5

PyTorch
Cuda

PyTorch 是一个开源的 Python 机器学习库,基于 Torch 库,底层由 C++ 实现,应用于人工智能领域,如计算机视觉和自然语言处理

WARNING: Redirecting 'python setup.py install' to 'pip install . -v --no-build-isolation', for more info see https://github.com/pytorch/pytorch/issues/152276 Using pip 22.0.2 from /home/re/桌面/pytorch_env/pytorch_env/lib/python3.10/site-packages/pip (python 3.10) Processing /home/re/桌面/pytorch_env/pytorch-cross/pytorch Running command Preparing metadata (pyproject.toml) Building wheel torch-2.10.0a0+gitab5086a Found cmake (/home/re/桌面/pytorch_env/pytorch_env/bin/cmake) version: 4.1.0 (>=3.27) /home/re/桌面/pytorch_env/pytorch_env/lib/python3.10/site-packages/setuptools/config/_apply_pyprojecttoml.py:82: SetuptoolsDeprecationWarning: `project.license` as a TOML table is deprecated !! ******************************************************************************** Please use a simple string containing a SPDX expression for `project.license`. You can also use `project.license-files`. (Both options available on setuptools>=77.0.0). By 2026-Feb-18, you need to update your project and remove deprecated calls or your builds will no longer be supported. See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#license for details. ******************************************************************************** !! corresp(dist, value, root_dir) running dist_info creating /tmp/pip-modern-metadata-6sj6v5ya/torch.egg-info writing /tmp/pip-modern-metadata-6sj6v5ya/torch.egg-info/PKG-INFO writing dependency_links to /tmp/pip-modern-metadata-6sj6v5ya/torch.egg-info/dependency_links.txt writing entry points to /tmp/pip-modern-metadata-6sj6v5ya/torch.egg-info/entry_points.txt writing requirements to /tmp/pip-modern-metadata-6sj6v5ya/torch.egg-info/requires.txt writing top-level names to /tmp/pip-modern-metadata-6sj6v5ya/torch.egg-info/top_level.txt writing manifest file '/tmp/pip-modern-metadata-6sj6v5ya/torch.egg-info/SOURCES.txt' reading manifest file '/tmp/pip-modern-metadata-6sj6v5ya/torch.egg-info/SOURCES.txt' reading manifest template 'MANIFEST.in' warning: no files found matching 'BUILD' warning: no files found matching '*.BUILD' warning: no files found matching 'BUCK' warning: no files found matching '[Mm]akefile.*' warning: no files found matching '*.[Dd]ockerfile' warning: no files found matching '[Dd]ockerfile.*' warning: no previously-included files matching '*.o' found anywhere in distribution warning: no previously-included files matching '*.obj' found anywhere in distribution warning: no previously-included files matching '*.so' found anywhere in distribution warning: no previously-included files matching '*.a' found anywhere in distribution warning: no previously-included files matching '*.dylib' found anywhere in distribution warning: no previously-included files matching '*.pxd' found anywhere in distribution warning: no previously-included files matching '*.dll' found anywhere in distribution warning: no previously-included files matching '*.lib' found anywhere in distribution no previously-included directories found matching '*/.git' warning: no previously-included files matching '*~' found anywhere in distribution warning: no previously-included files matching '*.swp' found anywhere in distribution adding license file 'LICENSE' adding license file 'NOTICE' writing manifest file '/tmp/pip-modern-metadata-6sj6v5ya/torch.egg-info/SOURCES.txt' creating '/tmp/pip-modern-metadata-6sj6v5ya/torch-2.10.0a0+gitab5086a.dist-info' Preparing metadata (pyproject.toml) ... done Requirement already satisfied: typing-extensions>=4.10.0 in /home/re/桌面/pytorch_env/pytorch_env/lib/python3.10/site-packages (from torch==2.10.0a0+gitab5086a) (4.15.0) Requirement already satisfied: filelock in /home/re/桌面/pytorch_env/pytorch_env/lib/python3.10/site-packages (from torch==2.10.0a0+gitab5086a) (3.13.1) Requirement already satisfied: sympy>=1.13.3 in /home/re/桌面/pytorch_env/pytorch_env/lib/python3.10/site-packages (from torch==2.10.0a0+gitab5086a) (1.13.3) Requirement already satisfied: fsspec>=0.8.5 in /home/re/桌面/pytorch_env/pytorch_env/lib/python3.10/site-packages (from torch==2.10.0a0+gitab5086a) (2024.6.1) Requirement already satisfied: networkx>=2.5.1 in /home/re/桌面/pytorch_env/pytorch_env/lib/python3.10/site-packages (from torch==2.10.0a0+gitab5086a) (3.3) Requirement already satisfied: jinja2 in /home/re/桌面/pytorch_env/pytorch_env/lib/python3.10/site-packages (from torch==2.10.0a0+gitab5086a) (3.1.4) Requirement already satisfied: mpmath<1.4,>=1.1.0 in /home/re/桌面/pytorch_env/pytorch_env/lib/python3.10/site-packages (from sympy>=1.13.3->torch==2.10.0a0+gitab5086a) (1.3.0) Requirement already satisfied: MarkupSafe>=2.0 in /home/re/桌面/pytorch_env/pytorch_env/lib/python3.10/site-packages (from jinja2->torch==2.10.0a0+gitab5086a) (2.1.5) Building wheels for collected packages: torch Running command Building wheel for torch (pyproject.toml) Building wheel torch-2.10.0a0+gitab5086a Found cmake (/home/re/桌面/pytorch_env/pytorch_env/bin/cmake) version: 4.1.0 (>=3.27) -- Building version 2.10.0a0+gitab5086a Could not find any of CMakeLists.txt, Makefile, setup.py, LICENSE, LICENSE.md, LICENSE.txt in /home/re/桌面/pytorch_env/pytorch-cross/pytorch/third_party/pybind11 Did you run 'git submodule update --init --recursive'? error: subprocess-exited-with-error × Building wheel for torch (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> See above for output. note: This error originates from a subprocess, and is likely not a problem with pip. full command: '/home/re/桌面/pytorch_env/pytorch_env/bin/python3' '/home/re/桌面/pytorch_env/pytorch_env/lib/python3.10/site-packages/pip/_vendor/pep517/in_process/_in_process.py' build_wheel /tmp/tmpjhyiej6r cwd: /home/re/桌面/pytorch_env/pytorch-cross/pytorch Building wheel for torch (pyproject.toml) ... error ERROR: Failed building wheel for torch Failed to build torch ERROR: Could not build wheels for torch, which is required to install pyproject.toml-based projects
09-23
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值