Merge pull request #15 from EddieCueto/bugsolving
Solved bug with GPU and RAM power calculations
This commit is contained in:
commit
f3b5ec240b
|
@ -1,7 +1,7 @@
|
||||||
name = "GreenFlux"
|
name = "GreenFlux"
|
||||||
uuid = "ccad5352-7643-4eb2-b711-e9c298e87bf0"
|
uuid = "ccad5352-7643-4eb2-b711-e9c298e87bf0"
|
||||||
authors = ["Eduardo Cueto Mendoza"]
|
authors = ["Eduardo Cueto Mendoza"]
|
||||||
version = "0.1.0"
|
version = "0.0.4"
|
||||||
|
|
||||||
[deps]
|
[deps]
|
||||||
CUDAapi = "3895d2a7-ec45-59b8-82bb-cfc6a382f9b3"
|
CUDAapi = "3895d2a7-ec45-59b8-82bb-cfc6a382f9b3"
|
||||||
|
|
|
@ -34,17 +34,20 @@ function gpupowerdraw()
|
||||||
usagestr = ""
|
usagestr = ""
|
||||||
capstr = ""
|
capstr = ""
|
||||||
if g[5] == "N/A"
|
if g[5] == "N/A"
|
||||||
usagestr = "0.0"
|
usagestr = "0W"
|
||||||
else
|
else
|
||||||
usagestr = usagestr * g[5]
|
usagestr = usagestr * g[5]
|
||||||
end
|
end
|
||||||
if g[7] == "N/A"
|
if g[7] == "N/A"
|
||||||
capstr = "0.0"
|
capstr = "0W"
|
||||||
else
|
else
|
||||||
capstr = capstr * g[7]
|
capstr = capstr * g[7]
|
||||||
end
|
end
|
||||||
powerdraw = vcat(powerdraw, parse(Float64,usagestr))
|
regexw = r"(\d+)"
|
||||||
powercap = vcat(powercap, parse(Float64,capstr))
|
wattusg = match(regexw,usagestr)
|
||||||
|
wattcap = match(regexw,capstr)
|
||||||
|
powerdraw = vcat(powerdraw, parse(Float64,wattusg.match))
|
||||||
|
powercap = vcat(powercap, parse(Float64,wattcap.match))
|
||||||
end
|
end
|
||||||
usage[count] = mean(powerdraw)
|
usage[count] = mean(powerdraw)
|
||||||
cap[count] = mean(powercap)
|
cap[count] = mean(powercap)
|
||||||
|
@ -73,20 +76,26 @@ end
|
||||||
rampowerdraw()::Float64
|
rampowerdraw()::Float64
|
||||||
|
|
||||||
[Approximate RAM Power Draw](https://www.jedec.org/) the values are provided by the JEDEC we just take the
|
[Approximate RAM Power Draw](https://www.jedec.org/) the values are provided by the JEDEC we just take the
|
||||||
ratio of activated memory against the unactivated for the maximum power value and convert it
|
average of the total RAM with its Watt value to get the approximate power draw.
|
||||||
to hours.
|
|
||||||
"""
|
"""
|
||||||
function rampowerdraw()
|
function rampowerdraw(ramtype="DDR3")
|
||||||
ramcommand = `free`
|
ramcommand = `free -m`
|
||||||
powerused = Array{Float64}(undef,60)
|
powerused = Array{Float64}(undef,60)
|
||||||
for count in 1:60
|
for count in 1:60
|
||||||
ram = read(ramcommand, String);
|
ram = read(ramcommand, String);
|
||||||
ram = split(ram,"\n")
|
ram = split(ram,"\n")
|
||||||
ram = split(ram[2]," ")
|
ram = split(ram[2]," ")
|
||||||
filter!(x->x≠"",ram)
|
filter!(x->x≠"",ram)
|
||||||
usedram = parse(Float64,ram[3])
|
|
||||||
totalram = parse(Float64,ram[2])
|
totalram = parse(Float64,ram[2])
|
||||||
powerused[count] = ((usedram*1.575)/totalram)*1.904
|
if ramtype == "DDR3"
|
||||||
|
powerused[count] = (totalram/1024)*0.3125
|
||||||
|
elseif ramtype == "DDR2"
|
||||||
|
powerused[count] = (totalram/1024)*0.625
|
||||||
|
elseif ramtype == "DDR"
|
||||||
|
powerused[count] = (totalram/1024)*6.5
|
||||||
|
else
|
||||||
|
error("$ramtype unrecognized RAM type.")
|
||||||
|
end
|
||||||
sleep(1)
|
sleep(1)
|
||||||
end
|
end
|
||||||
return mean(powerused)
|
return mean(powerused)
|
||||||
|
@ -105,8 +114,10 @@ the number of available gpus.
|
||||||
`apd = 1.58*t*(pc + pr + g*pg)/1000`
|
`apd = 1.58*t*(pc + pr + g*pg)/1000`
|
||||||
|
|
||||||
returns the average power consumption in kWh.
|
returns the average power consumption in kWh.
|
||||||
|
|
||||||
|
By default it assumes you use `"DDR3"` memory but you can pass `"DDR2"` or `"DDR"` to get a better estimate.
|
||||||
"""
|
"""
|
||||||
function avgpowerdraw()
|
function avgpowerdraw(freeram="DDR3")
|
||||||
g, pg, pc, pr = 0.0, 0.0, 0.0, 0.0
|
g, pg, pc, pr = 0.0, 0.0, 0.0, 0.0
|
||||||
starttime = time()
|
starttime = time()
|
||||||
try
|
try
|
||||||
|
@ -122,12 +133,12 @@ function avgpowerdraw()
|
||||||
return 0.0
|
return 0.0
|
||||||
end
|
end
|
||||||
try
|
try
|
||||||
pr = rampowerdraw()
|
pr = rampowerdraw(freeram)
|
||||||
catch ex
|
catch ex
|
||||||
println(ex.msg)
|
println(ex.msg)
|
||||||
return 0.0
|
return 0.0
|
||||||
end
|
end
|
||||||
endtime = time()
|
endtime = time()
|
||||||
elapsedtime = (endtime - starttime)/3600
|
elapsedtime = (endtime - starttime)*0.0002777778
|
||||||
return 1.58*elapsedtime*(pc + pr + g*pg)/1000
|
return 1.58*elapsedtime*(pc + pr + g*pg)/1000
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue