Skip to content

Commit

Permalink
Stop gap capturing of TF attrs
Browse files Browse the repository at this point in the history
This is a temporary hack and doesn't go through the runtime layer but
we needed to get this in for 0.1.0. Comment to that effect included.
  • Loading branch information
Garrett Smith committed Jan 16, 2017
1 parent 37beb1d commit f06e587
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
11 changes: 11 additions & 0 deletions priv/bin/tensorflow-attrs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python

import sys

try:
import tensorflow as tf
except ImportError:
pass
else:
sys.stdout.write("tensorflow_version=%s\n" % tf.__version__)
sys.stdout.flush()
27 changes: 26 additions & 1 deletion src/guild_log_system_attrs_task.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ init([Op]) ->
{ok, #state{rundir=RunDir}}.

handle_task(#state{rundir=RunDir}) ->
Attrs = sys_attrs() ++ gpu_attrs(),
Attrs = sys_attrs() ++ gpu_attrs() ++ runtime_attrs(),
guild_run_db:log_attrs(RunDir, Attrs),
{stop, normal}.

Expand All @@ -56,3 +56,28 @@ apply_gpu_attrs(Attrs, Acc) ->
[{Key("name"), Name},
{Key("memory"), Memory}
|Acc].

runtime_attrs() ->
%% TODO: We're cheating here and hard-coding a TF function but
%% this needs to come from the associated model via an appropriate
%% lookup.
Bin = guild_app:priv_bin("tensorflow-attrs"),
case exec:run(Bin, [stdout, stderr, sync]) of
{ok, Result} ->
parse_tensorflow_attrs(proplists:get_value(stdout, Result));
{error, Result} ->
guild_log:internal(
"ERROR reading TensorFlow stats:~n~p~n", [Result]),
[]
end.

parse_tensorflow_attrs(undefined) ->
[];
parse_tensorflow_attrs(Out) ->
[parse_attr(Line) || Line <- split_lines(Out)].

split_lines(Out) -> re:split(Out, "\n", [trim]).

parse_attr(Line) ->
[Key, Val] = re:split(Line, "=", [{parts, 2}]),
{Key, Val}.

0 comments on commit f06e587

Please sign in to comment.