Skip to content

Commit 4e77aa4

Browse files
committed
Added method to prevent GPU/CPU build if not using GPU/CPU runtime
1 parent 3419826 commit 4e77aa4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,8 @@ build_prep:
186186

187187
actual_build:
188188
# Build prep
189+
@$(eval CHECK_DOCKER_RUNTIME=$(shell docker run --rm -it ${CTO_FROM} nvidia-smi >& /dev/null && echo "GPU" || echo "CPU"))
190+
@if [ "A${CTO_BUILD}" != "A${CHECK_DOCKER_RUNTIME}" ]; then echo "ERROR: Unable to build, default runtime is ${CHECK_DOCKER_RUNTIME} and build requires ${CTO_BUILD}, aborting"; echo ""; echo ""; exit 1; fi
189191
@$(eval VAR_NT="${CTO_NAME}-${CTO_TAG}")
190192
@$(eval VAR_DD="BuildInfo/${VAR_NT}")
191193
@$(eval VAR_CV="BuildInfo/${VAR_NT}/${VAR_NT}-OpenCV.txt")
@@ -196,6 +198,8 @@ actual_build:
196198
@echo ""
197199
@echo " CTO_FROM : ${CTO_FROM}" | tee ${VAR_CV} | tee ${VAR_TF} | tee ${VAR_FF} | tee ${VAR_PT}
198200
@echo ""
201+
@echo -n " Built with Docker"; docker info | grep "Default Runtime"
202+
@echo ""
199203
@echo "-- Docker command to be run:"
200204
# @echo "docker buildx build --progress plain --allow network.host --platform linux/amd64 ${DOCKER_BUILD_ARGS} \\" > ${VAR_NT}.cmd
201205
@echo "docker build ${DOCKER_BUILD_ARGS} \\" > ${VAR_NT}.cmd

0 commit comments

Comments
 (0)