首页 > 编程知识 正文

pytorch和pycharm,torch和pytorch

时间:2023-05-06 00:57:47 阅读:170479 作者:2200

PyTorch源代码编译过程:

1、源代码编译环境:

操作系统: debian 9.12

交换空间: 1G

Python版本: 3.5

硬件:

CPU:rk3399(aarch64 ) ) )。

内存: 4G

2、下载依赖包:

下载pytorch及其依赖包时,缺省情况下从github下载。 如果网络较差且容易断开连接,请在gitee中找到相应的mldsmt链接,修改并下载相应的配置文件。 需要细致的耐心。

3、编译主要参数:

设定最大作业数:

export MAX_JOBS=3

无pytorch、cude、无MKL :

export no _ cuda=1export no _ distributed=1export no _ mkl dnn=1export no _ nn pack=1export no _ qnnpack=1

torchvision源代码编译过程:

1、取决于安装环境:

sdoapt-getinstallibjpeg-dev zlib 1g-dev

2、下载源代码:

git clone-bv 0.5.0https://github.com/py torch/vision.gittorchvision

或git clone-bv 0.5.0https://gitee.com/mirrors/vision.gittorchvision

3、源代码编译:

cd torchvision

python3 setup.py build

编译过程中应该出现了错误。 据说是python3.5的错误。 参考链接: https://blog.csdn.net/爱笑战斗机_ show/article/details/108280251

错误详细信息:

file/usr/lib/python 3.5/weak ref.py,line 117,in remove

typeerror : nonetypeobjectisnotcallable

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

找到" defremove(wr,selfref=ref ) self "行

修改为“defremove(wr,selfref=ref ) self,_ atomic _ removal=_ remove _ dead _ weak ref ) :”

找到_remove_dead_weakref(d,wr.key )行

修改为“_atomic_removal(d,wr.key )”

4、生成wheel :

python3 setup.py bdist_wheel

此时,在dist/目录中获得了whl数据包: torch vision-0.5.0 a 085 b8f BF-cp35-cp35m-Linux _ a arch 64.whl

其他:

1、py torch.whlforgenericaarch 64 platforms

justdownloadthefileorclonetherepository,and install the wheel using pip。

pip3install torch-1.1.0 a 0472 be 69-cp36-cp36m-Linux _ a arch 64.whl

2、Rationale

iwantedtorunsomepytorchmodelsonmyultra 96 boardforeventualuseinxilinx/deep hi ' sdnndkplatofrm,whichallowsyoutotkaeatratrainedmorinedmorm

3、构建安装

incaseyouyouhaveadifferntversionofpython,oranyotherreasonyoumighthavetobuildityourself,ill describe the steps below。

4、内存一致性s

thebiggestchallengebuildingalargelibrarylikethisonanembeeddeviceisthelimitaionofram (ultra 96 has 2gb ).To combat this、 you could make some extra swap space, oryoucouldlimitjobsthenumberofjobsusedwhenbuilding.iwouldrecommnedmakingsureyouhaveatleast1gbswapandlimitingthejobsto 1,asjjjobsto 1

ihadaspare 2gb USB2flashdrivewhichwouldworkperfectly,soiusedthatasmyextraswap.makesuretochangethe/dev/sda1 to your device

First,maketheswapspacesudomkswap/dev/sda 1

edityourfstabtoincludethenewdrive.nano/etc/fstab,commentoutanylinesyousee (replacethemonceyouaredone ) andadd/dev/dev

turnonthenewswapspacesudoswapon-p 32767/dev/sda 1

checkitworkedusingcat/proc/swapsandseeingifyourdriveislisted。

Finally,setthemaxnumberofjobs.idi D1 tobe safe,butifyouwantittogofasteryoucouldtry 2。

export MAX_JOBS=1

5、downloaddependenciesandclonepytorch

Dependencies:

sudoaptinstallibopenblas-devlibblas-dev M4 cmakecythonpython3- dev python3- YAML python3- setup tools

Clone PyTorch:

git clone-- recursive https://github.com/py torch/pytorchandcdpytorch

setbuildoptionsforembeededmachine (no cude,no MKL,etc ) )。

export no _ cuda=1export no _ distributed=1export no _ mkl dnn=1export no _ nn pack=1export no _ qnnpack=1

and finally,run the build。

python3 setup.py build

Once it completes with no errors,youcanrunpython3setup.pyinstalltoinstallthefiles,andifyouarereadingthisinthefuturewithanupdath youcanalsorunpython3setup.pybdist _ wheeltocreateawhlfilefordistribution.thatcommandwillputhegenerated.whlfileinthenewewed

Now you can run torch!

cd python3 import torch

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。