Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Division by Zero When Executing temp.sh #40

Open
ourichermath opened this issue Mar 6, 2021 · 1 comment
Open

Division by Zero When Executing temp.sh #40

ourichermath opened this issue Mar 6, 2021 · 1 comment

Comments

@ourichermath
Copy link

ourichermath commented Mar 6, 2021

When I try to run the temp.sh script after modifying the fan curve in config, I get a Division by Zero error:

dave@dave-x570:~/nfancurve$ ./temp.sh

################################################################################
#          nan0s7's script for automatically managing GPU fan speed            #
################################################################################

Configuration file: /home/dave/nfancurve/config
Number of Fans detected: 
1
Number of GPUs detected: 
1
./temp.sh: 259: arithmetic expression: division by zero: "(check_diff1/(fcurve_len-1))-sleep_time"

I'm using Linux Mint 20 with an Nvidia GTX 1080 (by EVGA -- it has two fans, but one doesn't register since it's, apparently, non-standard). The only changes I've made are for both fan curves (just in case the script did recognize the 2nd fan). Stripping out the comments of config, here's what's now there:

min_t="25"
min_t2="25"
sleep_time="7"
fcurve="34 85" # fan speeds
tcurve="45 75" # temperatures
force_check="0"
fcurve2="34 85"
tcurve2="45 75"
which_curve="1 2 1 2"
default_fan="0"
fan2gpu="0 0 1 1"

The temp.sh line where the error occurs, "(check_diff1/(fcurve_len-1))-sleep_time", implies fcurve_len is 1 (giving that divide by zero). Assuming fcurve_len is derived from config's fcurve, it looks to me like fcurve_len ought to be 2. But, I'm guessing at all of this.

EDIT: I'm also assuming the "git clone https://github.com/nan0s7/nfancurve" command grabbed the latest version. I don't see version information anywhere in the files.

@nan0s7
Copy link
Owner

nan0s7 commented Mar 8, 2021

git clone ... does get the latest git version :)

Yeah so it seems the length of the curve 'array' is reduced by 2, so if you have a curve less than 3 long it'll return something weird. Guess it makes some sense since if you only have two points on a graph, it's not really a "curve" as such... :P

But I'll look into fixing this when I can. For now, you may just have to put a "dummy" point if you wish to use the same configuration you posted. For example, if your fan curve is "34 85", just find a point along that somewhere in the middle; so let's say 65. For the temperature curve "45, 75" a mid point could be "60". So if you make them "34 65 85" and "45 60 75" respectively, you'll work around the issue and get the same results.

Hope that doesn't effect your usage too much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants