Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: GPUOptions for Go binding #22926

Open
mattn opened this issue Oct 12, 2018 · 13 comments
Open

Feature Request: GPUOptions for Go binding #22926

mattn opened this issue Oct 12, 2018 · 13 comments

Comments

@mattn
Copy link
Contributor

@mattn mattn commented Oct 12, 2018

Current implementation of Go binding can not specify options.

GPUOptions struct is in internal package. And go generate doesn't work for protobuf directory. So we can't specify GPUOptions for NewSession.

@tensorflowbutler

Loading…

Member

@tensorflowbutler tensorflowbutler commented Oct 12, 2018

Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks.
Have I written custom code
OS Platform and Distribution
TensorFlow installed from
TensorFlow version
Bazel version
CUDA/cuDNN version
GPU model and memory
Exact command to reproduce
Mobile device

@frreiss

Loading…

Contributor

@frreiss frreiss commented Dec 3, 2018

This problem appears to be broader than just specifying GPUOptions for TensorFlow sessions. There is no native Go API for passing any options when creating a session. The user must create the binary representation of a ConfigProto protocol buffer outside of the TensorFlow Go API.

See, for example, the test case TestSessionConfig in session_test.go:

func TestSessionConfig(t *testing.T) {
	// Exercise SessionOptions.
	// Arguably, a better API would be for SessionOptions.Config to be the
	// type generated by the protocol buffer compiler. But for now, the
	// tensorflow package continues to be independent of protocol buffers
	// and this test exercises the option since the implementation has a
	// nuanced conversion to C types.
	//
	// Till then, the []byte form of Config here was generated using a toy
	// tensorflow Python program:
	/*
	 import tensorflow
	 c = tensorflow.ConfigProto()
	 c.intra_op_parallelism_threads = 1
	 print c.SerializeToString()
	*/
	graph := NewGraph()
	c, err := Const(graph, "Const", int32(14))
	if err != nil {
		t.Fatal(err)
	}
	opts := SessionOptions{Config: []byte("(\x01")}
[...]

Would the TensorFlow maintainers accept a non-Google contribution that added the ability to specify session options using pure Go code? This functionality would require generating instances of the ConfigProto protocol buffer defined in config.proto. I can see two ways to generate these protocol buffers: Either add a build target to generate Go bindings for the files in tensorflow/core/protobuf; or add Go wrappers for the generated C++ code in tensorflow/core/protobuf/config.pb.h

@ymodak ymodak added the type:feature label Dec 3, 2018
@ymodak

Loading…

Contributor

@ymodak ymodak commented Dec 3, 2018

@asimshankar Can you please take a look? Thanks!

@alextp

Loading…

Member

@alextp alextp commented Mar 4, 2019

@frreiss we'll definitely accept a Go-only API to configure tensorflow.

@frreiss

Loading…

Contributor

@frreiss frreiss commented Mar 13, 2019

I am looking into this.

@frreiss

Loading…

Contributor

@frreiss frreiss commented Mar 13, 2019

Created PR #26682 with a Go API to create ConfigOptions protocol buffer messages. I made the changes as narrow in scope as I could.

@mattn

Loading…

Contributor Author

@mattn mattn commented Mar 30, 2019

Closed by #26682

@frreiss Thank you

@mattn mattn closed this Mar 30, 2019
@mattn

Loading…

Contributor Author

@mattn mattn commented Apr 5, 2019

@mattn mattn reopened this Apr 5, 2019
@imrahul361

Loading…

@imrahul361 imrahul361 commented Sep 28, 2020

is this issue open? Can i work on it? @mattn

@mattn

Loading…

Contributor Author

@mattn mattn commented Sep 30, 2020

Yes please.

@imrahul361

Loading…

@imrahul361 imrahul361 commented Oct 1, 2020

May I know how to reproduce the issue?

@mattn

Loading…

Contributor Author

@mattn mattn commented Oct 1, 2020

Sorry, I don't know why the changes was reverted.

#26682 (comment)

@imrahul361

Loading…

@imrahul361 imrahul361 commented Oct 1, 2020

ok no problem I will try some other issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants
You can’t perform that action at this time.