Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- # Usage: nvoc [core_offset] [mem_offset]
- # Example: nvoc 200 1000
- # If no args are given, defaults both to 0.
- CORE="${1:-0}"
- MEM="${2:-0}"
- GPU=0
- DISPLAY_ID=:0
- # Sanity checks: Only integers, within reasonable OC limits
- if ! [[ "$CORE" =~ ^-?[0-9]+$ ]]; then
- echo "Error: core_offset must be an integer."
- exit 1
- fi
- if ! [[ "$MEM" =~ ^-?[0-9]+$ ]]; then
- echo "Error: mem_offset must be an integer."
- exit 1
- fi
- if (( CORE > 350 || CORE < -350 )); then
- echo "Error: core_offset ($CORE) must be between -350 and 350 MHz."
- exit 1
- fi
- if (( MEM > 6000 || MEM < -2000 )); then
- echo "Error: mem_offset ($MEM) must be between -2000 and 6000 MHz."
- exit 1
- fi
- # Check if the X server is running on DISPLAY :0
- if [ ! -S /tmp/.X11-unix/X0 ]; then
- echo "No X server detected on DISPLAY :0."
- echo "Attempting to start X server on :0 as root..."
- sudo X :0 &> /dev/null &
- # Wait up to 5 seconds for X server to come up
- for i in {1..10}; do
- if [ -S /tmp/.X11-unix/X0 ]; then
- echo "X server started successfully."
- break
- fi
- sleep 0.5
- done
- if [ ! -S /tmp/.X11-unix/X0 ]; then
- echo "Failed to start X server on :0."
- exit 2
- fi
- fi
- export DISPLAY=$DISPLAY_ID
- for i in {0..4}; do
- nvidia-settings -a "[gpu:${GPU}]/GPUGraphicsClockOffset[$i]=${CORE}" -a "[gpu:${GPU}]/GPUMemoryTransferRateOffset[$i]=${MEM}"
- done
- echo "Core clock offset set to ${CORE} MHz and memory offset set to ${MEM} MHz for all performance levels on GPU ${GPU}."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement