Fetched master and solved conflicts

This commit is contained in:
Eduardo Cueto Mendoza 2020-07-05 19:31:40 -06:00
commit 3402803a5a
5 changed files with 140 additions and 111 deletions

View File

@ -1,23 +1,48 @@
name: CI
on:
- push
- pull_request
push:
branches:
- master
pull_request:
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow-failure }}
strategy:
fail-fast: false # don't stop CI even when one of them fails
matrix:
version:
- '1.0'
- '1.4'
- 'nightly'
os:
- ubuntu-latest
- macOS-latest
# - windows-latest # TODO: test on Windows
arch:
- x64
- x86
# - x86
allow-failure: [false]
# include:
# - version: 'nightly'
# os: ubuntu-latest
# arch: x64
# allow-failure: true
# - version: 'nightly'
# os: ubuntu-latest
# arch: x86
# allow-failure: true
# - version: 'nightly'
# os: macOS-latest
# arch: x64
# allow-failure: true
# - version: 'nightly'
# os: windows-latest
# arch: x64
# allow-failure: true
# - version: 'nightly'
# os: windows-latest
# arch: x86
# allow-failure: true
exclude:
- os: macOS-latest
arch: x86
@ -27,39 +52,13 @@ jobs:
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: actions/cache@v1
env:
cache-name: cache-artifacts
with:
path: ~/.julia/artifacts
key: ${{ runner.os }}-test-${{ env.cache-name }}-${{ hashFiles('**/Project.toml') }}
restore-keys: |
${{ runner.os }}-test-${{ env.cache-name }}-
${{ runner.os }}-test-
${{ runner.os }}-
- uses: julia-actions/julia-buildpkg@latest
- uses: julia-actions/julia-runtest@latest
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v1
with:
file: lcov.info
- uses: julia-actions/julia-uploadcoveralls@latest
env:
COVERALLS_TOKEN: ${{ secrets.COVERALLS_TOKEN }}
docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: julia-actions/setup-julia@v1
with:
version: '1'
- run: |
julia --project=docs -e '
using Pkg
Pkg.develop(PackageSpec(path=pwd()))
Pkg.instantiate()'
- run: julia --project=docs docs/make.jl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCUMENTER_KEY: ${{ secrets.DOCUMENTER_KEY }}
file: ./lcov.info
flags: unittests
name: codecov-umbrella
fail_ci_if_error: false
token: ${{ secrets.CODECOV_TOKEN }}

View File

