# Copyright (c) 2023 Habana Labs, Ltd. an Intel Company.Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
configure_hugepages() { | |
# config hugepages number | |
local huge_pages_size="$(grep "^Hugepagesize:" /proc/meminfo | awk '{print $2}')" | |
local huge_pages_memory=$((2 * 110 * 1024)) # convert to kB | |
local number_of_cores="$(nproc)" | |
local total_huge_pages_memory=$(($huge_pages_memory * $number_of_cores * 2)) | |
local number_of_huge_pages=$(($total_huge_pages_memory / $huge_pages_size + 1)) | |
#set current hugepages | |
#sudo sysctl -w "vm.nr_hugepages=$number_of_huge_pages" | |
sudo sysctl -w "vm.nr_hugepages=153600" | |
} | |
configure_hugepages |