Coder Social home page Coder Social logo

jetson-fan-ctl's Introduction

jetson-fan-ctl

Automagic fan control for the Nvidia Jetson Nano

Requirements:

Hardware

You will need a 5V PWM fan for this to make any sense.
I used the Noctua nf-a4x20 5V PWM fan.

Additionally, I recommend you use the barrel jack with a 4A power supply.

Software

I will assume you use the standard image on your jetson nano.

Python 3 should be pre-installed on the jetson nano.
You can check this using python3 --version
(3.5 or higher should be fine.)
otherwise, you can install it with

sudo apt install python3-dev

How to install:

run

sudo ./install.sh

The script will automatically run at boot time.

It's a set-it-and-forget-it type thing, unless you want to mess with the fan speeds.

How to customize:

open /etc/automagic-fan/config.json with your favorite editor (I'm using nano):

sudo nano /etc/automagic-fan/config.json

you will find the following lines:

{
"FAN_OFF_TEMP":20,
"FAN_MAX_TEMP":50,
"UPDATE_INTERVAL":2,
"MAX_PERF":1
}

FAN_OFF_TEMP is the temperature (°C) below which the fan is turned off.
FAN_MAX_TEMP is the temperature (°C) above which the fan is at 100% speed.
The script interpolates linearly between these two points.

UPDATE_INTERVAL tells the script how often to update the fan speed (in seconds).
MAX_PERF values greater than 0 maximize system performance by setting the CPU and GPU clock speeds to the maximum.

You can use either integers (like 20) or floating point numbers (like 20.125) in each of these fields.
The temperature precision of the thermal sensors is 0.5 (°C), so don't expect this to be too precise.

Any changes in the script will be will be applied after the next reboot.
You can run

sudo service automagic-fan restart

to apply changes immediately.

If you suspect something went wrong, please check:

sudo service automagic-fan status

How to contribute:

Feel Free to open Issues or Pull requests on this Repository.

If you find this tool useful, you can buy me a coffe:

jetson-fan-ctl's People

Contributors

christran avatar florinandrei avatar pyrestone avatar shijq23 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jetson-fan-ctl's Issues

Error: Failed to max GPU frequency!

Hi!
Great work with the fan, it works for me fine but I always get these errors on startup:

ubuntu python3[4733]: Maximizing clock speeds with jetson_clocks
ubuntu python3[4733]: /usr/bin/jetson_clocks: line 316: : No such file or directory
ubuntu python3[4733]: /usr/bin/jetson_clocks: line 317: : No such file or directory
ubuntu python3[4733]: Error: Failed to max GPU frequency!
ubuntu python3[4733]: Setup complete.
ubuntu python3[4733]: Running normally.

Would you have any advice on how to resolve them?

Cheers!

jetson_stats as well as jetson-fan-ctl

I have jetson_stats on my machine and it has a service that controls when jetson_clocks is run... Will jetson-fan-ctl upset that given the config files has a MAX_PERF value which causes jetson_clocks to be run?

Errors in GPU frequency

I get the following when running the script.

=>sudo service automagic-fan status
● automagic-fan.service - Automagic fan control
Loaded: loaded (/lib/systemd/system/automagic-fan.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2020-05-10 19:35:19 CEST; 13h ago
Main PID: 2579 (python3)
Tasks: 1 (limit: 4163)
CGroup: /system.slice/automagic-fan.service
└─2579 /usr/bin/python3 -u /usr/local/bin/automagic-fan/fanctl.py

May 10 19:35:19 nano systemd[1]: Started Automagic fan control.
May 10 19:35:24 nano python3[2579]: Maximizing clock speeds with jetson_clocks
May 10 19:35:24 nano python3[2579]: /usr/bin/jetson_clocks: line 269: : No such file or directory
May 10 19:35:24 nano python3[2579]: /usr/bin/jetson_clocks: line 270: : No such file or directory
May 10 19:35:24 nano python3[2579]: Error: Failed to max GPU frequency!
May 10 19:35:24 nano python3[2579]: Setup complete.
May 10 19:35:24 nano python3[2579]: Running normally.

Lines 269/270

  	echo 0 > "${GPU_RAIL_GATE}"
  	cat "${GPU_MAX_FREQ}" > "${GPU_MIN_FREQ}"

Failed to start - service masked - cannot unmask

Hi. First of all, thanks for publishing this software. However, I can't force it to run. When I'm trying to manually restart the service it says, that the service is masked. When I'm trying to unmask it, nothing happens.

Any ideas how to fix that?

jetson@nano:~$ sudo service automagic-fan restart
Failed to restart automagic-fan.service: Unit automagic-fan.service is masked.
jetson@nano:~$ sudo systemctl unmask automagic-fan.service
jetson@nano:~$ sudo service automagic-fan restart
Failed to restart automagic-fan.service: Unit automagic-fan.service is masked.
jetson@nano:~$ sudo systemctl status automagic-fan.service 
● automagic-fan.service
     Loaded: masked (Reason: Unit automagic-fan.service is masked.)
     Active: inactive (dead)

unstability on AGX Xavier running on MAXN power mode

I installed this package on my AGX Xavier. It works! I love it.
But after a while, the system starts to automatically reboot sporadically.
I wonder why and investigate a little bit:
Setup: AGX Xavier is running at MAXN power mode, historically I would manually run "sudo jetson_clocks" to turn on the fan to 255 (maximal speed). But just once to change the fan speed.
Potential root cause of sporatical reset:
Now after install automagic-fan, every 2 secs, the fanctl.py will write fanspeed to /sys/devices/pwm-fan/target_pwm.
Hypothesis: while AGX is running at MAXN and it is known issue that in this mode AGX is very voltage/current sensitive. Every time when set_speed(spd) occurs, it might potentially create the voltage swing that might upset AGX to trigger the reset.
Avoiding unnecessary set_speed(spd) strategy:
I modify the code to do following to reduce the frequency of set_speed(spd) while meets my need of thermal management yet still enjoy the silent when the unit is idle:

  1. check if current spd is the same as prev_speed, then there is no need to call set_speed()
  2. introduce optional (configurable) WATERMARK feature that only set the fan speed at two level (HI_FAN, LO_FAN) using watermark algorithms (HI_TEMP, LO_TEMP). This further reduce the frequency of touching set_speed()
  3. make default UPDATE_INTERVAL longer from 2 sec to 17 sec.

I tested it with my AGX Xavier running MAXN power mode and the result is very stable now.

If you like to review my code and please provide me permission to push (branch: watermark) changes to you. Please let me know ; ))

