Pages:
Author

Topic: pyADL - Python AMD ADL Wrapper (Read 5614 times)

hero member
Activity: 631
Merit: 500
August 17, 2011, 11:55:15 PM
#24
thanks for this, netxshare.

i noticed some functions like getTemp() weren't working that well (value was set only when setIndex() was called), so i updated it a little.

i also added the setFanAuto() function to reset the fan speed to automatic..i know aticonfig pplib-cmd set fanspeed doesn't quite work, so this turned out to be a nice solution.

don't think i can upload attachments so here's the patch inline.


--- pyADL.cpp   2011-06-09 12:45:32.000000000 -0700
+++ pyADL-new.cpp   2011-08-17 21:47:14.967520700 -0700
@@ -70,6 +70,7 @@
 
    if (adl->GetSupportedFeatures() & ADL::FEAT_GET_ACTIVITY)
    {
+      adl->UpdateData();
       Results = Py_BuildValue("i", adl->mODActivity.iActivityPercent);
       return Results;
    }
@@ -85,6 +86,7 @@
    PyObject *Results;
    if (adl->GetSupportedFeatures() & ADL::FEAT_GET_TEMPERATURE)
    {
+      adl->UpdateData();
       Results = Py_BuildValue("f", (float)adl->mTemperature.iTemperature/1000.0);
       return Results;
    }
@@ -102,6 +104,7 @@
    PyObject *Results;
    if ((adl->GetSupportedFeatures() & ADL::FEAT_GET_FANSPEED_INFO) && (adl->GetSupportedFeatures() & ADL::FEAT_GET_FANSPEED))
    {
+      adl->UpdateData();
       Results = Py_BuildValue("i", adl->mCurrentFanSpeed.iFanSpeed * 100 / adl->mFanSpeedInfo.iMaxRPM);
       return Results;
    }
@@ -120,6 +123,7 @@
 
    if ((adl->GetSupportedFeatures() & ADL::FEAT_GET_FANSPEED_INFO) && (adl->GetSupportedFeatures() & ADL::FEAT_GET_FANSPEED))
    {
+      adl->UpdateData();
       Results = Py_BuildValue("i", adl->mCurrentFanSpeed.iFanSpeed);
       return Results;
    }
@@ -139,6 +143,7 @@
 
    if (adl->GetSupportedFeatures() & ADL::FEAT_GET_OD_PARAMETERS)
    {
+      adl->UpdateData();
       Results =  Py_BuildValue("i", adl->mpODPerformanceLevels->aLevels[adl->mODActivity.iCurrentPerformanceLevel].iEngineClock/100);
       return Results;
    }
@@ -157,6 +162,7 @@
 
    if (adl->GetSupportedFeatures() & ADL::FEAT_GET_OD_PARAMETERS)
    {
+      adl->UpdateData();
       Results = Py_BuildValue("i", adl->mpODPerformanceLevels->aLevels[adl->mODActivity.iCurrentPerformanceLevel].iMemoryClock/100);
       return Results;
    }
@@ -173,6 +179,7 @@
    PyObject *Results;
    if (adl->GetSupportedFeatures() & ADL::FEAT_GET_OD_PARAMETERS)
    {
+      adl->UpdateData();
       Results = Py_BuildValue("f", (float)adl->mpODPerformanceLevels->aLevels[adl->mODActivity.iCurrentPerformanceLevel].iVddc/1000.0);
       return Results;
    }
@@ -221,6 +228,29 @@
 }
 
 
