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 的相关文章

  • 使用“iloc”时出现“尝试在 DataFrame 切片的副本上设置值”错误

    Jupyter 笔记本返回此警告 C anaconda lib site packages pandas core indexing py 337 SettingWithCopyWarning A value is trying to be
  • 如何向未知用户目录读取/写入文件?

    我正在尝试从用户目录 C Users USERNAME Test Source 读取和写入文件 但我未能成功找到任何有关如何自动检测用户名的资源 其中的 USERNAME上面的例子 或者无论如何 我可以让它读取和写入目录 而不需要知道用户名
  • pandas 系列值之间的过滤

    If s is a pandas Series http pandas pydata org pandas docs stable dsintro html series 我知道我可以这样做 b s lt 4 or b s gt 0 但我做
  • Django管理命令是在单独的进程中执行的吗?

    Django 有很多管理命令 此外 我们还可以编写自己的命令 进行 shell 调用后会发生什么python manage py XXX 代码是否会在从 shell 启动的进程中执行 或者 shell 进程只是与执行命令的主 Django
  • 使用Python选择屏幕区域

    我正在用 Python 开发一个屏幕截图实用程序 目前它是专门针对 Linux 的 到目前为止 我已经能够拍摄完整桌面的屏幕截图 并将其上传到 Imgur 然后将链接复制到剪贴板 现在我想扩展到诸如活动窗口或特定选择的屏幕截图之类的功能 如
  • Pandas系列矢量化文本处理

    我想使用矢量化操作改进我的 Pandas 代码 假设我有一个简单的 DataFrame 其中有一个文本列 其中可能包含 url Column1 0 hello http www google com 1 bye www mail com w
  • 如何在 django admin 中使用自定义字段进行搜索

    我有一个模型并已注册到管理员 并且我已使用自定义字段在列表中显示 class ReportsAdmin admin ModelAdmin def investment self inst return models OrderDetail
  • 带剖面的 3D 曲面图

    基本上 我有一个由一组时间序列组成的曲面图 我想在特定高度添加剖面图 以更好地了解一年中值高于所选阈值的时期 由此 其中显示平面但不是剖面 To This 有什么建议吗 使用 alpha 和相机仰角并没有解决问题 平面似乎仍然在人物的前面
  • XGBOOST 功能名称错误 - Python

    也许这个问题已经以不同的形式被问过很多次了 但是 我的问题是当我使用XGBClassifier 对于像数据这样的产品 我收到功能名称不匹配错误 我希望有人能告诉我我做错了什么 这是我的代码 顺便说一句 数据完全是编造的 import pan
  • fleiss kappa 是衡量注释者间一致性的可靠指标吗?下面的结果让我很困惑,使用它时是否涉及任何假设?

    我有带有以下描述的注释矩阵 3 名注释者 3个类别 206 个科目 数据存储在 numpy ndarray 变量 z 中 array 0 2 1 0 2 1 0 2 1 0 2 1 1 1 1 0 2 1 0 3 0 0 3 0 0 3 0
  • While 在范围内循环用户输入

    我有一些代码 我想要求用户输入 1 100 之间的数字 如果他们在这些数字之间输入一个数字 它将打印 Size input 并打破循环 但是 如果他们在外部输入一个数字1 100 它将打印 大小 输入 并继续向他们重新询问一个数字 但我遇到
  • Python 结构的 PHP 替代品

    我很高兴在我的 Python 项目中使用 Fabric 进行部署 现在我正在从事一个更大的 PHP 项目 想知道是否有类似 PHP 的 Fabric 之类的东西 唔 为什么这有关系 Fabric 只是 python 脚本 所以它与项目语言无
  • 如何在Python中的字符串中插入变量值

    这是一个简单的例子 amount1 input Insert your value amount2 input Insert your value print Your first value is amount1 your second
  • Keras CNN 回归模型损失低,准确度为 0

    我在 keras 中遇到这个 NN 回归模型的问题 我正在研究一个汽车数据集 以根据 13 个维度预测价格 简而言之 我已将其读取为 pandas 数据帧 将数值转换为浮点数 缩放值 然后对分类值使用 one hot 编码 这创建了很多新列
  • 当输入是 DataFrame 时,在seaborn中对箱线图进行分组

    我打算在一个图中绘制多个列pandas dataframe 全部按另一列分组 使用groupby inside seaborn boxplot 对于类似的问题 这里有一个很好的答案matplotlib matplotlib 分组箱线图 ht
  • 如何导入 boto3 ssm ParameterNotFound 异常?

    我想import the exception当一个boto3 ssm找不到参数get parameter 我正在尝试添加一些额外的内容ssm的功能moto图书馆 但我现在很困惑 gt gt gt import boto3 gt gt gt
  • 在 envoy 中使用 rm *(通配符):没有这样的文件或目录

    我正在使用 Python 和 Envoy 我需要删除目录中的所有文件 除了一些文件外 该目录是空的 在终端中 这将是 rm tmp my silly directory 常识表明 在特使中 这转化为 r envoy run rm tmp m
  • Python 中的否定

    如果路径不存在 我尝试创建一个目录 但是 不 运算符不起作用 我不知道如何在 Python 中进行否定 正确的方法是什么 if os path exists usr share sounds blues proc subprocess Po
  • 检查一个数是否是完全平方数

    如何检查一个数是否是完全平方数 速度并不重要 目前 只是工作 See also Integer square root in python https stackoverflow com questions 15390807 依赖任何浮点计
  • 如何将 pygame Surface 转换为 PIL 图像?

    我正在使用 PIL 来透视地变换屏幕的一部分 原始图像数据是一个 pygame Surface 需要转换为 PIL 图像 因此我发现了 pygame 的 tostring 函数就是为了这个目的而存在的 然而结果看起来很奇怪 见附图 这段代码

随机推荐