日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > python >内容正文

python

python arm64_PyTorch-aarch64

發布時間:2025/4/16 python 22 豆豆
生活随笔 收集整理的這篇文章主要介紹了 python arm64_PyTorch-aarch64 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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

總結

以上是生活随笔為你收集整理的python arm64_PyTorch-aarch64的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。