python arm64_PyTorch-aarch64

2023-05-16

PyTorch源码编译步骤:

1、源码编译环境:

操作系统:debian 9.12

交换空间:1G

Python版本:3.5

硬件:

CPU:RK3399(aarch64)

内存:4G

2、下载依赖包:

下载pytorch及其依赖包时,默认从github上下载,如果网络不好、容易断开时,可在gitee上找到对应包克隆链接,然后修改对应配置文件,进行下载。需要细致耐心。

3、编译主要参数:

设置最大作业数:

export MAX_JOBS=3

pytorch,无cude、无MKL:

export NO_CUDA=1 export NO_DISTRIBUTED=1 export NO_MKLDNN=1 export NO_NNPACK=1 export NO_QNNPACK=1

torchvision源码编译步骤:

1、安装环境依赖:

sudo apt-get install libjpeg-dev zlib1g-dev

2、下载源代码:

git clone -b v0.5.0 https://github.com/pytorch/vision.git torchvision

或者:git clone -b v0.5.0 https://gitee.com/mirrors/vision.git torchvision

3、源码编译:

cd torchvision

python3 setup.py build

编译过程中应该出现错误,据说是python3.5的bug。参考链接:https://blog.csdn.net/Jessie_show/article/details/108280251

错误详情:

File /usr/lib/python3.5/weakref.py, line 117, in remove

TypeError: NoneType object is not callable

解决方式,修改weakref.py文件:

找到“def remove(wr, selfref=ref(self)):”这一行

并将之修改为:“def remove(wr, selfref=ref(self), _atomic_removal=_remove_dead_weakref):”

找到“_remove_dead_weakref(d, wr.key)”这一行

并将之修改为:“_atomic_removal(d, wr.key)”

4、生成wheel:

python3 setup.py bdist_wheel

此时dist/目录下得到whl包:torchvision-0.5.0a0+85b8fbf-cp35-cp35m-linux_aarch64.whl

其他:

1、PyTorch .whl for generic aarch64 platforms

Just download the file or clone the repository, and install the wheel using pip.

pip3 install torch-1.1.0a0+472be69-cp36-cp36m-linux_aarch64.whl

2、Rationale

I wanted to run some PyTorch models on my Ultra96 board for eventual use in Xilinx/Deephi's DNNDK platofrm, which allows you to tkae a trained model and speed up inference using the DPU in the programmable logic of the ZU+ device.

3、Build Instructions

In case you you have a differnt version of python, or any other reason you might have to build it yourself, ill describe the steps below.

4、Memory Considerations

The biggest challenge building a large library like this on an embeedde device is the limitaion of RAM (Ultra96 has 2GB). To combat this, you could make some extra swap space, or you could limit jobs the number of jobs used when building. I would recommned making sure you have at least 1GB swap and limiting the jobs to 1, as just using a lot of swap will slow things to a standstill if you dont have lightning fast swap.

I had a spare 2GB USB2 flash drive which would work perfectly, so I used that as my extra swap. Make sure to change the /dev/sda1 to your device, and make sure its not mounted when you start this process.

First, make the swap space sudo mkswap /dev/sda1

edit your fstab to include the new drive. nano /etc/fstab, comment out any lines you see (replace them once you are done) and add /dev/sda1 swap swap at the top of the file.

Turn on the new swap space sudo swapon -p 32767 /dev/sda1

Check it worked using cat /proc/swaps and seeing if your drive is listed.

Finally, set the max number of jobs. I did 1 to be safe, but if you want it to go faster you could try 2.

export MAX_JOBS=1

5、download dependencies and clone PyTorch

Dependencies:

sudo apt install libopenblas-dev libblas-dev m4 cmake cython python3-dev python3-yaml python3-setuptools

Clone PyTorch:

git clone --recursive https://github.com/pytorch/pytorch and cd pytorch

Set build options for embeeded machine (no cude, no MKL, etc)

export NO_CUDA=1 export NO_DISTRIBUTED=1 export NO_MKLDNN=1 export NO_NNPACK=1 export NO_QNNPACK=1

and finally, run the build.

python3 setup.py build

Once it completes with no errors, you can run python3 setup.py install to install the files, and if you are reading this in the future with an updated version, you can also run python3 setup.py bdist_wheel to create a whl file for distribution. That command will put the generated .whl file in the newly created dist directory.

Now you can run torch!

cd python3 import torch

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