@ -2,6 +2,7 @@
<img width="400px" src="green-flux-logo.png"/>
</p>
[![Build Status](https://github.com/EddieCueto/GreenFlux.jl/workflows/CI/badge.svg)](https://github.com/EddieCueto/GreenFlux.jl/actions)
[![Stable](https://img.shields.io/badge/docs-stable-blue.svg)](https://EddieCueto.github.io/GreenFlux.jl/stable)
[![Dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://EddieCueto.github.io/GreenFlux.jl/dev)
[![Build Status](https://travis-ci.com/EddieCueto/GreenFlux.jl.svg?branch=master)](https://travis-ci.com/EddieCueto/GreenFlux.jl)

View File

@ -34,6 +34,7 @@ function layerflops(layer::Dense,input::Tuple)
return convert(Float64,((2*Mi*N - M)+bi)*noofopers*Fm), out
end
# TODO: Maxout for more that one layer Maxout
function layerflops(layer::Maxout,input::Tuple)
i = 0; j = 0; Fm = 1
if length(input) == 3

View File

@ -5,60 +5,52 @@ The function uses Linux `nvidia-smi` package to sample and get the average elect
draw of the GPUs.
"""
function gpupowerdraw()
if has_cuda_gpu()
gpucommand = `nvidia-smi`
usage = Array{Any}(undef,60)
cap = Array{Any}(undef,60)
nogpus = 0
gpucommand = `nvidia-smi`
usage = Array{Any}(undef,60)
cap = Array{Any}(undef,60)
nogpus = 0
for count in 1:60
smis = Array{Any}[]
smiss = Array{Any}[]
gpus = Array{Any}[]
powerdraw = Array{Float64}[]
powercap = Array{Float64}[]
smi = read(gpucommand, String);
smi = split(smi, "\n")
for s in smi
push!(smis,split(s, " "))
end
for s in smis
push!(smiss,filter(x->x≠"",s))
end
for strings in smiss
if length(strings) > 5 && strings[6] == "/" && strings[10] == "/"
push!(gpus,strings)
end
end
nogpus = length(gpus)
for g in gpus
usagestr = ""
capstr = ""
if g[5] == "N/A"
usagestr = "0.0"
else
usagestr = usagestr * g[5]
end
if g[7] == "N/A"
capstr = "0.0"
else
capstr = capstr * g[7]
end
powerdraw = vcat(powerdraw, parse(Float64,usagestr))
powercap = vcat(powercap, parse(Float64,capstr))
end
usage[count] = mean(powerdraw)
cap[count] = mean(powercap)
sleep(1)
for count in 1:60
smis = Array{Any}[]
smiss = Array{Any}[]
gpus = Array{Any}[]
powerdraw = Array{Float64}[]
powercap = Array{Float64}[]
smi = read(gpucommand, String);
smi = split(smi, "\n")
for s in smi
push!(smis,split(s, " "))
end
return nogpus, mean(usage), mean(cap)
else
@info "This computer does not have acces to a GPU passing to CPU and RAM computations"
for s in smis
push!(smiss,filter(x->x≠"",s))
end
for strings in smiss
if length(strings) > 5 && strings[6] == "/" && strings[10] == "/"
push!(gpus,strings)
end
end
nogpus = length(gpus)
for g in gpus
usagestr = ""
capstr = ""
if g[5] == "N/A"
usagestr = "0.0"
else
usagestr = usagestr * g[5]
end
if g[7] == "N/A"
capstr = "0.0"
else
capstr = capstr * g[7]
end
powerdraw = vcat(powerdraw, parse(Float64,usagestr))
powercap = vcat(powercap, parse(Float64,capstr))
end
usage[count] = mean(powerdraw)
cap[count] = mean(powercap)
sleep(1)
end
return nogpus, mean(usage), mean(cap)
end
@ -69,16 +61,11 @@ This function uses the Linux `powerstat` utility to get the average CPU energy c
"""
function cpupowerdraw()
cpucommand = `powerstat -R -n -d0`
try
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"
end
end
cpu = read(cpucommand, String);
cpu = split(cpu,"\n")
cpu = cpu[66][60:64]
return parse(Float64,cpu)
end
#TODO: further fine tune the model
@ -120,19 +107,27 @@ the number of available gpus.
returns the average power consumption in kWh.
"""
function avgpowerdraw()
if has_cuda_gpu()
starttime = time()
g, pg, pc, pr = 0.0, 0.0, 0.0, 0.0
starttime = time()
try
g, pg, _ = gpupowerdraw()
pc = cpupowerdraw()
pr = rampowerdraw()
endtime = time()
elapsedtime = (endtime - starttime)/3600
return 1.58*elapsedtime*(pc + pr + g*pg)/1000
else
pc = cpupowerdraw()
pr = rampowerdraw()
endtime = time()
elapsedtime = (endtime - starttime)/3600
return 1.58*elapsedtime*(pc + pr)/1000
catch ex
println(ex.msg)
return 0.0
end
try
pc = cpupowerdraw()
catch ex
println(ex.msg)
return 0.0
end
try
pr = rampowerdraw()
catch ex
println(ex.msg)
return 0.0
end
endtime = time()
elapsedtime = (endtime - starttime)/3600
return 1.58*elapsedtime*(pc + pr + g*pg)/1000
end

View File

@ -1,6 +1,39 @@
using GreenFlux
using Test
using Flux
@testset "GreenFlux.jl" begin
# Write your tests here.
convol = Conv((15,15),4=>2,tanh)
dense = Dense(23,31,gelu)
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,identity)
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)
maxo = Maxout((12,12))
if Sys.isapple()
@test_throws Base.IOError GreenFlux.gpupowerdraw()
@test_throws Base.IOError GreenFlux.cpupowerdraw()
@test_throws Base.IOError GreenFlux.rampowerdraw()
end
if Sys.islinux()
@test typeof(avgpowerdraw()) <: Float64
end
@test GreenFlux.layerflops(convol,(28,28)) == (354368.0, (14, 14, 2))
@test GreenFlux.layerflops(dense,(4,4)) == (2304.0, (31, 1))
@test GreenFlux.layerflops(maxpoo,(100,100)) == (6240.0, (8, 1))
@test GreenFlux.layerflops(mpool,(8,8)) == (36.0, (2, 2))
@test GreenFlux.layerflops(dconv,(30,30)) == (177600.0, (10, 10, 6))
@test GreenFlux.layerflops(ctrans,(6,6)) == (56736.0, (12, 12, 2))
@test GreenFlux.layerflops(cc,(3,3)) == (224.0, (2, 2, 16))
@test GreenFlux.layerflops(gr,(77,77)) == (6099.0, (24, 1))
@test GreenFlux.layerflops(lst,(8,8)) == (1968.0, (12, 1))
@test GreenFlux.layerflops(rn,(4,4)) == (546.0, (6, 1))
@test GreenFlux.layerflops(maxo,(5,5)) == (3600.0, (5, 1))
end