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
|
struct NoNvidiaSMI <: Exception
|
||||||
var::Symbol
|
var::String
|
||||||
end
|
end
|
||||||
|
|
||||||
Base.showerror(io::IO, e::NoNvidiaSMI) = print(io, e.var)
|
Base.showerror(io::IO, e::NoNvidiaSMI) = print(io, e.var)
|
||||||
|
|
||||||
struct NoPowerStat <: Exception
|
struct NoPowerStat <: Exception
|
||||||
var::Symbol
|
var::String
|
||||||
end
|
end
|
||||||
|
|
||||||
Base.showerror(io::IO, e::NoPowerStat) = print(io, e.var)
|
Base.showerror(io::IO, e::NoPowerStat) = print(io, e.var)
|
||||||
@ -87,8 +87,8 @@ function cpupowerdraw()
|
|||||||
cpu = cpu[66][60:64]
|
cpu = cpu[66][60:64]
|
||||||
|
|
||||||
return parse(Float64,cpu)
|
return parse(Float64,cpu)
|
||||||
catch e
|
finally
|
||||||
@info "powerstat not installed in your computer" #throw(NoPowerStat("there is no powerstat installed"))
|
throw(NoPowerStat("there is no powerstat installed")) #@info "powerstat not installed in your computer"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -102,19 +102,24 @@ ratio of activated memory against the unactivated for the maximum power value an
|
|||||||
to hours.
|
to hours.
|
||||||
"""
|
"""
|
||||||
function rampowerdraw()
|
function rampowerdraw()
|
||||||
ramcommand = `free`
|
try
|
||||||
powerused = Array{Float64}(undef,60)
|
ramcommand = `free`
|
||||||
for count in 1:60
|
powerused = Array{Float64}(undef,60)
|
||||||
ram = read(ramcommand, String);
|
for count in 1:60
|
||||||
ram = split(ram,"\n")
|
ram = read(ramcommand, String);
|
||||||
ram = split(ram[2]," ")
|
ram = split(ram,"\n")
|
||||||
filter!(x->x≠"",ram)
|
ram = split(ram[2]," ")
|
||||||
usedram = parse(Float64,ram[3])
|
filter!(x->x≠"",ram)
|
||||||
totalram = parse(Float64,ram[2])
|
usedram = parse(Float64,ram[3])
|
||||||
powerused[count] = ((usedram*1.575)/totalram)*1.904
|
totalram = parse(Float64,ram[2])
|
||||||
sleep(1)
|
powerused[count] = ((usedram*1.575)/totalram)*1.904
|
||||||
|
sleep(1)
|
||||||
|
end
|
||||||
|
return mean(powerused)
|
||||||
|
catch e
|
||||||
|
finally
|
||||||
|
return 0.0
|
||||||
end
|
end
|
||||||
return mean(powerused)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -133,18 +138,28 @@ returns the average power consumption in kWh.
|
|||||||
"""
|
"""
|
||||||
function avgpowerdraw()
|
function avgpowerdraw()
|
||||||
if has_cuda_gpu()
|
if has_cuda_gpu()
|
||||||
starttime = time()
|
try
|
||||||
g, pg, _ = gpupowerdraw()
|
starttime = time()
|
||||||
pc = cpupowerdraw()
|
g, pg, _ = gpupowerdraw()
|
||||||
pr = rampowerdraw()
|
pc = cpupowerdraw()
|
||||||
endtime = time()
|
pr = rampowerdraw()
|
||||||
elapsedtime = (endtime - starttime)/3600
|
endtime = time()
|
||||||
return 1.58*elapsedtime*(pc + pr + g*pg)/1000
|
elapsedtime = (endtime - starttime)/3600
|
||||||
|
return 1.58*elapsedtime*(pc + pr + g*pg)/1000
|
||||||
|
catch e
|
||||||
|
finally
|
||||||
|
return 0.0
|
||||||
|
end
|
||||||
else
|
else
|
||||||
pc = cpupowerdraw()
|
try
|
||||||
pr = rampowerdraw()
|
pc = cpupowerdraw()
|
||||||
endtime = time()
|
pr = rampowerdraw()
|
||||||
elapsedtime = (endtime - starttime)/3600
|
endtime = time()
|
||||||
return 1.58*elapsedtime*(pc + pr)/1000
|
elapsedtime = (endtime - starttime)/3600
|
||||||
|
return 1.58*elapsedtime*(pc + pr)/1000
|
||||||
|
catch e
|
||||||
|
finally
|
||||||
|
return 0.0
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -5,7 +5,30 @@ using Flux
|
|||||||
@testset "GreenFlux.jl" begin
|
@testset "GreenFlux.jl" begin
|
||||||
convol = Conv((15,15),1=>2,tand)
|
convol = Conv((15,15),1=>2,tand)
|
||||||
dense = Dense(23,31,gelu)
|
dense = Dense(23,31,gelu)
|
||||||
@test_throws GreenFlux.NoNvidiaSMI avgpowerdraw()
|
maxpoo = MaxPool((12,65))
|
||||||
@test_throws GreenFlux.NoPowerStat avgpowerdraw()
|
#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(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
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user