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,6 +102,7 @@ ratio of activated memory against the unactivated for the maximum power value an
|
||||
to hours.
|
||||
"""
|
||||
function rampowerdraw()
|
||||
try
|
||||
ramcommand = `free`
|
||||
powerused = Array{Float64}(undef,60)
|
||||
for count in 1:60
|
||||
@ -115,6 +116,10 @@ function rampowerdraw()
|
||||
sleep(1)
|
||||
end
|
||||
return mean(powerused)
|
||||
catch e
|
||||
finally
|
||||
return 0.0
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -133,6 +138,7 @@ returns the average power consumption in kWh.
|
||||
"""
|
||||
function avgpowerdraw()
|
||||
if has_cuda_gpu()
|
||||
try
|
||||
starttime = time()
|
||||
g, pg, _ = gpupowerdraw()
|
||||
pc = cpupowerdraw()
|
||||
@ -140,11 +146,20 @@ function avgpowerdraw()
|
||||
endtime = time()
|
||||
elapsedtime = (endtime - starttime)/3600
|
||||
return 1.58*elapsedtime*(pc + pr + g*pg)/1000
|
||||
catch e
|
||||
finally
|
||||
return 0.0
|
||||
end
|
||||
else
|
||||
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
Block a user