This gist is a collection of bash scripts and a Jupyter noteookbooks to support the blog entitled:
"A (No-Cross) Compile of PyTorch and OpenCV using AWS A1 instances"
This gist is a collection of bash scripts and a Jupyter noteookbooks to support the blog entitled:
"A (No-Cross) Compile of PyTorch and OpenCV using AWS A1 instances"
#!/bin/bash | |
# References | |
# https://docs.opencv.org/master/d2/de6/tutorial_py_setup_in_ubuntu.html | |
set -x | |
set -e | |
if [ "$1" == "a1" ]; then | |
threads=16 | |
elif [ "$1" == "u96" ]; then | |
threads=4 | |
elif [ "$1" == "install" ]; then | |
make install | |
ldconfig | |
else | |
echo '$0 <a1|u96|install>' | |
exit 0 | |
fi | |
# if needed | |
# sudo apt-get update | |
# sudo apt-get -y install build-essential cmake zip python3-opencv python3-dev python3-numpy | |
opencv_version=3.4.3 | |
wget -O opencv.zip https://github.com/opencv/opencv/archive/${opencv_version}.zip | |
wget -O opencv_contrib.zip https://github.com/opencv/opencv_contrib/archive/${opencv_version}.zip | |
unzip opencv.zip | |
unzip opencv_contrib.zip | |
mkdir opencv-${opencv_version}/build | |
cd opencv-${opencv_version}/build | |
cmake -D CMAKE_BUILD_TYPE=RELEASE \ | |
-D CMAKE_INSTALL_PREFIX=/usr/local \ | |
-D BUILD_WITH_DEBUG_INFO=OFF \ | |
-D BUILD_DOCS=OFF \ | |
-D BUILD_EXAMPLES=OFF \ | |
-D BUILD_TESTS=ON \ | |
-D BUILD_opencv_ts=OFF \ | |
-D BUILD_PERF_TESTS=OFF \ | |
-D INSTALL_C_EXAMPLES=OFF \ | |
-D INSTALL_PYTHON_EXAMPLES=OFF \ | |
-D ENABLE_NEON=ON \ | |
-D WITH_LIBV4L=ON \ | |
-D WITH_GSTREAMER=ON \ | |
-D BUILD_opencv_dnn=OFF \ | |
-D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-${opencv_version}/modules \ | |
../ | |
make -j$threads | |
cd ../.. | |
#!/bin/bash | |
# Following a nice blog here: | |
# https://medium.com/hardware-interfacing/how-to-install-pytorch-v4-0-on-raspberry-pi-3b-odroids-and-other-arm-based-devices-91d62f2933c7 | |
set -x | |
set -e | |
if [ "$1" == "a1" ]; then | |
threads=16 | |
sudo apt-get update | |
sudo apt-get -y install build-essential libopenblas-dev libblas-dev m4 cmake cython python3-dev python3-yaml python3-setuptools python3-pip | |
pip3 install wheel | |
elif [ "$1" == "u96" ]; then | |
threads=4 | |
sudo apt-get update | |
sudo apt-get install libopenblas-dev | |
else | |
echo "$0 <a1|u96>" | |
exit 0 | |
fi | |
mkdir pytorch_install && cd pytorch_install | |
git clone --recursive https://github.com/pytorch/pytorch | |
cd pytorch | |
export NO_CUDA=1 | |
export NO_DISTRIBUTED=1 | |
export NO_MKLDNN=1 | |
export NO_NNPACK=1 | |
export NO_QNNPACK=1 | |
export MAX_JOBS=$threads | |
python3 setup.py bdist_wheel | |