balena-labs-projects / rosetta-at-home

80 stars 17 forks source link

Jetson Nano: Leverage PWM Fan #30

Open adumont opened 4 years ago

adumont commented 4 years ago

It's recommended to use a PWM fan (like the Noctua nf-a4x20 5V PWM fan) with the Jetson Nano board to avoid damaging it under normal operation (especially if used for long period of time, like rosetta-at-home).

Having a PWM fan is of course optional, but when we have one, it'd be best to leverage it to keep the board cooler if possible.

In the case of balenaOS on the nano, I noticed at the momento it doesn't seem to activate the PWM fan (tested yesterday, FAN didn't run at all, not even slowly).

Some software logic need to be used to adjust the fan speed.

On one hand, the temperature of the board can be read via software (just open and read value from /sys/devices/virtual/thermal/thermal_zone0/temp).

On the other hand the PWM fan speed can be adjusted by software by writing an int between 0 (low speed) and 255 (full speed) to /sys/devices/pwm-fan/target_pwm.

For example, if temp is below 20ºC, keep at speed 0, if temp > 50ºC , keep at full speed (255). Between 20 and 50, map/ramp up speed from 0 to 255. See example code here (https://github.com/Pyrestone/jetson-fan-ctl/blob/master/fanctl.py).

PS: I didn't find any way to access the balenaOS with SSH so I couldn't try this below. But it should be doable as it works fine in Linux with the official Nvidia image (meaning that the linux kernel exposes the necesarry API to read/write the temp sensor and the PWM fan speed).

More info:

If you give me instructions to enter the balenaOS via SSH for example and test command, don't hesitate to contact me (here or email)

adolfogc commented 4 years ago

Hi @adumont,

You can gain access to a shell by using the web interface:

image

For example:

image

I noticed the power-management container exits in the case of the Jetson Nano, perhaps its Docker image can be modified to check the board is a Nano and run something like this script: https://github.com/Pyrestone/jetson-fan-ctl/blob/master/fanctl.py ?

Edit: add this additional reference that could be usefule: https://gist.github.com/bgulla/5d7afdb6575e8ef0260b7ab0507b014b

chrisys commented 4 years ago

Hi guys, we did close this issue the other day which sets the fan on the Nano to run at 100%: https://github.com/balenalabs/rosetta-at-home/issues/26 but this hasn't been deployed to the foldforcovid.io fleet yet.

Deploying your device and app manually via balenaCloud as @adolfogc points out is one way to gain access to the device; when you join the app via foldforcovid.io the devices are in a secure production mode so don't have open SSH. If you deploy via the dashboard you can use a development version of the OS which has open SSH.

adumont commented 4 years ago

IMHO the fan shouldn't be activated at full speed all the time. It's precisely a PWM fan. This issue is to allow it to be enabled, but also to have it regulate its speed according to the temperature of the board (which sounds a more logical approach).

El dom., 26 abr. 2020 13:27, Chris Crocker-White notifications@github.com escribió:

Hi guys, we did close this issue the other day which sets the fan on the Nano to run at 100%: #26 https://github.com/balenalabs/rosetta-at-home/issues/26 but this hasn't been deployed to the foldforcovid.io fleet yet.

Deploying your device and app manually via balenaCloud as @adolfogc https://github.com/adolfogc points out is one way to gain access to the device; when you join the app via foldforcovid.io the devices are in a secure production mode so don't have open SSH. If you deploy via the dashboard you can use a development version of the OS which has open SSH.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/balenalabs/rosetta-at-home/issues/30#issuecomment-619533617, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACRLWVKQWENP7WBLJFWTCDROQLALANCNFSM4MQZKMGQ .

chrisys commented 4 years ago

@adumont agree, and we'd welcome a PR that adds this, I was merely pointing out that it had at least been enabled in a recent update.

adolfogc commented 4 years ago

@chrisys Thanks for the info., I wasn't aware of that. I'm running directly the master branch (using Balena CLI), but I don't yet have a fan to test. One question: the environment variable your script uses to check the device type must be added manually or is this set automatically by Balena OS?

chrisys commented 4 years ago

@adolfogc that one is automatically set by the OS 👍 I didn't actually have a fan either but managed to find one in the attic on an old i5 CPU cooler!

ptrm commented 4 years ago

IMHO the fan shouldn't be activated at full speed all the time. It's precisely a PWM fan.

https://github.com/Pyrestone/jetson-fan-ctl – should be as simple as running in start.sh instead of writing to sysfs. Python3 is onboard the boinc-client service for some reason or other 😁