python安装pytorch@FreeBSD(失败)

2024-04-19 07:44

本文主要是介绍python安装pytorch@FreeBSD(失败),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

pip 安装

在FreeBSD系统下pip安装pytorch,报错

Building wheels for collected packages: pytorchBuilding wheel for pytorch (setup.py) ... errorerror: subprocess-exited-with-error× python setup.py bdist_wheel did not run successfully.│ exit code: 1╰─> [6 lines of output]Traceback (most recent call last):File "<string>", line 2, in <module>File "<pip-setuptools-caller>", line 34, in <module>File "/tmp/pip-install-08n_s_43/pytorch_94d503f93a464e71b575ea1cfef78bdc/setup.py", line 15, in <module>raise Exception(message)Exception: You tried to install "pytorch". The package named for PyTorch is "torch"[end of output]note: This error originates from a subprocess, and is likely not a problem with pip.ERROR: Failed building wheel for pytorchRunning setup.py clean for pytorch
Failed to build pytorch
ERROR: Could not build wheels for pytorch, which is required to install pyproject.toml-based projects

安装pyproject

 pip install pyproject

再pip 安装pytorch还是同样的报错:

Building wheels for collected packages: pytorch
  Building wheel for pytorch (setup.py) ... error
  error: subprocess-exited-with-error
 
  × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [6 lines of output]
      Traceback (most recent call last):
        File "<string>", line 2, in <module>
        File "<pip-setuptools-caller>", line 34, in <module>
        File "/tmp/pip-install-n_l8ufvy/pytorch_20c01d7c94e04917a97f282d03e31d92/setup.py", line 15, in <module>
          raise Exception(message)
      Exception: You tried to install "pytorch". The package named for PyTorch is "torch"
      [end of output]
 
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for pytorch

查找帮助说:

运行编译过程中出现错误,并提示“Too many arguments to functions call, expected....”的信息:

遇到这种情况时,该如何解决呢?解决方法是将属性“Enable Strict Checking of objc_msgSend Calls”的值设置成“No”,即TARGETS——>项目——>Build Settings——>Apple LLVM 6.0 - Preprocessing——>Enable Strict Checking of objc_msgSend Calls

pkg安装

到pkg里发现有现成的pytorch包,于是pkg 安装:pkg install pytorch

报错冲突:

Proceed with this action? [y/N]: y
[1/1] Fetching libdca-0.0.7_1.pkg: 100%  113 KiB 115.3kB/s    00:01    
Checking integrity... done (2 conflicting)- pytorch-2.2.1 conflicts with libfmt-10.2.1 on /usr/local/include/fmt/args.h- pytorch-2.2.1 conflicts with libfmt-10.2.1 on /usr/local/include/fmt/args.h
Cannot solve problem using SAT solver, trying another plan
Checking integrity... done (0 conflicting)
Conflicts with the existing packages have been found.
One more solver iteration is needed to resolve them.
The following 2 package(s) will be affected (of 0 checked):Installed packages to be UPGRADED:libdca: 0.0.7 -> 0.0.7_1Installed packages to be REINSTALLED:pkg-1.21.1Number of packages to be upgraded: 1
Number of packages to be reinstalled: 1Proceed with this action? [y/N]: 

根据提示,是pytorch和fmt文件冲突了。删除libfmt包试试

pkg remove libfmt

删除之后再安装pytorch,会自动再安装上libfmt并继续报冲突。

pip安装python39-pytorch包

pkg install py39-pytorch

安装好之后导入torch报错:

>>> import torch
Traceback (most recent call last):File "<stdin>", line 1, in <module>File "/usr/local/lib/python3.9/site-packages/torch/__init__.py", line 237, in <module>from torch._C import *  # noqa: F403
ImportError: /usr/local/lib/python3.9/site-packages/torch/lib/libtorch_cpu.so: Undefined symbol "_ZN4onnx7checker11check_modelERKNS_10ModelProtoEbbb"

源码编译安装

下载源代码

git clone --depth 2 https://github.com/pytorch/pytorch

设置环境变量

# 直接在终端中输入即可,重启需要重新输入
export USE_CUDA=0
export USE_DISTRIBUTED=0
export USE_MKLDNN=0
export MAX_JOBS=8

