{"id":15659905,"url":"https://github.com/pinto0309/pytorch4raspberrypi","last_synced_at":"2025-05-05T19:54:05.359Z","repository":{"id":44484424,"uuid":"401059401","full_name":"PINTO0309/pytorch4raspberrypi","owner":"PINTO0309","description":"Cross-compilation of PyTorch armv7l (32bit) for RaspberryPi OS","archived":false,"fork":false,"pushed_at":"2022-02-10T12:56:12.000Z","size":107,"stargazers_count":20,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-30T23:12:19.439Z","etag":null,"topics":["armv7l","pytorch","raspberry-pi","torchaudio","torchvision"],"latest_commit_sha":null,"homepage":"","language":"Dockerfile","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PINTO0309.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-08-29T14:15:41.000Z","updated_at":"2024-03-03T04:03:10.000Z","dependencies_parsed_at":"2022-09-04T23:14:14.233Z","dependency_job_id":null,"html_url":"https://github.com/PINTO0309/pytorch4raspberrypi","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fpytorch4raspberrypi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fpytorch4raspberrypi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fpytorch4raspberrypi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PINTO0309%2Fpytorch4raspberrypi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PINTO0309","download_url":"https://codeload.github.com/PINTO0309/pytorch4raspberrypi/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252567501,"owners_count":21769247,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["armv7l","pytorch","raspberry-pi","torchaudio","torchvision"],"created_at":"2024-10-03T13:19:33.166Z","updated_at":"2025-05-05T19:54:05.329Z","avatar_url":"https://github.com/PINTO0309.png","language":"Dockerfile","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pytorch4raspberrypi\nCross-compilation of PyTorch armv7l (32bit) for RaspberryPi OS\n\n**[Cross-compilation of PyTorch v1.9.0 armv7l for RaspberryPi OS Buster](https://zenn.dev/pinto0309/articles/b796e2d6396c1e)**\n\n## 1. Environment\n- Ubuntu 20.04 x86_64\n- Docker\n\n## 2. Procedure\nA very time-consuming but very easy cross-compilation procedure. It will take about three hours. Performed on Ubuntu 20.04 x86_64.\n## 2-1. [Method 1] Docker build\n```\n$ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes \\\n  \u0026\u0026 docker build -t pytorch4raspberrypi .\n\n##### A pre-built .whl file will be generated directly under the /wheels folder.\n\n$ docker run --rm -it -v ${PWD}:/work pytorch4raspberrypi /bin/bash\n\n# cp /wheels/* work\n# exit\n\n$ sudo chmod -R 777 *.whl\n```\n## 2-2. [Method 2] Manual build\n```\n$ docker run --rm --privileged multiarch/qemu-user-static --reset -p yes\n$ docker run --rm -it \\\n  -v ${PWD}:/workdir \\\n  pinto0309/raspios_lite_armhf:2022-02-10_bullseye \\\n  /bin/bash\n```\nAll of the following operations were performed on a RaspberryPi OS armv7l 32-bit Docker container running on Ubuntu 20.04 x86_64.\n```\n# apt update \u0026\u0026 apt upgrade -y\n\n# apt-get update \u0026\u0026 apt-get install -y \\\n  openjdk-11-jdk automake autoconf libpng-dev nano \\\n  curl zip unzip libtool swig zlib1g-dev pkg-config git wget xz-utils \\\n  libopenblas-dev libblas-dev m4 cmake python3-dev python3-yaml \\\n  python3-setuptools python3-pip python3-mock \\\n  libpython3-dev libpython3-all-dev g++ gcc libatlas-base-dev \\\n  libtbb-dev sox libsox-dev\n\n# pip3 install pip --upgrade\n# pip3 install cython==0.29.27 numpy==1.22.2 cmake==3.21.2 ninja==1.10.2.3 typing_extensions==4.0.1\n\n# pip3 install -U six wheel mock \u0026\u0026 ldconfig\n\n# TORCH=v1.10.2 \\\n  \u0026\u0026 TORCHVISION=v0.11.3 \\\n  \u0026\u0026 TORCHAUDIO=v0.10.2\n\n# git clone -b ${TORCH} https://github.com/pytorch/pytorch.git\n\n##########################################################\npytorch/torch/csrc/utils/python_arg_parser.h:415:94\npytorch/torch/csrc/utils/python_arg_parser.h:442:94\npytorch/torch/csrc/autograd/python_function.cpp:439:11\n\n%ld -\u003e %d\n##########################################################\n\n# cd pytorch \\\n    \u0026\u0026 git submodule update --init --recursive \\\n    \u0026\u0026 pip3 install -r requirements.txt \\\n    \u0026\u0026 NO_CUDA=1 NO_DISTRIBUTED=1 NO_MKLDNN=1 USE_NCCL=OFF USE_XNNPACK=OFF USE_TBB=ON BUILD_TEST=OFF python3 setup.py build \\\n    \u0026\u0026 cd build/lib.linux-armv7l-3.9/torch \\\n    \u0026\u0026 ln -s _C.cpython-39-arm-linux-gnueabihf.so _C.so \\\n    \u0026\u0026 ln -s _dl.cpython-39-arm-linux-gnueabihf.so _dl.so \\\n    \u0026\u0026 cd ../../..\n# python3 setup.py bdist_wheel\n\n-- ******** Summary ********\n-- General:\n--   CMake version         : 3.21.2\n--   CMake command         : /usr/local/lib/python3.9/dist-packages/cmake/data/bin/cmake\n--   System                : Linux\n--   C++ compiler          : /usr/bin/c++\n--   C++ compiler id       : GNU\n--   C++ compiler version  : 10.2.1\n--   Using ccache if found : ON\n--   Found ccache          : CCACHE_PROGRAM-NOTFOUND\n--   CXX flags             :  -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow\n--   Build type            : Release\n--   Compile definitions   : ONNX_ML=1;ONNXIFI_ENABLE_EXT=1;ONNX_NAMESPACE=onnx_torch;HAVE_MMAP=1;_FILE_OFFSET_BITS=64;HAVE_SHM_OPEN=1;HAVE_SHM_UNLINK=1;HAVE_MALLOC_USABLE_SIZE=1;USE_EXTERNAL_MZCRC;MINIZ_DISABLE_ZIP_READER_CRC32_CHECKS\n--   CMAKE_PREFIX_PATH     : /usr/lib/python3.9/site-packages\n--   CMAKE_INSTALL_PREFIX  : /pytorch/torch\n--   USE_GOLD_LINKER       : OFF\n--\n--   TORCH_VERSION         : 1.10.0\n--   CAFFE2_VERSION        : 1.10.0\n--   BUILD_CAFFE2          : ON\n--   BUILD_CAFFE2_OPS      : ON\n--   BUILD_CAFFE2_MOBILE   : OFF\n--   BUILD_STATIC_RUNTIME_BENCHMARK: OFF\n--   BUILD_TENSOREXPR_BENCHMARK: OFF\n--   BUILD_BINARY          : OFF\n--   BUILD_CUSTOM_PROTOBUF : ON\n--     Link local protobuf : ON\n--   BUILD_DOCS            : OFF\n--   BUILD_PYTHON          : True\n--     Python version      : 3.9.2\n--     Python executable   : /usr/bin/python3\n--     Pythonlibs version  : 3.9.2\n--     Python library      : /usr/lib/libpython3.9.so.1.0\n--     Python includes     : /usr/include/python3.9\n--     Python site-packages: lib/python3.9/site-packages\n--   BUILD_SHARED_LIBS     : ON\n--   CAFFE2_USE_MSVC_STATIC_RUNTIME     : OFF\n--   BUILD_TEST            : False\n--   BUILD_JNI             : OFF\n--   BUILD_MOBILE_AUTOGRAD : OFF\n--   BUILD_LITE_INTERPRETER: OFF\n--   INTERN_BUILD_MOBILE   :\n--   USE_BLAS              : 1\n--     BLAS                : open\n--   USE_LAPACK            : 1\n--     LAPACK              : open\n--   USE_ASAN              : OFF\n--   USE_CPP_CODE_COVERAGE : OFF\n--   USE_CUDA              : OFF\n--   USE_ROCM              : OFF\n--   USE_EIGEN_FOR_BLAS    : ON\n--   USE_FBGEMM            : OFF\n--     USE_FAKELOWP          : OFF\n--   USE_KINETO            : ON\n--   USE_FFMPEG            : OFF\n--   USE_GFLAGS            : OFF\n--   USE_GLOG              : OFF\n--   USE_LEVELDB           : OFF\n--   USE_LITE_PROTO        : OFF\n--   USE_LMDB              : OFF\n--   USE_METAL             : OFF\n--   USE_PYTORCH_METAL     : OFF\n--   USE_PYTORCH_METAL_EXPORT     : OFF\n--   USE_FFTW              : OFF\n--   USE_MKL               : OFF\n--   USE_MKLDNN            : OFF\n--   USE_NCCL              : OFF\n--   USE_NNPACK            : ON\n--   USE_NUMPY             : ON\n--   USE_OBSERVERS         : ON\n--   USE_OPENCL            : OFF\n--   USE_OPENCV            : OFF\n--   USE_OPENMP            : ON\n--   USE_TBB               : ON\n--     USE_SYSTEM_TBB      : OFF\n--   USE_VULKAN            : OFF\n--   USE_PROF              : OFF\n--   USE_QNNPACK           : ON\n--   USE_PYTORCH_QNNPACK   : ON\n--   USE_REDIS             : OFF\n--   USE_ROCKSDB           : OFF\n--   USE_ZMQ               : OFF\n--   USE_DISTRIBUTED       : ON\n--     USE_MPI               : OFF\n--     USE_GLOO              : OFF\n--     USE_GLOO_WITH_OPENSSL : OFF\n--     USE_TENSORPIPE        : ON\n--   USE_DEPLOY           : OFF\n--   USE_BREAKPAD         : ON\n--   Public Dependencies  : Threads::Threads\n--   Private Dependencies : pthreadpool;cpuinfo;qnnpack;pytorch_qnnpack;nnpack;fp16;tensorpipe;aten_op_header_gen;foxi_loader;rt;fmt::fmt-header-only;kineto;gcc_s;gcc;dl\n--   USE_COREML_DELEGATE     : OFF\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /pytorch/build\n\n# cp dist/* /workdir\n# cd ..\n\n# git clone -b ${TORCHVISION} https://github.com/pytorch/vision.git\n\n# cd vision \\\n    \u0026\u0026 git submodule update --init --recursive \\\n    \u0026\u0026 pip3 install /pytorch/dist/*.whl \\\n    \u0026\u0026 python3 setup.py build \\\n    \u0026\u0026 python3 setup.py bdist_wheel\n\n# cp dist/* /workdir\n# cd ..\n\n# git clone -b ${TORCHAUDIO} https://github.com/pytorch/audio.git\n# cd audio \\\n    \u0026\u0026 git submodule update --init --recursive \\\n    \u0026\u0026 python3 setup.py build \\\n    \u0026\u0026 python3 setup.py bdist_wheel\n\n# cp dist/* /workdir\n# cd ..\n\n# exit\n```\n# 3. Install\nRunning on RaspberryPi.\n```\n$ sudo apt install -y libatlas-base-dev libpng-dev nano \\\n  curl zip unzip libtool swig zlib1g-dev pkg-config git wget xz-utils \\\n  libopenblas-dev libblas-dev m4 cmake cython python3-dev python3-yaml \\\n  libtbb-dev\n\n$ sudo pip3 install numpy==1.22.2\n\n$ sudo pip3 install torch-*_armv7l_.whl torchvision-*_armv7l.whl torchaudio-*_armv7l.whl\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinto0309%2Fpytorch4raspberrypi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpinto0309%2Fpytorch4raspberrypi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpinto0309%2Fpytorch4raspberrypi/lists"}