1111if [[ -n ${ONNXRUNTIME_ROOT:- } && -f $ONNXRUNTIME_ROOT /etc/ort-init.sh ]]; then
1212 source " $ONNXRUNTIME_ROOT /etc/ort-init.sh"
1313fi
14+ if [[ -n ${GPU_SYSTEM_ROOT:- } && -f $GPU_SYSTEM_ROOT /etc/gpu-features-available.sh ]]; then
15+ source " $GPU_SYSTEM_ROOT /etc/gpu-features-available.sh"
16+ fi
1417
1518has_cuda_device () {
1619 if command -v nvidia-smi > /dev/null 2>&1 && nvidia-smi -L > /dev/null 2>&1 ; then
@@ -28,25 +31,49 @@ has_rocm_device() {
2831
2932if [[ -n ${ONNXRUNTIME_INFERENCE_TEST_PROVIDERS:- } ]]; then
3033 IFS=' , ' read -r -a PROVIDERS <<< " $ONNXRUNTIME_INFERENCE_TEST_PROVIDERS"
34+ for PROVIDER in " ${PROVIDERS[@]} " ; do
35+ PROVIDER=${PROVIDER,,}
36+ if [[ $PROVIDER == " cuda" && ${O2_GPU_CUDA_AVAILABLE:- 0} == 1 ]] && ! has_cuda_device; then
37+ echo " onnxruntime-inference-test: CUDA is available but no CUDA device was detected" >&2
38+ exit 1
39+ fi
40+ if [[ $PROVIDER == " tensorrt" && ${O2_GPU_CUDA_AVAILABLE:- 0} == 1 ]] && ! has_cuda_device; then
41+ echo " onnxruntime-inference-test: TensorRT is available but no CUDA device was detected" >&2
42+ exit 1
43+ fi
44+ if [[ $PROVIDER == " migraphx" && ${O2_GPU_ROCM_AVAILABLE:- 0} == 1 ]] && ! has_rocm_device; then
45+ echo " onnxruntime-inference-test: ROCm is available but no ROCm device was detected" >&2
46+ exit 1
47+ fi
48+ done
3149else
3250 PROVIDERS=(cpu)
3351 if [[ ${ORT_MIGRAPHX_BUILD:- 0} == 1 ]]; then
3452 if has_rocm_device; then
3553 PROVIDERS+=(migraphx)
54+ elif [[ ${O2_GPU_ROCM_AVAILABLE:- 0} == 1 ]]; then
55+ echo " onnxruntime-inference-test: ROCm is available but no ROCm device was detected" >&2
56+ exit 1
3657 else
3758 echo " onnxruntime-inference-test: skipping migraphx, no ROCm device detected"
3859 fi
3960 fi
4061 if [[ ${ORT_CUDA_BUILD:- 0} == 1 ]]; then
4162 if has_cuda_device; then
4263 PROVIDERS+=(cuda)
64+ elif [[ ${O2_GPU_CUDA_AVAILABLE:- 0} == 1 ]]; then
65+ echo " onnxruntime-inference-test: CUDA is available but no CUDA device was detected" >&2
66+ exit 1
4367 else
4468 echo " onnxruntime-inference-test: skipping cuda, no CUDA device detected"
4569 fi
4670 fi
4771 if [[ ${ORT_TENSORRT_BUILD:- 0} == 1 ]]; then
4872 if has_cuda_device; then
4973 PROVIDERS+=(tensorrt)
74+ elif [[ ${O2_GPU_CUDA_AVAILABLE:- 0} == 1 ]]; then
75+ echo " onnxruntime-inference-test: TensorRT is available but no CUDA device was detected" >&2
76+ exit 1
5077 else
5178 echo " onnxruntime-inference-test: skipping tensorrt, no CUDA device detected"
5279 fi
0 commit comments