编译

cd pytorch
mkdir build
cd build
cmake ..
make -j 8

报错

--   Private Dependencies : Threads::Threads;cpuinfo;fbgemm;fp16;caffe2::openmp;foxi_loader;rt;fmt::fmt-header-only;kineto;dl
--   Public CUDA Deps.    :
--   Private CUDA Deps.   :
--   USE_COREML_DELEGATE     : OFF
--   BUILD_LAZY_TS_BACKEND   : ON
--   USE_ROCM_KERNEL_ASSERT : OFF
-- Configuring incomplete, errors occurred!

配置这里就没有过去。这个报错指向了这里

CMake Error at third_party/FP16/CMakeLists.txt:94 (ADD_SUBDIRECTORY):
  The source directory

    /home/skywalk/github/pytorch/third_party/psimd

  does not contain a CMakeLists.txt file.

原来psimd目录是空的啊,删除这个目录,然后执行:

third_party]$ git submodule update --init --recursive

问题解决。后面发现foxi 、 sleef目录也是空的,同样处理,先删除目录,再git submodule update

现在终于cmake成功了,然后make:

make install -j 8

编译到40%左右的时候报错

In file included from /home/skywalk/github/pytorch/aten/src/ATen/native/sparse/ValidateCompressedIndicesKernel.cpp:1:
/home/skywalk/github/pytorch/aten/src/ATen/native/sparse/ValidateCompressedIndicesCommon.h:93:9: error: too many arguments provided to function-like macro invocation"`0 <= crow_indices[..., 1:] - crow_indices[..., :-1] <= ncols` is not satisfied.");^
/usr/include/assert.h:52:9: note: macro '_assert' defined here
#define _assert(e)      ((void)0)^
In file included from /home/skywalk/github/pytorch/aten/src/ATen/native/sparse/ValidateCompressedIndicesKernel.cpp:1:
/home/skywalk/github/pytorch/aten/src/ATen/native/sparse/ValidateCompressedIndicesCommon.h:97:9: error: too many arguments provided to function-like macro invocation"`0 <= ccol_indices[..., 1:] - ccol_indices[..., :-1] <= nrows` is not satisfied.");^
/usr/include/assert.h:52:9: note: macro '_assert' defined here
#define _assert(e)      ((void)0)^
In file included from /home/skywalk/github/pytorch/aten/src/ATen/native/sparse/ValidateCompressedIndicesKernel.cpp:1:

更新源代码:

~/github/pytorch]$ git pull

还是这个报错

h:112:24: error: too many arguments provided to function-like macro invocation     _assert(invariant, "`0 <= row_indices < nrows` is not satisfied.");

改方法,python安装

python setup.py develop --cmake

报错:

[533/2242] Building CXX object c10/test/CMa.../c10_Scalar_test.dir/core/Scalar_test.cpp.o
FAILED: c10/test/CMakeFiles/c10_Scalar_test.dir/core/Scalar_test.cpp.o

又重新安装下,报错:

/usr/home/skywalk/github/pytorch/c10/test/core/Scalar_test.cpp:53:10: error: conversion from 'long long' to 'c10::Scalar' is ambiguous
  Scalar longlongOne = 1LL;
         ^             ~~~
/usr/home/skywalk/github/pytorch/c10/core/Scalar.h:59:7: note: candidate constructor
      DEFINE_IMPLICIT_CTOR)

ports 编译安装

 安装时会有一些库安装的比较慢,可以采取各种方法改进,比如手工下载文件然后放到/usr/ports/distfiles目录里。pkg手动安装一些依赖库,比如:

pkg install psimd
pkg install kineto
cd /usr/ports/misc/pytorch 
make install 
===>  Installing for pytorch-2.1.2
===>  Checking if pytorch is already installed
===>   Registering installation for pytorch-2.1.2
Installing pytorch-2.1.2...
pkg-static: pytorch-2.1.2 conflicts with libfmt-10.2.1 (installs files into the same place).  Problematic file: /usr/local/include/fmt/args.h
*** Error code 1Stop.
make[1]: stopped in /usr/ports/misc/pytorch
*** Error code 1

