TensorFlow检查正在使用哪个protobuf实现

use*_*575 3 installation protocol-buffers tensorflow

有没有办法检查TensorFlow使用哪种protobuf实现(即,是使用C ++版本还是使用Python版本)?

Dan*_*haw 5

@keveman的答案告诉我们默认实现,而不是活动实现。

重要的是,PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION环境变量会影响哪个实现处于活动状态,因此

PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=cpp python -c "from google.protobuf.internal import api_implementation; print(api_implementation._default_implementation_type)"
Run Code Online (Sandbox Code Playgroud)

PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python python -c "from google.protobuf.internal import api_implementation; print(api_implementation._default_implementation_type)"
Run Code Online (Sandbox Code Playgroud)

将始终显示相同的结果。

要查看哪个实现处于活动状态,请改用以下方法:

python -c "from google.protobuf.internal import api_implementation; print(api_implementation.Type())"
Run Code Online (Sandbox Code Playgroud)

更改PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION环境变量将导致更改结果的Type()位置_default_implementation_type