1
1
2
2
ROOT =../../..
3
3
4
- VERSION ?= 1.5.0
5
- OSNICK ?= buster
4
+ VERSION ?= 1.7.0
5
+ OSNICK ?= bionic
6
+
7
+ REDIS_VER =6.0.9
6
8
7
9
# ----------------------------------------------------------------------------------------------
8
10
9
11
S3_URL =redismodules/pytorch
10
12
11
13
OS: =$(shell $(ROOT ) /opt/readies/bin/platform --os)
12
- ifeq ($(OS ) ,macosx)
13
- OS: =macos
14
- endif
15
- STEM =libtorch-cpu-$(OS )
14
+ OSNICK: =$(shell $(ROOT ) /opt/readies/bin/platform --osnick)
15
+ ARCH: =$(shell $(ROOT ) /opt/readies/bin/platform --arch)
16
+ DEVICE ?= cpu
17
+
18
+ STEM =libtorch
16
19
17
20
DOCKER_OS.bionic =ubuntu:bionic
18
21
DOCKER_OS.stretch =debian:stretch-slim
19
22
DOCKER_OS.buster =debian:buster-slim
20
23
DOCKER_OS =$(DOCKER_OS.$(OSNICK ) )
21
24
25
+ TAR_ARCH.x64 =x86_64
26
+ TAR_ARCH.arm64v8 =arm64
27
+ TAR_ARCH.arm32v7 =arm
28
+
22
29
# ----------------------------------------------------------------------------------------------
23
30
24
31
define targets # (1=OP, 2=op)
25
32
$(1 ) _TARGETS :=
26
- $(1 ) _TARGETS += $(if $(findstring $(X64 ) ,1) ,$(2 ) _x64)
33
+ $(1 ) _TARGETS += $(if $(findstring $(X64 ) ,1) ,$(2 ) _native)
34
+ ifeq ($$(CROSS ) ,1)
27
35
$(1)_TARGETS += $(if $(findstring $(ARM7 ) ,1) ,$(2 ) _arm32v7)
28
36
$(1)_TARGETS += $(if $(findstring $(ARM8 ) ,1) ,$(2 ) _arm64v8)
37
+ endif
29
38
30
- $(1 ) _TARGETS += $$(if $$(strip $$($(1 ) _TARGETS) ) ,,$(2 ) _x64 $(2 ) _arm32v7 $(2 ) _arm64v8)
39
+ ifeq ($$(CROSS ) ,1)
40
+ $(1)_TARGETS += $$(if $$(strip $$($(1 ) _TARGETS) ) ,,$(2 ) _native $(2 ) _arm32v7 $(2 ) _arm64v8)
41
+ else
42
+ $(1)_TARGETS += $$(if $$(strip $$($(1 ) _TARGETS) ) ,,$(2 ) _native)
43
+ endif
31
44
endef
32
45
33
46
$(eval $(call targets,BUILD,build))
34
47
$(eval $(call targets,PUBLISH,publish))
35
48
36
49
# ----------------------------------------------------------------------------------------------
37
50
38
- define build_x64 # (1=arch, 2=tar-arch)
51
+ DOCKER_BUILD_ARGS += \
52
+ PT_VER=$(VERSION ) \
53
+ OSNICK=$(OSNICK ) \
54
+ OS=$(DOCKER_OS ) \
55
+ ARCH=$(ARCH )
56
+
57
+ define build_native # (1=arch, 2=tar-arch)
39
58
IID_$(1 ) =$(1 ) _$(VERSION ) .iid
40
59
CID_$(1 ) =$(1 ) _$(VERSION ) .cid
41
60
42
- build_x64 :
43
- @docker build --iidfile $$(IID_$(1 ) ) -t redisfab/$(STEM ) -$(1 ) : $( VERSION ) -f Dockerfile.x64 \
44
- --build-arg OS= $( DOCKER_OS ) $( ROOT )
61
+ build_native :
62
+ @docker build --iidfile $$(IID_$(1 ) ) -t redisfab/$(STEM ) : $( VERSION ) -$(DEVICE ) - $( 1 ) -f Dockerfile.$( VARIANT ) \
63
+ $( foreach A, $( DOCKER_BUILD_ARGS ) , --build-arg $( A ) ) .
45
64
@docker create --cidfile $$(CID_$(1 ) ) `cat $$(IID_$(1 ) ) `
46
- @docker cp `cat $$(CID_$(1 ) ) `:/build/dest/$(STEM ) -$(2 ) -$(VERSION ) .tar.gz .
65
+ @docker cp `cat $$(CID_$(1 ) ) `:/build/dest/$(STEM ) -$(DEVICE ) - $( OS ) - $( 2 ) -$(VERSION ) .tar.gz .
47
66
48
- .PHONY: build_x64
67
+ .PHONY: build_native
49
68
endef
50
69
70
+ ifeq ($(CROSS ) ,1)
71
+
51
72
define build_arm # (1=arch, 2=tar-arch)
52
73
IID_$(1 ) =$(1 ) _$(VERSION ) .iid
53
74
CID_$(1 ) =$(1 ) _$(VERSION ) .cid
54
75
55
76
build_$(1 ) :
56
- @docker build --iidfile $$(IID_$(1 ) ) -t redisfab/$(STEM ) -$(1 ) : $( VERSION ) -f Dockerfile.arm \
57
- --build-arg ARCH= $( 1 ) $( ROOT )
77
+ @docker build --iidfile $$(IID_$(1 ) ) -t redisfab/$(STEM ) : $( VERSION ) -$(DEVICE ) - $( 1 ) -f Dockerfile.$( VARIANT ) \
78
+ $( foreach A, $( DOCKER_BUILD_ARGS ) , --build-arg $( A ) ) .
58
79
@docker create --cidfile $$(CID_$(1 ) ) `cat $$(IID_$(1 ) ) `
59
80
@docker cp `cat $$(CID_$(1 ) ) `:/build/$(STEM ) -$(2 ) -$(VERSION ) .tar.gz .
60
81
61
82
.PHONY: build_$(1 )
62
83
endef
63
84
85
+ endif # CROSS
86
+
64
87
# ----------------------------------------------------------------------------------------------
65
88
66
- define publish_x64 # (1=arch, 2=tar-arch)
67
- publish_x64 :
89
+ define publish_native # (1=arch, 2=tar-arch)
90
+ publish_native :
68
91
@aws s3 cp $(STEM ) -$(2 ) -$(VERSION ) .tar.gz s3://$(S3_URL ) / --acl public-read
69
92
70
- .PHONY: publish_x64
93
+ .PHONY: publish_native
71
94
endef
72
95
96
+ ifeq ($(CROSS ) ,1)
97
+
73
98
define publish_arm # (1=arch, 2=tar-arch)
74
99
publish_$(1 ) :
75
100
@aws s3 cp $(STEM ) -$(2 ) -$(VERSION ) .tar.gz s3://$(S3_URL ) / --acl public-read
76
101
77
102
.PHONY: publish_$(1 )
78
103
endef
79
104
105
+ endif # CROSS
106
+
80
107
# ----------------------------------------------------------------------------------------------
81
108
82
109
all : build publish
83
110
84
111
build : $(BUILD_TARGETS )
85
112
86
- $(eval $(call build_x64,x64,x86_64))
113
+ $(eval $(call build_native,$(ARCH),$(TAR_ARCH.$(ARCH))))
114
+ ifeq ($(CROSS ) ,1)
87
115
$(eval $(call build_arm,arm64v8,arm64))
88
116
$(eval $(call build_arm,arm32v7,arm))
117
+ endif
89
118
90
119
ifneq ($(filter publish,$(MAKECMDGOALS ) ) ,)
91
120
ifeq ($(wildcard $(HOME ) /.aws/credentials) ,)
@@ -96,13 +125,16 @@ endif
96
125
publish : $(PUBLISH_TARGETS )
97
126
98
127
$(eval $(call publish_x64,x64,x86_64))
128
+ ifeq ($(CROSS ) ,1)
99
129
$(eval $(call publish_arm,arm64v8,arm64))
100
130
$(eval $(call publish_arm,arm32v7,arm))
131
+ endif
101
132
102
133
repack :
103
134
@PT_VERSION=$(VERSION ) GPU=$(GPU ) ./repack.sh
104
135
105
136
help :
106
- @echo " make [build|repack|publish] [X64=1|ARM7=1|ARM8=1]"
137
+ @echo " make [build|repack|publish] [X64=1|ARM7=1|ARM8=1] [CROSS=1] "
107
138
108
139
.PHONY : all build repack publish help
140
+
0 commit comments