Thank you again for your code. It helps a lot.

Is your script supposed to work with another kernel and set of patches ?

I've recompiled the kernel because I wanted to enable kvm. The commands that I have issued are :

git clone https://github.com/OE4T/linux-tegra-4.9.git
cd linux-tegra-4.9
git checkout oe4t-patches-l4t-r32.7.3
cp /proc/config.gz .
gunzip config.gz
mv config .config
make menuconfig —> (enable kvm)
make -j4
make -j4 modules_install
make -j4 Image
mv /boot/Image-kvm Image2-kvm
cp arch/arm64/boot/Image /boot/Image

the dtb file to use is called : tegra210-p3448-0000-p3449-0000-a02.dtb 
and the extlinux.conf is something like this :

TIMEOUT 30
DEFAULT primary

MENU TITLE L4T boot options

LABEL primary
MENU LABEL primary kernel
LINUX /boot/Image
INITRD /boot/initrd
FDT /boot/tegra210-p3448-0000-p3449-0000-a02.dtb
APPEND ${cbootargs} quiet root=/dev/mmcblk0p1 rw rootwait rootfstype=ext4 console=ttyS0,115200n8 console=tty0 fbcon=map:0 net.ifnames=0

Unfortunately Xfce freezes a second before to be fully loaded and I suspect that the cause is your script. Is it supposed to work on the scenario that I have explained ? Yes,I've removed your script,giving these commands :


systemctl disable automagic-fan
mv /usr/local/bin/automagic-fan /usr/local/bin/automagic-fan_
mv /lib/systemd/system/automagic-fan.service /lib/systemd/system/automagic-fan.service_
mv /etc/automagic-fan /etc/automagic-fan_

but the problem still there. xfce won't fully load. But i still suspect that the cause is your script. I would like to know your opinion.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.