python arm64_PyTorch-aarch64 的相关文章

  • python sys.path 故障排除

    python 文档位于http docs python org library sys html http docs python org library sys html比如说sys path is 从环境变量 PYTHONPATH 以及
  • 当我有自定义身份验证模型时,如何登录 Django Rest 可浏览 API?

    我有一个自定义用户模型 如下所示account models py from django contrib auth modles import AbstractUser from django db models signals impo
  • 使用 django-rest-framework 设置对象级权限

    尝试使用 django rest framework 最干净 最规范地管理 django guardian 对象级权限 我想将对象的读取权限 module view object 分配给在执行 POST 时发出请求的用户 我的基于阶级的观点
  • 如何通过 python 多处理利用所有核心

    我一直在摆弄Python的multiprocessing现在已经使用了一个多小时的功能 尝试使用并行化相当复杂的图形遍历函数multiprocessing Process and multiprocessing Manager import
  • 协程从未被等待

    我正在使用一个简单的上下文管理器 其中包含一个异步循环 class Runner def init self self loop asyncio get event loop def enter self return self def e
  • Arcpy 模数在 Pycharm 中不显示

    如何将 Arcpy 集成到 Pycharm 中 我尝试通过导入模块但它没有显示 我确实知道该模块仅适用于 2 x python arcpy 在 PyPi Python 包索引 上不可用 因此无法通过 pip 安装 要使用 arcpy 您需要
  • Python Anaconda:如何测试更新的库是否与我现有的代码兼容?

    我在 Windows 7 机器上使用 Python 2 7 Anaconda 安装进行数据分析和科学计算 当新的库发布时 例如新版本的 pandas patsy 等 您建议我如何测试新版本与现有代码的兼容性 是否可以在同一台机器上安装两个
  • 根据其他单元格值更改多个单元格值

    我想更改包含的单元格moving to movingToOpenor movingToClose基于下一个单元格中给出的状态 有时循环会被中断并且不会从open to close or close to open 这是我当前的数据框 Dat
  • 使用 for 循环创建一系列元组

    我已经搜索过 但找不到答案 尽管我确信它已经存在了 我对 python 很陌生 但我以前用其他语言做过这种事情 我正在以行形式读取数据文件 我想将每行数据存储在它自己的元组中 以便在 for 循环之外访问 tup i inLine wher
  • 两个不同长度的数据帧的列之间的余弦相似度?

    我在 df1 中有文本列 在 df2 中有文本列 df2 的长度将与 df1 的长度不同 我想计算 df1 text 中每个条目与 df2 text 中每个条目的余弦相似度 并为每场比赛给出分数 输入样本 df1 mahesh suresh
  • python中basestring和types.StringType之间的区别?

    有什么区别 isinstance foo types StringType and isinstance foo basestring 对于Python2 basestring是两者的基类str and unicode while type
  • 给定一个排序数组,就地删除重复项,使每个元素仅出现一次并返回新长度

    完整的问题 我开始在线学习 python 但对这个标记为简单的问题有疑问 给定一个排序数组 就地删除重复项 使得每个 元素只出现一次并返回新的长度 不分配 另一个数组的额外空间 您必须通过修改输入来完成此操作 数组就地 具有 O 1 额外内
  • Airflow 1.9 - 无法将日志写入 s3

    我在 aws 的 kubernetes 中运行气流 1 9 我希望将日志发送到 s3 因为气流容器本身的寿命并不长 我已经阅读了描述该过程的各种线程和文档 但我仍然无法让它工作 首先是一个测试 向我证明 s3 配置和权限是有效的 这是在我们
  • 为什么 __dict__ 和 __weakref__ 类从未在 Python 中重新定义?

    类创建似乎从来没有re 定义 dict and weakref class属性 即 如果它们已经存在于超类的字典中 则它们不会添加到其子类的字典中 但始终re 定义 doc and module class属性 为什么 gt gt gt c
  • Python bug - 或者我的愚蠢 - 扫描字符串文字时 EOL

    我看不出以下两行之间有显着差异 然而第一个解析 而后者则不解析 In 5 n Axis of Awesome In 6 n Axis of Awesome File
  • AWS Lambda 不读取环境变量

    我正在编写一个 python 脚本来查询 Qualys API 中的漏洞元数据 我在 AWS 中将其作为 lambda 函数执行 我已经在控制台中设置了环境变量 但是当我执行函数时 出现以下错误 module initialization
  • rpy2 无法加载外部库

    希望有人能帮忙解决这个问题 R版本 2 14 1rpy2版本 2 2 5蟒蛇版本 2 7 3 一直在尝试在 python 脚本中使用 rpy2 加载 R venneuler 包 该包以 rJava 作为依赖项 venneuler 和 rJa
  • 如何使用 python 定位和读取 Data Matrix 代码

    我正在尝试读取微管底部的数据矩阵条形码 我试过libdmtx http libdmtx sourceforge net 它有 python 绑定 当矩阵的点是方形时工作得相当好 但当矩阵的点是圆形时工作得更糟 如下所示 另一个复杂问题是在某
  • 用于插入或替换 URL 参数的 Django 模板标签

    有人知道 Django 模板标签可以获取当前路径和查询字符串并插入或替换查询字符串值吗 例如向 some custom path q how now brown cow page 3 filter person 发出请求 电话 urlpar
  • 定义在文本小部件中双击时选择哪些字符

    在 Windows 上 双击文本小部件中的单词也将选择连接的标点符号 有什么方法可以定义您想要选择的角色吗 tcl wordchars该变量的值是一个正则表达式 可以设置它来控制什么被视为 单词 字符 例如 通过双击 Tk 中的文本来选择单

随机推荐