Changed and added try statemets to power draw functions, some failing layer tests
This commit is contained in:
parent
4d42dd52c0
commit
63caa4fdf6
|
@ -1,11 +1,11 @@
|
|||
struct NoNvidiaSMI <: Exception
|
||||
var::Symbol
|
||||
var::String
|
||||
end
|
||||
|
||||
Base.showerror(io::IO, e::NoNvidiaSMI) = print(io, e.var)
|
||||
|
||||
struct NoPowerStat <: Exception
|
||||
var::Symbol
|
||||
var::String
|
||||
end
|
||||
|
||||
Base.showerror(io::IO, e::NoPowerStat) = print(io, e.var)
|
||||
|
@ -87,8 +87,8 @@ function cpupowerdraw()
|
|||
cpu = cpu[66][60:64]
|
||||
|
||||
return parse(Float64,cpu)
|
||||
catch e
|
||||
@info "powerstat not installed in your computer" #throw(NoPowerStat("there is no powerstat installed"))
|
||||
finally
|
||||
throw(NoPowerStat("there is no powerstat installed")) #@info "powerstat not installed in your computer"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -102,19 +102,24 @@ ratio of activated memory against the unactivated for the maximum power value an
|
|||
to hours.
|
||||
"""
|
||||
function rampowerdraw()
|
||||
ramcommand = `free`
|
||||
powerused = Array{Float64}(undef,60)
|
||||
for count in 1:60
|
||||
ram = read(ramcommand, String);
|
||||
ram = split(ram,"\n")
|
||||
ram = split(ram[2]," ")
|
||||
filter!(x->x≠"",ram)
|
||||
usedram = parse(Float64,ram[3])
|
||||
totalram = parse(Float64,ram[2])
|
||||
powerused[count] = ((usedram*1.575)/totalram)*1.904
|
||||
sleep(1)
|
||||
try
|
||||
ramcommand = `free`
|
||||
powerused = Array{Float64}(undef,60)
|
||||
for count in 1:60
|
||||
ram = read(ramcommand, String);
|
||||
ram = split(ram,"\n")
|
||||
ram = split(ram[2]," ")
|
||||
filter!(x->x≠"",ram)
|
||||
usedram = parse(Float64,ram[3])
|
||||
totalram = parse(Float64,ram[2])
|
||||
powerused[count] = ((usedram*1.575)/totalram)*1.904
|
||||
sleep(1)
|
||||
end
|
||||
return mean(powerused)
|
||||
catch e
|
||||
finally
|
||||
return 0.0
|
||||
end
|
||||
return mean(powerused)
|
||||
end
|
||||
|
||||
|
||||
|
@ -133,18 +138,28 @@ returns the average power consumption in kWh.
|
|||
"""
|
||||
function avgpowerdraw()
|
||||
if has_cuda_gpu()
|
||||
starttime = time()
|
||||
g, pg, _ = gpupowerdraw()
|
||||
pc = cpupowerdraw()
|
||||
pr = rampowerdraw()
|
||||
endtime = time()
|
||||
elapsedtime = (endtime - starttime)/3600
|
||||
return 1.58*elapsedtime*(pc + pr + g*pg)/1000
|
||||
try
|
||||
starttime = time()
|
||||
g, pg, _ = gpupowerdraw()
|
||||
pc = cpupowerdraw()
|
||||
pr = rampowerdraw()
|
||||
endtime = time()
|
||||
elapsedtime = (endtime - starttime)/3600
|
||||
return 1.58*elapsedtime*(pc + pr + g*pg)/1000
|
||||
catch e
|
||||
finally
|
||||
return 0.0
|
||||
end
|
||||
else
|
||||
pc = cpupowerdraw()
|
||||
pr = rampowerdraw()
|
||||
endtime = time()
|
||||
elapsedtime = (endtime - starttime)/3600
|
||||
return 1.58*elapsedtime*(pc + pr)/1000
|
||||
try
|
||||
pc = cpupowerdraw()
|
||||
pr = rampowerdraw()
|
||||
endtime = time()
|
||||
elapsedtime = (endtime - starttime)/3600
|
||||
return 1.58*elapsedtime*(pc + pr)/1000
|
||||
catch e
|
||||
finally
|
||||
return 0.0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -5,7 +5,30 @@ using Flux
|
|||
@testset "GreenFlux.jl" begin
|
||||
convol = Conv((15,15),1=>2,tand)
|
||||
dense = Dense(23,31,gelu)
|
||||
@test_throws GreenFlux.NoNvidiaSMI avgpowerdraw()
|
||||
@test_throws GreenFlux.NoPowerStat avgpowerdraw()
|
||||
maxpoo = MaxPool((12,65))
|
||||
#TODO: GlobalMaxPool
|
||||
mpool = MeanPool((3,3))
|
||||
#TODO: GlobalMeanPool
|
||||
dconv = DepthwiseConv((21,21),6=>12,relu)
|
||||
ctrans = ConvTranspose((7,7),2=>4,tan)
|
||||
cc = CrossCor((2, 2), 1=>16, relu6)
|
||||
gr = GRU(4,8)
|
||||
lst = LSTM(3,3)
|
||||
rn = RNN(3,6)
|
||||
maxo = Maxout(()->Dense(35, 27), 4)
|
||||
@test_throws GreenFlux.NoNvidiaSMI GreenFlux.gpupowerdraw()
|
||||
@test_throws GreenFlux.NoPowerStat GreenFlux.cpupowerdraw()
|
||||
@test typeof(GreenFlux.rampowerdraw()) <: Float64
|
||||
@test typeof(avgpowerdraw()) <: Float64
|
||||
@test typeof(GreenFlux.layerflops(convol,(2,2))) == Tuple{Float64,Tuple{Int64,Int64}}
|
||||
@test typeof(GreenFlux.layerflops(dense,(4,4))) == Tuple{Float64,Tuple{Int64,Int64}}
|
||||
@test typeof(GreenFlux.layerflops(maxpoo,(9,9))) == Tuple{Float64,Tuple{Int64,Int64}}
|
||||
@test typeof(GreenFlux.layerflops(mpool,(2,2))) == Tuple{Float64,Tuple{Int64,Int64}}
|
||||
@test typeof(GreenFlux.layerflops(dconv,(1,1))) == Tuple{Float64,Tuple{Int64,Int64}}
|
||||
@test typeof(GreenFlux.layerflops(ctrans,(6,6))) == Tuple{Float64,Tuple{Int64,Int64}}
|
||||
@test typeof(GreenFlux.layerflops(cc,(3,3))) == Tuple{Float64,Tuple{Int64,Int64}}
|
||||
@test typeof(GreenFlux.layerflops(gr,(77,77))) == Tuple{Float64,Tuple{Int64,Int64}}
|
||||
@test typeof(GreenFlux.layerflops(lst,(8,8))) == Tuple{Float64,Tuple{Int64,Int64}}
|
||||
@test typeof(GreenFlux.layerflops(rn,(4,4))) == Tuple{Float64,Tuple{Int64,Int64}}
|
||||
@test typeof(GreenFlux.layerflops(maxo,(5,5))) == Tuple{Float64,Tuple{Int64,Int64}}
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue