1 Star 3 Fork 1

wangqx/PyTorch-aarch64

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README

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

4、详细步骤,请参考链接:https://github.com/chunter18/PyTorch-AARCH64

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

空文件

简介

PyTorch wheel for ARM64 Python 3.5 (no CUDA) . 展开 收起
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangqiongxia/PyTorch-aarch64.git
git@gitee.com:wangqiongxia/PyTorch-aarch64.git
wangqiongxia
PyTorch-aarch64
PyTorch-aarch64
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891