+static PyObject *setFanAuto(PyObject *self, PyObject *noargs)
+{
+   if (adl->GetSupportedFeatures() & ADL::FEAT_GET_FANSPEED)
+        {
+      if(SAVE_CALL(adl->ADL_Overdrive5_FanSpeedToDefault_Set)(adl->GetGPUIndex(), 0)
+!= ADL_OK)
+      {
+                        Py_INCREF(Py_False);
+                        return Py_False;
+                }
+                else
+                {
+                        ACT_LOG("Fan speed set to AUTO");
+                        Py_INCREF(Py_True);
+                        return Py_True;
+                }
+
+        }
+
+        Py_INCREF(Py_False);
+        return Py_False;
+}   
+
 static PyObject *setCoreClockSpeed(PyObject *self, PyObject *args)
 {
    int Level,CoreSpeed;
@@ -373,6 +403,7 @@
    {"getMemoryClockSpeed", getMemoryClockSpeed, METH_NOARGS, "Returns Current Memory Clock Speed."},
    {"getVoltage", getVoltage, METH_NOARGS, "Returns Current Voltage."},
    {"setFanSpeed", setFanSpeed, METH_VARARGS, "Sets The Fan Speed."},
+   {"setFanAuto", setFanAuto, METH_NOARGS, "Sets The Fan Speed To Automatic."},
    {"setCoreClockSpeed", setCoreClockSpeed, METH_VARARGS, "Sets The Core Clock Speed."},
    {"setMemoryClockSpeed", setMemoryClockSpeed, METH_VARARGS, "Sets The Memory Clock Speed."},
    {"setVoltage", setVoltage, METH_VARARGS, "Sets The GPU Voltage."},
sr. member
Activity: 292
Merit: 250
Apparently I inspired this image.
June 30, 2011, 10:35:30 AM
#23
Just to save everyone some grief, to initialize you now should run
Code:
ADL.setIndex(0)
or whatever index you want, instead of
Code:
ADL.SetupADL(0)
.
newbie
Activity: 41
Merit: 0
May 26, 2011, 06:08:56 PM
#22
Good work. Though I wish it exposed a "detected device list" of some sort as well.
newbie
Activity: 40
Merit: 0
May 26, 2011, 05:59:49 PM
#21
Does this run on windows?
newbie
Activity: 15
Merit: 0
May 26, 2011, 04:44:20 PM
#20
Ok, for anyone interested, I wrote my own temperature tracker: http://forum.bitcoin.org/index.php?topic=10073.0
member
Activity: 78
Merit: 10
May 21, 2011, 02:47:12 PM
#19
Are you running it on linux? if so did you do env Display= :0.1 or whatever you need to do?

Yep.  DISPLAY is set properly.  Other calls (like setfanspeed) work.  Those two calls always fail.
newbie
Activity: 15
Merit: 0
May 20, 2011, 08:37:45 AM
#18
Any plans on releasing that realtime temperature tracker?

Looks awesome, and would save me quite some work Smiley
legendary
Activity: 1708
Merit: 1020
May 20, 2011, 05:38:18 AM
#17
it's definiteley much more stable now! did not crash on me so far.   Cheesy

donated a coin
(and unfortunately I am not one of the old dragons sitting on a big pile of early btc).

full member
Activity: 120
Merit: 100
May 20, 2011, 01:18:08 AM
#16
Odd, can't get core or memory clocks from one of my two 5870s.

Code:
core: getCoreClockSpeed() Failed.
mem: getMemoryClockSpeed() Failed.

Edit: typo, should be 5870.


Are you running it on linux? if so did you do env Display= :0.1 or whatever you need to do?


I have done a few tests and I ran the current version in a for loop of 1550 with calls to every getXXX function on each gpu, no errors.

I also started working on an example of something I am using pyADL for



It is a real time chart so it updates on it's own, will be useful when all the remote monitoring is done.
member
Activity: 78
Merit: 10
May 19, 2011, 01:56:15 PM
#15
Odd, can't get core or memory clocks from one of my two 5870s.

Code:
core: getCoreClockSpeed() Failed.
mem: getMemoryClockSpeed() Failed.

Edit: typo, should be 5870.
legendary
Activity: 1708
Merit: 1020
May 19, 2011, 10:57:02 AM
#14
Unfortunately still the same problem. I'll take another look at it later. Now sports =)
full member
Activity: 120
Merit: 100
May 19, 2011, 10:39:23 AM
#13
It might be some deallocation problem. I got this error once: fatal python error dealocating none   mostly it crashes with pretty much no information why. I am so used to having nice Python tracebacks. =)

Is there a particular reason you return NULL sometimes and not Py_None? Or is it the same?


It would be interesting to build a temperature controlled miner with this tool.

I updated a line of code on github I am not sure if this will make a difference at all, but I ran a loop for a while and had no problems. Could you please update and give it a shot.
legendary
Activity: 1708
Merit: 1020
May 19, 2011, 09:23:55 AM
#12
It might be some deallocation problem. I got this error once: fatal python error dealocating none   mostly it crashes with pretty much no information why. I am so used to having nice Python tracebacks. =)

