-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
87 lines (76 loc) · 2.31 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.SUFFIXES:
.SILENT:
ifeq ($(OS),Windows_NT)
PREREQS = docker docker-compose code
GPU := $(shell wmic path win32_VideoController get name | findstr "NVIDIA")
ifneq ($(strip $(GPU)),)
GPU_ID := $(shell nvidia-smi --query-gpu=index --format=csv,noheader | findstr "^[0-9]")
endif
K := $(foreach exec,$(PREREQS),\
$(if $(shell where $(exec)),some string,$(error "No $(exec) in PATH")))
pwd := $(strip $(shell cd))
else
ifeq ($(shell grep "Jetson" /proc/device-tree/model -ao), Jetson)
GPU := true
endif
ifneq ($(filter arm%,$(shell uname -p)),)
ARCH := ARM
endif
PREREQS = docker compose code
GPU := $(shell lspci | grep -i "NVIDIA")
ifneq ($(strip $(GPU)),)
GPU_ID := $(shell nvidia-smi --list-gpus | grep -oP '(\d+)' | head -1)
endif
K := $(foreach exec,$(PREREQS),\
$(if $(shell which $(exec)),some string,$(error "No $(exec) in PATH")))
endif
.PHONY: build
build: $(pwd)
# docker build -t autonomous_img . -f ros2_ws.Dockerfile
ifneq ($(strip $(GPU)),)
$(info using GPU container)
cp .docker_templates/docker-compose.GPU.yml .devcontainer/docker-compose.yml
cp .docker_templates/zed.Dockerfile .devcontainer/zed.Dockerfile
sed -i 's/NVIDIA_VISIBLE_DEVICES=.*/NVIDIA_VISIBLE_DEVICES=0/g' .devcontainer/docker-compose.yml
if [ -f "/etc/nv_tegra_release" ]; then \
sed -i 's/zed:.*/zed:4.0-tools-devel-jetson-jp4.6.1/g' .devcontainer/zed.Dockerfile; \
else \
echo "Not jetson";\
fi
# docker run -d \
# --gpus all \
# --env DISPLAY \
# --env NVIDIA_VISIBLE_DEVICES=$(GPU_ID) \
# --env NVIDIA_DRIVER_CAPABILITIES=all \
# --env ROS_DOMAIN_ID=47 \
# --volume $(pwd):/ws \
# --network host \
# --ipc host \
# --interactive \
# --tty \
# --name autonomous \
# autonomous_img \
# /bin/bash
else
$(info using CPU container)
cp .docker_templates/docker-compose.CPU.yml .devcontainer/docker-compose.yml
# docker run -d \
# --env DISPLAY \
# --env ROS_DOMAIN_ID=47 \
# --volume $(pwd):/ws \
# --network host \
# --ipc host \
# --interactive \
# --tty \
# --name autonomous \
# autonomous_img \
# /bin/bash
endif
cp .docker_templates/ros2_ws.Dockerfile .devcontainer/ros2_ws.Dockerfile
ifeq ($(strip $(ARCH)),ARM)
$(info using ARM container)
sed -i 's/osrf\/ros:humble-desktop/arm64v8\/ros:humble/' .devcontainer/ros2_ws.Dockerfile
endif
.PHONY: start
start: build
docker compose -f .devcontainer/docker-compose.yml up -d