forked from dusty-nv/jetson-containers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autotag
executable file
·46 lines (38 loc) · 1.54 KB
/
autotag
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
#!/usr/bin/env bash
#
# Find a container image that's compatible with the requested package(s),
# either locally, built from source, or pulled from DockerHub.
#
# For example, you can use this to automatically run a package without tracking
# down yourself exactly which container image/tag to run:
#
# $ sudo docker run --runtime nvidia -it --rm $(./autotag pytorch)
# $ ./run.sh $(./autotag pytorch) # shorthand for full 'docker run' command
#
# Or interspersed with more run arguments:
#
# $ ./run.sh --volume /my/dir:/mount $(./autotag tensorflow2)
# $ ./run.sh --volume /my/dir:/mount $(./autotag tensorflow2) /bin/bash -c 'some cmd'
#
# By default, the most-recent local image will be preferred - then DockerHub will be checked.
# If a compatible image isn't found on DockerHub, the user will be asked if they want to build it.
#
# See jetson_containers/tag.py for optional autotag arguments.
#
ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PYTHONPATH="$PYTHONPATH:$ROOT" python3 -m jetson_containers.tag "$@" >&2
return_status=$?
if [ $return_status -ne 0 ]; then
echo "-- Error: return code $return_status" >&2
exit $return_status
fi
cat /tmp/autotag
# this way didn't require a /tmp file, but couldn't have interactive input
#return_output=$(PYTHONPATH="$PYTHONPATH:$ROOT" python3 -m jetson_containers.tag "$@")
#return_status=$?
#printf "%s\n" "$return_output" >&2
#if [ $return_status -ne 0 ]; then
# echo "-- Error: return code $return_status" >&2
# exit $return_status
#fi
#echo $(echo "$return_output" | tail -1)