Skip to content

Commit eb4da4c

Browse files
committed
Detect platform and platform config
Signed-off-by: Victor Chang <vicchang@nvidia.com>
1 parent 2512c12 commit eb4da4c

File tree

3 files changed

+82
-13
lines changed

3 files changed

+82
-13
lines changed

applications/endoscopy_tool_tracking/cpp/package-app.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
set -e
1617

1718
GIT_ROOT=$(readlink -f ./$(git rev-parse --show-cdup))
1819

@@ -26,6 +27,21 @@ print_error() {
2627
echo -e "${RED}ERROR${NOCOLOR}:" $*
2728
}
2829

30+
get_host_gpu() {
31+
if ! command -v nvidia-smi >/dev/null; then
32+
print_error Y "Could not find any GPU drivers on host. Defaulting build to target dGPU/CPU stack."
33+
echo -n "dgpu"
34+
elif nvidia-smi 2>/dev/null | grep nvgpu -q; then
35+
echo -n "igpu"
36+
else
37+
echo -n "dgpu"
38+
fi
39+
}
40+
41+
get_host_arch() {
42+
echo -n "$(uname -m)"
43+
}
44+
2945
if [ ! -d $GIT_ROOT/build/endoscopy_tool_tracking ]; then
3046
print_error "Please build the Endoscopy Tool Tracking application first with the following command:"
3147
print_error "./dev_container build_and_run endoscopy_tool_tracking"
@@ -45,10 +61,17 @@ cp -f $GIT_ROOT/build/endoscopy_tool_tracking/operators/tool_tracking_postproces
4561
echo Updating application configuration...
4662
sed -e s!gxf_extensions/lstm_tensor_rt_inference/!!g -i $APP_PATH/endoscopy_tool_tracking.yaml
4763

64+
PLATFORM=x64-workstation
65+
GPU=$(get_host_gpu)
66+
if [ $(get_host_arch) == "aarch64" ]; then
67+
PLATFORM=igx-orin-devkit
68+
fi
4869

4970
echo -e "done\n"
50-
echo -e Use the following commands to package and run the Endoscopy Tool Tracking application:\n
51-
echo -e "Package the application:\n"
52-
echo -e "${YELLOW}holoscan package -c $APP_PATH/endoscopy_tool_tracking.yaml --platform x64-workstation -t holohub-endoscopy-tool-tracking-cpp $APP_PATH/endoscopy_tool_tracking --include onnx holoviz${NOCOLOR}"
53-
echo -e "Run the application:\n"
71+
echo -e Use the following commands to package and run the Endoscopy Tool Tracking application:
72+
echo -e "Package the application:"
73+
echo -e "${YELLOW}holoscan package -c $APP_PATH/endoscopy_tool_tracking.yaml --platform [igx-orin-devkit | jetson-agx-orin-devkit | sbsa, x64-workstation] --platform-config [igpu | dgpu] -t holohub-endoscopy-tool-tracking-cpp $APP_PATH/endoscopy_tool_tracking --include onnx holoviz${NOCOLOR}"
74+
echo -e "\nFor example:"
75+
echo -e "${YELLOW}holoscan package -c $APP_PATH/endoscopy_tool_tracking.yaml --platform ${PLATFORM} --platform-config ${GPU} -t holohub-endoscopy-tool-tracking-cpp $APP_PATH/endoscopy_tool_tracking --include onnx holoviz${NOCOLOR}"
76+
echo -e "\nRun the application:"
5477
echo -e "${YELLOW}holoscan run -r \$(docker images | grep "holohub-endoscopy-tool-tracking-cpp" | awk '{print \$1\":\"\$2}') -i $GIT_ROOT/data/endoscopy${NOCOLOR}"

applications/endoscopy_tool_tracking/python/package-app.sh

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
set -e
1617

1718
GIT_ROOT=$(readlink -f ./$(git rev-parse --show-cdup))
1819

@@ -26,6 +27,21 @@ print_error() {
2627
echo -e "${RED}ERROR${NOCOLOR}:" $*
2728
}
2829

30+
get_host_gpu() {
31+
if ! command -v nvidia-smi >/dev/null; then
32+
print_error Y "Could not find any GPU drivers on host. Defaulting build to target dGPU/CPU stack."
33+
echo -n "dgpu"
34+
elif nvidia-smi 2>/dev/null | grep nvgpu -q; then
35+
echo -n "igpu"
36+
else
37+
echo -n "dgpu"
38+
fi
39+
}
40+
41+
get_host_arch() {
42+
echo -n "$(uname -m)"
43+
}
44+
2945
if [ ! -d $GIT_ROOT/build/endoscopy_tool_tracking ]; then
3046
print_error "Please build the Endoscopy Tool Tracking application first with the following command:"
3147
print_error "./dev_container build_and_run endoscopy_tool_tracking"
@@ -45,10 +61,17 @@ cp -rf $GIT_ROOT/build/endoscopy_tool_tracking/python/lib/holohub $APP_PATH
4561
echo Updating application configuration...
4662
sed -e s!gxf_extensions/lstm_tensor_rt_inference/!!g -i $APP_PATH/endoscopy_tool_tracking.yaml
4763

