在本地机器上加载张量流模型
loading tensorflow model on local machine
我在 google colab 中训练了我的 TensorFlow 模型并以 .h5 格式导出。在 google colab 中,我可以毫无问题地加载模型,但在我的本地机器上,它会抛出错误和警告。
正在加载模型
import tensorflow as tf
rnn = tf.keras.models.load_model('my_model.h5')
错误
2020-05-16 20:17:10.802390: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU
supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-05-16 20:17:10.835907: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU
Frequency: 2400000000 Hz
2020-05-16 20:17:10.836269: I tensorflow/compiler/xla/service/service.cc:168] XLA service
0x4443f90 executing computations on platform Host. Devices:
2020-05-16 20:17:10.836308: I tensorflow/compiler/xla/service/service.cc:175]
StreamExecutor device (0): <undefined>, <undefined>
2020-05-16 20:17:10.862236: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412]
(One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--
tf_xla_cpu_global_jit was not set. If you want XLA:CPU, either set that envvar, or use
experimental_jit_scope to enable XLA:CPU. To confirm that XLA is active, pass
--vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or
set the envvar XLA_FLAGS=--xla_hlo_profile.
我在 google 与 GPU 协作中训练了模型。
它们只是信息和警告消息,因为它们的前缀是 I
表示信息,W
表示警告,否则如果是错误消息,它们将带有前缀 E
.
例如 - 在下面的错误跟踪中,有一些以 I
为前缀的信息消息和以 E
.
为前缀的错误消息
2020-01-14 21:30:27.591905: I tensorflow/core/profiler/lib/profiler_session.cc:225] Profiler session started.
2020-01-14 21:30:27.594743: I tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1259] Profiler found 1 GPUs
2020-01-14 21:30:27.599172: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cupti64_101.dll
2020-01-14 21:30:27.704083: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1307] function cupti_interface_->Subscribe( &subscriber_, (CUpti_CallbackFunc)ApiCallback, this)failed with error CUPTI_ERROR_INSUFFICIENT_PRIVILEGES
2020-01-14 21:30:27.716790: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1346] function cupti_interface_->ActivityRegisterCallbacks( AllocCuptiActivityBuffer, FreeCuptiActivityBuffer)failed with error CUPTI_ERROR_INSUFFICIENT_PRIVILEGES
Epoch 1/5
2020-01-14 21:30:28.370429: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-01-14 21:30:28.651767: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-01-14 21:30:29.662864: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1329] function cupti_interface_->EnableCallback( 0 , subscriber_, CUPTI_CB_DOMAIN_DRIVER_API, cbid)failed with error CUPTI_ERROR_INVALID_PARAMETER
2020-01-14 21:30:29.670282: I tensorflow/core/profiler/internal/gpu/device_tracer.cc:88] GpuTracer has collected 0 callback api events and 0 activity events.
如果您无法使用加载的模型并遇到其他错误,请告诉我们。希望这能回答您的问题。
我在 google colab 中训练了我的 TensorFlow 模型并以 .h5 格式导出。在 google colab 中,我可以毫无问题地加载模型,但在我的本地机器上,它会抛出错误和警告。
正在加载模型
import tensorflow as tf
rnn = tf.keras.models.load_model('my_model.h5')
错误
2020-05-16 20:17:10.802390: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU
supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
2020-05-16 20:17:10.835907: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU
Frequency: 2400000000 Hz
2020-05-16 20:17:10.836269: I tensorflow/compiler/xla/service/service.cc:168] XLA service
0x4443f90 executing computations on platform Host. Devices:
2020-05-16 20:17:10.836308: I tensorflow/compiler/xla/service/service.cc:175]
StreamExecutor device (0): <undefined>, <undefined>
2020-05-16 20:17:10.862236: W tensorflow/compiler/jit/mark_for_compilation_pass.cc:1412]
(One-time warning): Not using XLA:CPU for cluster because envvar TF_XLA_FLAGS=--
tf_xla_cpu_global_jit was not set. If you want XLA:CPU, either set that envvar, or use
experimental_jit_scope to enable XLA:CPU. To confirm that XLA is active, pass
--vmodule=xla_compilation_cache=1 (as a proper command-line flag, not via TF_XLA_FLAGS) or
set the envvar XLA_FLAGS=--xla_hlo_profile.
我在 google 与 GPU 协作中训练了模型。
它们只是信息和警告消息,因为它们的前缀是 I
表示信息,W
表示警告,否则如果是错误消息,它们将带有前缀 E
.
例如 - 在下面的错误跟踪中,有一些以 I
为前缀的信息消息和以 E
.
2020-01-14 21:30:27.591905: I tensorflow/core/profiler/lib/profiler_session.cc:225] Profiler session started.
2020-01-14 21:30:27.594743: I tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1259] Profiler found 1 GPUs
2020-01-14 21:30:27.599172: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cupti64_101.dll
2020-01-14 21:30:27.704083: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1307] function cupti_interface_->Subscribe( &subscriber_, (CUpti_CallbackFunc)ApiCallback, this)failed with error CUPTI_ERROR_INSUFFICIENT_PRIVILEGES
2020-01-14 21:30:27.716790: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1346] function cupti_interface_->ActivityRegisterCallbacks( AllocCuptiActivityBuffer, FreeCuptiActivityBuffer)failed with error CUPTI_ERROR_INSUFFICIENT_PRIVILEGES
Epoch 1/5
2020-01-14 21:30:28.370429: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-01-14 21:30:28.651767: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-01-14 21:30:29.662864: E tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1329] function cupti_interface_->EnableCallback( 0 , subscriber_, CUPTI_CB_DOMAIN_DRIVER_API, cbid)failed with error CUPTI_ERROR_INVALID_PARAMETER
2020-01-14 21:30:29.670282: I tensorflow/core/profiler/internal/gpu/device_tracer.cc:88] GpuTracer has collected 0 callback api events and 0 activity events.
如果您无法使用加载的模型并遇到其他错误,请告诉我们。希望这能回答您的问题。