Is there a particular reason you return NULL sometimes and not Py_None? Or is it the same?


It would be interesting to build a temperature controlled miner with this tool.
full member
Activity: 120
Merit: 100
May 19, 2011, 08:26:19 AM
#11
Sorry, was not aware anyone else had posted in this thread.

You do not need AMDOverdriveCtrl to use this. I did as you noticed change it from pyADL to ADL in the python code using pyADL was not correct.

I think I know what is causing the crashing I will take a look in to it and update the code. I can also add a option to enable/disable the output, this way it can be enabled when you are configuring the system and disable when you need it to run all the time.
legendary
Activity: 1708
Merit: 1020
May 19, 2011, 02:56:43 AM
#10
ok, I got it to work. the installation was a royal pain. it's cool but there still are some problems.

it's crashing badly (randomly?) every couple hundred calls with a runtime error in pythonw, I am still looking into that.

it's very verbose on the command line. Is there an easy way to redirect it's output to something else than stdout (besides modifying the .cpp)?

sr. member
Activity: 520
Merit: 253
555
May 18, 2011, 12:48:21 PM
#9
Thanks, this looks nice Smiley

I was thinking of doing something similar the other day, but I noticed that AMDOverdriveCtrl can also run on the command line (with a proper DISPLAY= variable in the environment).

The only problem was that in this mode, it can only load one default setting, so it takes some scripting to set multiple cards. In my case, the card indices are 0 and 3, so my config files are default-0.ovdr and default-3.ovdr. Each is symlinked to default.ovdr in turn, for running the overdrive command.

Code:
CMD=AMDOverdriveCtrl
DIR=~/.AMDOverdriveCtrl
LINK=default.ovdr

cd $DIR

export DISPLAY=:0

INDICES="`ls default-*.ovdr | sed -e 's/default-\([0-9]\+\).ovdr/\1/'`"

for i in $INDICES; do
    rm $LINK
    ln -s default-$i.ovdr $LINK
    $CMD -i $i -a -b
done
sr. member
Activity: 256
Merit: 250
May 18, 2011, 12:40:46 PM
#8
Welcome to the hell of properly mapping ADL adapters to OpenCL devices Smiley

The scenario with unsupported by OCL onboard adapters is easy to manage...but you have lots of other peculiarities there. E.g some 5970s are reported as a single adapter (2 devices in OpenCL)....some as 4 adapters with different ids (still 2 devices in OpenCL). The good thing is that I haven't seen yet a case where we have different ordering of devices...that would really be a problem.

I've asked the AMD OpenCL guys if it's possible to create an extension that exports temperature/fan speed data to OpenCL...never got any reply.
hero member
Activity: 726
Merit: 500
May 18, 2011, 12:08:47 PM
#7
OK, I answered my own question.  You don't need to compile the AMDOverdriveCtrl GUI first.  However, the author seems to have only partially changed the extension name from ADL to pyADL.  You still need to refer to it as ADL, viz:

Code:
import ADL

ADL.SetupADL(0)
print ADL.getTemp()
print ADL.getCoreClockSpeed()
print ADL.getMemoryClockSpeed()
ADL.setMemoryClockSpeed(0,300)
ADL.setMemoryClockSpeed(1,300)
ADL.setMemoryClockSpeed(2,300)

I'm not sure what the levels refer to, but it would probably be clear if I read the SDK notes.  At any rate, it appears that level 2 is the one that is engaged on the GPUs while mining under full load.
hero member
Activity: 726
Merit: 500
May 18, 2011, 12:31:15 AM
#6
Now all this is a wrapper for AMDOverdriveCtrl ( http://amdovdrvctrl.sourceforge.net/ ) all I have done is turned it into a python extended library, all ADL code is by Thorsten Gilling.

I'm a bit confused.  Do I still need AMDOverdriveCtrl compiled and running on my system in order to use pyADL?  I've been unable to get AMDOverdriveCtrl to compile because of wxWidgets.
member
Activity: 78
Merit: 10
May 17, 2011, 09:59:48 PM
#5
I was contemplating writing this exact thing.  Thank you.  Will check it out.
Pages:
Jump to: