public static byte[] ToProtobuf(this ConfigProto cp) { using (MemoryStream ms = new MemoryStream()) using (pb::CodedOutputStream stream = new pb::CodedOutputStream(ms)) { cp.WriteTo(stream); stream.Flush(); return(ms.ToArray()); } }
public void TestCUDAEnabled() { bool cuda = TfInvoke.IsGoogleCudaEnabled; Tensorflow.ConfigProto config = new Tensorflow.ConfigProto(); config.LogDevicePlacement = true; byte[] pbuff; using (MemoryStream ms = new MemoryStream()) { config.WriteTo(ms); pbuff = ms.ToArray(); } SessionOptions options = new SessionOptions(); options.SetConfig(pbuff); Add(3, 4, options); }