Skip to content

Instantly share code, notes, and snippets.

@ehzawad
Created September 13, 2023 09:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ehzawad/7271549a57aed6158b38b8b86ffe5d63 to your computer and use it in GitHub Desktop.
Save ehzawad/7271549a57aed6158b38b8b86ffe5d63 to your computer and use it in GitHub Desktop.
numa solution!!
#!/bin/bash
if [[ "$EUID" -ne 0 ]]; then
echo "Please run as root."
exit 1
fi
PCI_ID=$(lspci | grep "VGA compatible controller: NVIDIA Corporation" | cut -d' ' -f1)
#PCI_ID="0000:$PCI_ID"
for item in $PCI_ID
do
item="0000:$item"
FILE=/sys/bus/pci/devices/$item/numa_node
echo Checking $FILE for NUMA connection status...
if [[ -f "$FILE" ]]; then
CURRENT_VAL=$(cat $FILE)
if [[ "$CURRENT_VAL" -eq -1 ]]; then
echo Setting connection value from -1 to 0.
echo 0 > $FILE
else
echo Current connection value of $CURRENT_VAL is not -1.
fi
else
echo $FILE does not exist to update.
fi
done
@ehzawad
Copy link
Author

ehzawad commented Sep 13, 2023

# First, create the numa_node files
for dev in $(ls --color=none /sys/bus/pci/devices/); do 
  if [ ! -e "/sys/bus/pci/devices/$dev/numa_node" ]; then
    sudo touch /sys/bus/pci/devices/$dev/numa_node
  fi
done

# Next, assign value 0 to all numa_node files
for dev in $(ls --color=none /sys/bus/pci/devices/); do 
  echo 0 | sudo tee -a /sys/bus/pci/devices/$dev/numa_node
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment