Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions opt/build/libtorch/Dockerfile.jetson
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# BUILD redisfab/libtorch-cpu-${ARCH}:$(PT_VER)

# stretch|bionic|buster
ARG OSNICK=buster

# arm32v7|arm64v8
ARG ARCH=aarch64

#----------------------------------------------------------------------------------------------
ARG OS=nvcr.io/nvidia/deepstream-l4t:5.1-21.02-base as builder

FROM ${OS}

ADD ./opt/readies/ /build/readies/
ADD ./opt/build/libtorch/collect.py /build/

ARG PT_VER=1.7.0

RUN apt-get -qq update && apt-get -q install -y git build-essential ninja-build cmake python3.7 python3-pip
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.7 1

RUN apt-get -q install -y python3-cffi python3-numpy
RUN pip3 install setuptools pyyaml typing
# RUN pip3 install mkl mkl-include

RUN git clone --single-branch --branch v${PT_VER} --recursive https://github.com/pytorch/pytorch.git /pytorch

ENV BUILD_PYTHON=0
ENV USE_GLOO=1
ENV USE_OPENCV=0
ENV BUILD_TORCH=ON
ENV BUILD_BINARY=ON
ENV BUILD_CAFFE2_OPS=ON
ENV BUILD_TEST=0
ENV NO_CUDA=1
ENV NO_DISTRIBUTED=1
ENV NO_MKLDNN=1
ENV NO_NNPACK=1
ENV NO_QNNPACK=1

RUN mkdir /pytorch/build_libtorch
WORKDIR /pytorch/build_libtorch
RUN python3 ../tools/build_libtorch.py

ENV BUILD_SHARED_LIBS=OFF
RUN python3 ../tools/build_libtorch.py

WORKDIR /build
RUN ./collect.py --pytorch /pytorch --pytorch-ver ${PT_VER} --dest /pytorch/dest
8 changes: 4 additions & 4 deletions opt/build/libtorch/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ DOCKER_OS.bionic=ubuntu:bionic
DOCKER_OS.stretch=debian:stretch-slim
DOCKER_OS.buster=debian:buster-slim
DOCKER_OS=$(DOCKER_OS.$(OSNICK))

TAR_ARCH.x64=x86_64
TAR_ARCH.arm64v8=arm64
TAR_ARCH.arm32v7=arm
Expand Down Expand Up @@ -60,9 +60,9 @@ CID_$(1)=$(1)_$(VERSION).cid

build_native:
@docker build --iidfile $$(IID_$(1)) -t redisfab/$(STEM):$(VERSION)-$(DEVICE)-$(1) -f Dockerfile.$(VARIANT) \
$(foreach A,$(DOCKER_BUILD_ARGS),--build-arg $(A)) .
$(foreach A,$(DOCKER_BUILD_ARGS),--build-arg $(A)) $(ROOT)
@docker create --cidfile $$(CID_$(1)) `cat $$(IID_$(1))`
@docker cp `cat $$(CID_$(1))`:/build/dest/$(STEM)-$(DEVICE)-$(OS)-$(2)-$(VERSION).tar.gz .
@docker cp `cat $$(CID_$(1))`:/pytorch/dest/$(STEM)-$(DEVICE)-$(OS)-$(2)-$(VERSION).tar.gz .

.PHONY: build_native
endef
Expand All @@ -75,7 +75,7 @@ CID_$(1)=$(1)_$(VERSION).cid

build_$(1):
@docker build --iidfile $$(IID_$(1)) -t redisfab/$(STEM):$(VERSION)-$(DEVICE)-$(1) -f Dockerfile.$(VARIANT) \
$(foreach A,$(DOCKER_BUILD_ARGS),--build-arg $(A)) .
$(foreach A,$(DOCKER_BUILD_ARGS),--build-arg $(A)) ../../..
@docker create --cidfile $$(CID_$(1)) `cat $$(IID_$(1))`
@docker cp `cat $$(CID_$(1))`:/build/$(STEM)-$(2)-$(VERSION).tar.gz .

Expand Down