Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TensorFlow check which protobuf implementation is being used

Is there a way to check which protobuf implementation is used by TensorFlow (i.e. if it is using the C++ version or the Python one)?

like image 870
user3504575 Avatar asked Aug 22 '16 12:08

user3504575


2 Answers

@keveman's answer tells us the default implementation but not the active implementation.

Importantly, the PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION environment variable affects which implementation is active so

PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp python -c "from google.protobuf.internal import api_implementation; print(api_implementation._default_implementation_type)"

and

PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python python -c "from google.protobuf.internal import api_implementation; print(api_implementation._default_implementation_type)"

will always show the same result.

To see which implementation is active, use this instead:

python -c "from google.protobuf.internal import api_implementation; print(api_implementation.Type())"

Changing the PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION environment variable will cause the result of Type() to change where it didn't for _default_implementation_type.

like image 151
Daniel Renshaw Avatar answered Sep 24 '22 15:09

Daniel Renshaw


Try the following :

$ python -c "from google.protobuf.internal import api_implementation; print(api_implementation._default_implementation_type)"

It should print either python or cpp.

like image 29
keveman Avatar answered Sep 26 '22 15:09

keveman