Skip to content

Instantly share code, notes, and snippets.

@saper-2
Created January 8, 2018 17:26
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 saper-2/1c7711720b358fe1dc519b6ec5e351c8 to your computer and use it in GitHub Desktop.
Save saper-2/1c7711720b358fe1dc519b6ec5e351c8 to your computer and use it in GitHub Desktop.
Debian 9 nvidia-smi at boot from systemd
  1. Put 'nvload.service' into /etc/systemd/system
  2. chmod 664 nvload.service
  3. Put 'nvsmi-load.sh' script in e.g. /usr/local/nvsmi-load.sh
  4. chmod 744 nvsmi-load.sh
  5. Optionally correct path to the nvsmi-load.sh From root exec cmds:
  6. 'systemctl daemon-reload'
  7. 'systemctl enable nvload.service'
  8. To test if works exec: systemctl start nvload.service
  9. Check if /tmp/nvsmi-load.log exists and have expected contetn (output of nvidia-smi and if have current date & time at header).
[Unit]
Description=Load nvidia-smi to prevent overheating GPU
[Service]
ExecStart=/usr/local/nvsmi-load.sh
[Install]
WantedBy=multi-user.target
#!/bin/bash
echo -e "\n\nExecuting nvidia-smi..."
/usr/bin/nvidia-smi 1>/tmp/nvsmi-load.log
SMI_RESULT=$?
echo -e "\n"
if [ $SMI_RESULT -eq 0 ]; then
echo -e "\e[32mnvidia-smi: EXEC OK!\e[93m\n"
cat /tmp/nvsmi-load.log
echo -e "\e[0m\n\n"
else
echo -e "\e[91mERROR: $SMI_RESULT\e[0m\n\n"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment