-
Notifications
You must be signed in to change notification settings - Fork 3k
/
build.sh
executable file
·84 lines (66 loc) · 2.64 KB
/
build.sh
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
#!/usr/bin/env bash
#
# This script builds the jetson-inference docker container from source.
# It should be run from the root dir of the jetson-inference project:
#
# $ cd /path/to/your/jetson-inference
# $ docker/build.sh
#
# Also you should set your docker default-runtime to nvidia:
# https://github.com/dusty-nv/jetson-containers#docker-default-runtime
#
BASE_IMAGE=$1
# find L4T_VERSION
source tools/l4t-version.sh
if [ -z $BASE_IMAGE ]; then
if [ $L4T_VERSION = "34.1.0" ]; then
BASE_IMAGE="nvcr.io/nvidia/l4t-pytorch:r34.1.0-pth1.12-py3"
elif [ $L4T_VERSION = "32.6.1" ]; then
BASE_IMAGE="nvcr.io/nvidia/l4t-pytorch:r32.6.1-pth1.9-py3"
elif [ $L4T_VERSION = "32.5.1" ]; then
BASE_IMAGE="nvcr.io/nvidia/l4t-pytorch:r32.5.0-pth1.6-py3"
elif [ $L4T_VERSION = "32.5.0" ]; then
BASE_IMAGE="nvcr.io/nvidia/l4t-pytorch:r32.5.0-pth1.6-py3"
elif [ $L4T_VERSION = "32.4.4" ]; then
BASE_IMAGE="nvcr.io/nvidia/l4t-pytorch:r32.4.4-pth1.6-py3"
elif [ $L4T_VERSION = "32.4.3" ]; then
BASE_IMAGE="nvcr.io/nvidia/l4t-pytorch:r32.4.3-pth1.6-py3"
elif [ $L4T_VERSION = "32.4.2" ]; then
BASE_IMAGE="nvcr.io/nvidia/l4t-pytorch:r32.4.2-pth1.5-py3"
else
echo "cannot automatically select l4t-pytorch base container for L4T R$L4T_VERSION"
echo "please specify it manually as: docker/build.sh nvcr.io/nvidia/l4t-pytorch:<TAG>"
exit 1
fi
fi
echo "BASE_IMAGE=$BASE_IMAGE"
echo "TAG=jetson-inference:r$L4T_VERSION"
# sanitize workspace (so extra files aren't added to the container)
rm -rf python/training/classification/data/*
rm -rf python/training/classification/models/*
rm -rf python/training/detection/ssd/data/*
rm -rf python/training/detection/ssd/models/*
# opencv.csv mounts files that preclude us installing different version of opencv
# temporarily disable the opencv.csv mounts while we build the container
CV_CSV="/etc/nvidia-container-runtime/host-files-for-container.d/opencv.csv"
if [ -f "$CV_CSV" ]; then
sudo mv $CV_CSV $CV_CSV.backup
fi
# distro release-dependent build options
LSB_RELEASE=$(lsb_release --codename --short)
OPENCV_URL="https://nvidia.box.com/shared/static/5v89u6g5rb62fpz4lh0rz531ajo2t5ef.gz"
OPENCV_DEB="OpenCV-4.5.0-aarch64.tar.gz"
if [ $LSB_RELEASE = "focal" ]; then
echo "configuring docker build for $LSB_RELEASE"
OPENCV_URL="https://nvidia.box.com/shared/static/2hssa5g3v28ozvo3tc3qwxmn78yerca9.gz"
fi
# build the container
sudo docker build -t jetson-inference:r$L4T_VERSION -f Dockerfile \
--build-arg BASE_IMAGE=$BASE_IMAGE \
--build-arg OPENCV_URL=$OPENCV_URL \
--build-arg OPENCV_DEB=$OPENCV_DEB \
.
# restore opencv.csv mounts
if [ -f "$CV_CSV.backup" ]; then
sudo mv $CV_CSV.backup $CV_CSV
fi