File tree 1 file changed +12
-3
lines changed
1 file changed +12
-3
lines changed Original file line number Diff line number Diff line change @@ -168,11 +168,18 @@ if [[ "${cpuinfo}" =~ (Core\(s\) per socket:[^0-9]*([0-9]+)) ]]; then
168
168
else
169
169
fatal_error " Failed to get the number of cores per socket for the current test hardware with lscpu."
170
170
fi
171
- cgroup_v1_mem_limit=" /sys/fs/cgroup/memory/$( < /proc/self/cpuset) /memory.limit_in_bytes"
172
- cgroup_v2_mem_limit=" /sys/fs/cgroup/$( < /proc/self/cpuset) /memory.max"
171
+
172
+ # The /sys inside the container is not the same as the /sys of the host
173
+ # We want to extract the memory limit from the cgroup on the host (which is typically set by SLURM).
174
+ # Thus, bot/test.sh bind-mounts the host's /sys/fs/cgroup into /hostsys/fs/cgroup
175
+ # and that's the prefix we use to extract the memory limit from
176
+ cgroup_v1_mem_limit=" /hostsys/fs/cgroup/memory/$( < /proc/self/cpuset) /memory.limit_in_bytes"
177
+ cgroup_v2_mem_limit=" /hostsys/fs/cgroup/$( < /proc/self/cpuset) /memory.max"
173
178
if [ -f " $cgroup_v1_mem_limit " ]; then
179
+ echo " Getting memory limit from file $cgroup_v1_mem_limit "
174
180
cgroup_mem_bytes=$( cat " $cgroup_v1_mem_limit " )
175
- else
181
+ elif [ -f " $cgroup_v2_mem_limit " ]; then
182
+ echo " Getting memory limit from file $cgroup_v2_mem_limit "
176
183
cgroup_mem_bytes=$( cat " $cgroup_v2_mem_limit " )
177
184
if [ " $cgroup_mem_bytes " = ' max' ]; then
178
185
# In cgroupsv2, the memory.max file may contain 'max', meaning the group can use the full system memory
183
190
fi
184
191
cgroup_mem_bytes=$(( "$cgroup_mem_kilobytes "* 1024 ))
185
192
fi
193
+ else
194
+ fatal_error " Both files ${cgroup_v1_mem_limit} and ${cgroup_v2_mem_limit} couldn't be found. Failed to get the memory limit from the current cgroup"
186
195
fi
187
196
if [[ $? -eq 0 ]]; then
188
197
# Convert to MiB
You can’t perform that action at this time.
0 commit comments