64+
PLATFORM=x64-workstation
65+
GPU=$(get_host_gpu)
66+
if [ $(get_host_arch) == "aarch64" ]; then
67+
PLATFORM=igx-orin-devkit
68+
fi
4869

4970
echo -e "done\n"
50-
echo -e Use the following commands to package and run the Endoscopy Tool Tracking application:\n
51-
echo -e "Package the application:\n"
52-
echo -e "${YELLOW}holoscan package -c $APP_PATH/endoscopy_tool_tracking.yaml --platform x64-workstation -t holohub-endoscopy-tool-tracking-python $APP_PATH/endoscopy_tool_tracking.py --include onnx holoviz${NOCOLOR}"
53-
echo -e "Run the application:\n"
71+
echo -e Use the following commands to package and run the Endoscopy Tool Tracking application:
72+
echo -e "Package the application:"
73+
echo -e "${YELLOW}holoscan package -c $APP_PATH/endoscopy_tool_tracking.yaml --platform [igx-orin-devkit | jetson-agx-orin-devkit | sbsa, x64-workstation] --platform-config [igpu | dgpu] -t holohub-endoscopy-tool-tracking-python $APP_PATH/endoscopy_tool_tracking.py --include onnx holoviz${NOCOLOR}"
74+
echo -e "\nFor example:"
75+
echo -e "${YELLOW}holoscan package -c $APP_PATH/endoscopy_tool_tracking.yaml --platform ${PLATFORM} --platform-config ${GPU} -t holohub-endoscopy-tool-tracking-python $APP_PATH/endoscopy_tool_tracking.py --include onnx holoviz${NOCOLOR}"
76+
echo -e "\nRun the application:"
5477
echo -e "${YELLOW}holoscan run -r \$(docker images | grep "holohub-endoscopy-tool-tracking-python" | awk '{print \$1\":\"\$2}') -i $GIT_ROOT/data/endoscopy${NOCOLOR}"

applications/object_detection_torch/package-app.sh

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
16+
set -e
1617

1718
GIT_ROOT=$(readlink -f ./$(git rev-parse --show-cdup))
1819

@@ -26,6 +27,21 @@ print_error() {
2627
echo -e "${RED}ERROR${NOCOLOR}:" $*
2728
}
2829

30+
get_host_gpu() {
31+
if ! command -v nvidia-smi >/dev/null; then
32+
print_error Y "Could not find any GPU drivers on host. Defaulting build to target dGPU/CPU stack."
33+
echo -n "dgpu"
34+
elif nvidia-smi 2>/dev/null | grep nvgpu -q; then
35+
echo -n "igpu"
36+
else
37+
echo -n "dgpu"
38+
fi
39+
}
40+
41+
get_host_arch() {
42+
echo -n "$(uname -m)"
43+
}
44+
2945
if [ ! -d $GIT_ROOT/build/object_detection_torch ]; then
3046
print_error "Please build the Object Detection Torch application first with the following command:"
3147
print_error "./dev_container build_and_run object_detection_torch"
@@ -37,11 +53,18 @@ echo Creating application directory $APP_PATH...
3753
mkdir -p $APP_PATH
3854
echo Copying application files to $APP_PATH...
3955
cp -f $GIT_ROOT/build/object_detection_torch/applications/object_detection_torch/object_detection_torch $APP_PATH
40-
cp -f $GIT_ROOT/build/object_detection_torch/applications/object_detection_torch/object_detection_torch.yaml $APP_PATH
56+
57+
PLATFORM=x64-workstation
58+
GPU=$(get_host_gpu)
59+
if [ $(get_host_arch) == "aarch64" ]; then
60+
PLATFORM=igx-orin-devkit
61+
fi
4162

4263
echo -e "done\n"
43-
echo -e Use the following commands to package and run the Object Detection Torch application:\n
44-
echo -e "Package the application:\n"
45-
echo -e "${YELLOW}holoscan package -c $APP_PATH/object_detection_torch.yaml --platform x64-workstation -t holohub-object-detection-torch $APP_PATH/object_detection_torch --include onnx holoviz torch${NOCOLOR}"
46-
echo -e "Run the application:\n"
64+
echo -e Use the following commands to package and run the Object Detection Torch application:
65+
echo -e "Package the application:"
66+
echo -e "${YELLOW}holoscan package -c $APP_PATH/object_detection_torch.yaml --platform [igx-orin-devkit | jetson-agx-orin-devkit | sbsa, x64-workstation] --platform-config [igpu | dgpu] -t holohub-object-detection-torch $APP_PATH/object_detection_torch --include onnx holoviz torch${NOCOLOR}"
67+
echo -e "\nFor example:"
68+
echo -e "${YELLOW}holoscan package -c $APP_PATH/object_detection_torch.yaml --platform ${PLATFORM} --platform-config ${GPU} -t holohub-object-detection-torch $APP_PATH/object_detection_torch --include onnx holoviz torch${NOCOLOR}"
69+
echo -e "\nRun the application:"
4770
echo -e "${YELLOW}holoscan run -r \$(docker images | grep "holohub-object-detection-torch" | awk '{print \$1\":\"\$2}') -i $GIT_ROOT/data/object_detection_torch${NOCOLOR}"

0 commit comments

Comments
 (0)