还是安装的时候报冲突

这篇关于python安装pytorch@FreeBSD(失败)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/916945

相关文章

Python中模块graphviz使用入门

《Python中模块graphviz使用入门》graphviz是一个用于创建和操作图形的Python库,本文主要介绍了Python中模块graphviz使用入门,具有一定的参考价值,感兴趣的可以了解一... 目录1.安装2. 基本用法2.1 输出图像格式2.2 图像style设置2.3 属性2.4 子图和聚

Python使用Matplotlib绘制3D曲面图详解

《Python使用Matplotlib绘制3D曲面图详解》:本文主要介绍Python使用Matplotlib绘制3D曲面图,在Python中,使用Matplotlib库绘制3D曲面图可以通过mpl... 目录准备工作绘制简单的 3D 曲面图绘制 3D 曲面图添加线框和透明度控制图形视角Matplotlib

一文教你Python如何快速精准抓取网页数据

《一文教你Python如何快速精准抓取网页数据》这篇文章主要为大家详细介绍了如何利用Python实现快速精准抓取网页数据,文中的示例代码简洁易懂,具有一定的借鉴价值,有需要的小伙伴可以了解下... 目录1. 准备工作2. 基础爬虫实现3. 高级功能扩展3.1 抓取文章详情3.2 保存数据到文件4. 完整示例

使用Python实现IP地址和端口状态检测与监控

《使用Python实现IP地址和端口状态检测与监控》在网络运维和服务器管理中,IP地址和端口的可用性监控是保障业务连续性的基础需求,本文将带你用Python从零打造一个高可用IP监控系统,感兴趣的小伙... 目录概述:为什么需要IP监控系统使用步骤说明1. 环境准备2. 系统部署3. 核心功能配置系统效果展

基于Python打造一个智能单词管理神器

《基于Python打造一个智能单词管理神器》这篇文章主要为大家详细介绍了如何使用Python打造一个智能单词管理神器,从查询到导出的一站式解决,感兴趣的小伙伴可以跟随小编一起学习一下... 目录1. 项目概述:为什么需要这个工具2. 环境搭建与快速入门2.1 环境要求2.2 首次运行配置3. 核心功能使用指

Python实现微信自动锁定工具

《Python实现微信自动锁定工具》在数字化办公时代,微信已成为职场沟通的重要工具,但临时离开时忘记锁屏可能导致敏感信息泄露,下面我们就来看看如何使用Python打造一个微信自动锁定工具吧... 目录引言:当微信隐私遇到自动化守护效果展示核心功能全景图技术亮点深度解析1. 无操作检测引擎2. 微信路径智能获

Python中pywin32 常用窗口操作的实现

《Python中pywin32常用窗口操作的实现》本文主要介绍了Python中pywin32常用窗口操作的实现,pywin32主要的作用是供Python开发者快速调用WindowsAPI的一个... 目录获取窗口句柄获取最前端窗口句柄获取指定坐标处的窗口根据窗口的完整标题匹配获取句柄根据窗口的类别匹配获取句

利用Python打造一个Excel记账模板

《利用Python打造一个Excel记账模板》这篇文章主要为大家详细介绍了如何使用Python打造一个超实用的Excel记账模板,可以帮助大家高效管理财务,迈向财富自由之路,感兴趣的小伙伴快跟随小编一... 目录设置预算百分比超支标红预警记账模板功能介绍基础记账预算管理可视化分析摸鱼时间理财法碎片时间利用财

Win安装MySQL8全过程

《Win安装MySQL8全过程》:本文主要介绍Win安装MySQL8全过程,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录Win安装mysql81、下载MySQL2、解压文件3、新建文件夹data,用于保存数据库数据文件4、在mysql根目录下新建文件my.ini

Python中的Walrus运算符分析示例详解

《Python中的Walrus运算符分析示例详解》Python中的Walrus运算符(:=)是Python3.8引入的一个新特性,允许在表达式中同时赋值和返回值,它的核心作用是减少重复计算,提升代码简... 目录1. 在循环中避免重复计算2. 在条件判断中同时赋值变量3. 在列表推导式或字典推导式中简化逻辑