Created
September 23, 2021 11:18
-
-
Save danhilltech/2d085066e390f4bb74bf485a2b04b203 to your computer and use it in GitHub Desktop.
Jetson Nano Dockerfile: Python 3.9, Pytorch 1.9,
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# To build | |
# DOCKER_BUILDKIT=0 docker build -f Dockerfile --platform linux/arm64 . | |
# OR | |
# docker buildx build -f Dockerfile --platform linux/arm64 . | |
FROM nvcr.io/nvidia/l4t-base:r32.6.1 | |
# | |
# setup environment | |
# | |
ENV DEBIAN_FRONTEND=noninteractive | |
ENV CUDA_HOME="/usr/local/cuda" | |
ENV PATH="/usr/local/cuda/bin:${PATH}" | |
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}" | |
WORKDIR /opt | |
# base packages | |
RUN apt-get update && \ | |
apt-get upgrade -y && \ | |
apt install -y software-properties-common && \ | |
add-apt-repository ppa:ubuntu-toolchain-r/test && \ | |
apt-get update && \ | |
apt-get upgrade -y && \ | |
apt-get install -y --no-install-recommends \ | |
libopenblas-base \ | |
libopenmpi-dev \ | |
curl \ | |
liblzma-dev \ | |
zlib1g-dev \ | |
libncurses5-dev \ | |
libgdbm-dev \ | |
libnss3-dev \ | |
libssl-dev \ | |
libreadline-dev \ | |
libffi-dev \ | |
libsqlite3-dev \ | |
libbz2-dev \ | |
build-essential \ | |
pkg-config \ | |
ninja-build \ | |
git \ | |
cmake \ | |
clang \ | |
libjpeg-dev \ | |
libopenmpi-dev \ | |
libomp-dev \ | |
ccache \ | |
libopenblas-dev \ | |
libblas-dev \ | |
libeigen3-dev \ | |
ca-certificates \ | |
gcc-9 \ | |
g++-9 \ | |
&& rm -rf /var/lib/apt/lists/* \ | |
&& apt-get clean | |
# Links etc | |
# OpenCV looks for the cuDNN version in cudnn_version.h, but it's been renamed to cudnn_version_v8.h | |
RUN ln -s /usr/include/aarch64-linux-gnu/cudnn_version_v8.h /usr/include/aarch64-linux-gnu/cudnn_version.h | |
RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9 | |
# PYTHON 3 | |
RUN wget https://www.python.org/ftp/python/3.9.7/Python-3.9.7.tgz && \ | |
tar xvf Python-3.9.7.tgz && \ | |
rm Python-3.9.7.tgz | |
RUN cd Python-3.9.7 && \ | |
./configure --enable-optimizations && \ | |
make -s -j $(nproc) install && \ | |
make clean && \ | |
rm -rf /opt/Python-3.9.7 | |
RUN rm /usr/bin/python3 && ln -s /usr/local/bin/python3 /usr/bin/python3 | |
RUN ln -s /usr/share/pyshared/lsb_release.py /usr/local/lib/python3.9/site-packages/lsb_release.py | |
RUN /usr/local/bin/python3 -m ensurepip --upgrade && \ | |
/usr/local/bin/python3 -m pip install --upgrade pip | |
RUN /usr/local/bin/python3 -m pip install -U wheel mock pillow && \ | |
/usr/local/bin/python3 -m pip install testresources && \ | |
/usr/local/bin/python3 -m pip install -U setuptools && \ | |
/usr/local/bin/python3 -m pip install scikit-build | |
RUN apt update && apt install -y software-properties-common | |
RUN git clone -b v1.9.0 --depth=1 --recursive https://github.com/pytorch/pytorch.git | |
RUN cd pytorch && curl https://gist.githubusercontent.com/dusty-nv/ce51796085178e1f38e3c6a1663a93a1/raw/bdb08d33760fc94ffbca20ed843c638228f8bb45/pytorch-1.9-jetpack-4.5.1.patch | git apply -v --index | |
# opencv-python | |
RUN /usr/local/bin/python3 -m pip install pandas requests pyyaml tqdm matplotlib seaborn typing_extensions | |
RUN export BUILD_CAFFE2_OPS=OFF && \ | |
export USE_FBGEMM=OFF && \ | |
export USE_FAKELOWP=OFF && \ | |
export BUILD_TEST=OFF && \ | |
export USE_MKLDNN=OFF && \ | |
export USE_NNPACK=OFF && \ | |
export USE_XNNPACK=OFF && \ | |
export USE_QNNPACK=OFF && \ | |
export USE_PYTORCH_QNNPACK=OFF && \ | |
export USE_CUDA=ON && \ | |
export USE_CUDNN=ON && \ | |
export TORCH_CUDA_ARCH_LIST="5.3;6.2;7.2" && \ | |
export USE_NCCL=OFF && \ | |
export USE_SYSTEM_NCCL=OFF && \ | |
export USE_OPENCV=OFF && \ | |
export PATH=/usr/lib/ccache:$PATH && \ | |
cd pytorch && \ | |
/usr/local/bin/python3 setup.py bdist_wheel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment