参考:https://elinux.org/Jetson/Performance#How_to_run_a_command_with_root_privileges_temporarily_or_on_every_bootup
- 首先创建一个performance.sh的脚本,如下:
#!/bin/bash
echo '0'|sudo tee /sys/devices/system/cpu/cpuquiet/tegra_cpuquiet/enable
g_ONLINE="$(cat /sys/devices/system/cpu/cpu0/online)";
if [[ "${g_ONLINE}" != '1' ]]; then
echo '1' |sudo tee /sys/devices/system/cpu/cpu0/online
fi
g_ONLINE="$(cat /sys/devices/system/cpu/cpu1/online)";
if [[ "${g_ONLINE}" != '1' ]]; then
echo '1' |sudo tee /sys/devices/system/cpu/cpu1/online
fi
g_ONLINE="$(cat /sys/devices/system/cpu/cpu2/online)";
if [[ "${g_ONLINE}" != '1' ]]; then
echo '1' |sudo tee /sys/devices/system/cpu/cpu2/online
fi
g_ONLINE="$(cat /sys/devices/system/cpu/cpu3/online)";
if [[ "${g_ONLINE}" != '1' ]]; then
echo '1' |sudo tee /sys/devices/system/cpu/cpu3/online
fi
# GPU to the highest performance mode
echo 'performance'|sudo tee /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
echo 852000000|sudo tee /sys/kernel/debug/clock/override.gbus/rate
echo 1|sudo tee /sys/kernel/debug/clock/override.gbus/state
- 将启动脚本放到/home/ubuntu/ 即根目录下,并设置权限。
chmod 777 /home/ubuntu/performance.sh
- 将启动性能脚本的命令放入到/etc/rc.local的最前面;
如下:
echo 'ubuntu'|sudo -S /home/ubuntu/performance.sh