forked from NVIDIA/gpu-driver-container
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.sh
executable file
·47 lines (42 loc) · 1.12 KB
/
common.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
#!/usr/bin/env bash
# Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
GPU_DIRECT_RDMA_ENABLED="${GPU_DIRECT_RDMA_ENABLED:-false}"
GDS_ENABLED="${GDS_ENABLED:-false}"
GDRCOPY_ENABLED="${GDRCOPY_ENABLED:-false}"
# Check if mellanox devices are present
_mellanox_devices_present() {
devices_found=0
for dev in /sys/bus/pci/devices/*; do
read vendor < $dev/vendor
if [ "$vendor" = "0x15b3" ]; then
echo "Mellanox device found at $(basename $dev)"
return 0
fi
done
echo "No Mellanox devices were found..."
return 1
}
# Check if GPU Direct RDMA is enabled
_gpu_direct_rdma_enabled() {
if [ "${GPU_DIRECT_RDMA_ENABLED}" = "true" ]; then
# check if mellanox cards are present
if _mellanox_devices_present; then
return 0
fi
fi
return 1
}
# Check if GDS is enabled
_gpu_direct_storage_enabled() {
if [ "${GDS_ENABLED}" = "true" ]; then
return 0
fi
return 1
}
# Check if GDRCopy is enabled
_gdrcopy_enabled() {
if [ "${GDRCOPY_ENABLED}" = "true" ]; then
return 0
fi
return 1
}