Added some tests have to correct cpupowerdraw

This commit is contained in:
Eduardo Cueto Mendoza 2020-07-02 00:05:25 -06:00
parent 1555daf193
commit 4d42dd52c0
2 changed files with 23 additions and 6 deletions

View File

@ -1,3 +1,15 @@
struct NoNvidiaSMI <: Exception
var::Symbol
end
Base.showerror(io::IO, e::NoNvidiaSMI) = print(io, e.var)
struct NoPowerStat <: Exception
var::Symbol
end
Base.showerror(io::IO, e::NoPowerStat) = print(io, e.var)
"""
gpupowerdraw()::Float64
@ -57,7 +69,7 @@ function gpupowerdraw()
end
return nogpus, mean(usage), mean(cap)
else
@info "This computer does not have acces to a GPU passing to CPU and RAM computations"
throw(NoNvidiaSMI("there is no nvidia-smi installed")) #@info "This computer does not have acces to a GPU passing to CPU and RAM computations"
end
end
@ -68,17 +80,17 @@ end
This function uses the Linux `powerstat` utility to get the average CPU energy cost.
"""
function cpupowerdraw()
cpucommand = `powerstat -R -n -d0`
try
cpucommand = `powerstat -R -n -d0`
cpu = read(cpucommand, String);
cpu = split(cpu,"\n")
cpu = cpu[66][60:64]
return parse(Float64,cpu)
catch e
@info "powerstat not installed in your computer"
@info "powerstat not installed in your computer" #throw(NoPowerStat("there is no powerstat installed"))
end
end
end
#TODO: further fine tune the model

View File

@ -1,6 +1,11 @@
using GreenFlux
using Test
using Flux
@testset "GreenFlux.jl" begin
# Write your tests here.
convol = Conv((15,15),1=>2,tand)
dense = Dense(23,31,gelu)
@test_throws GreenFlux.NoNvidiaSMI avgpowerdraw()
@test_throws GreenFlux.NoPowerStat avgpowerdraw()
@test typeof(avgpowerdraw()) <: Float64
end