簡體   English   中英

如何在 CPU 支持下配置 tensorflow?

[英]How to configure tensorflow with CPU support?

我正在嘗試在 CPU 支持下運行 tensorflow。

張量流:
版本:1.14.0

凱拉斯:
版本:2.3.1

當我嘗試運行以下代碼時:

def run_test_harness(trainX,trainY,testX,testY):
    datagen=ImageDataGenerator(rescale=1.0/255.0)
    train_it = datagen.flow(trainX, trainY, batch_size=1)
    test_it = datagen.flow(testX, testY, batch_size=1)
    model=define_model()

    history = model.fit_generator(train_it, steps_per_epoch=len(train_it),
        validation_data=test_it, validation_steps=len(test_it), epochs=1, verbose=0)

我收到以下錯誤,如圖所示:

圖像顯示錯誤

我試圖為同樣的情況配置 bazel,但它沒有用。 如果有人可以指導我獲取資源或幫助解決問題,那將會很有幫助。 謝謝

編輯:(警告消息)

WARNING:tensorflow:From /home/neha/valiance/kerascpu/lib/python3.6/site-packages/keras/backend/tensorflow_backend.py:4070: The name tf.nn.max_pool is deprecated. Please use tf.nn.max_pool2d instead.

WARNING:tensorflow:From /home/neha/valiance/kerascpu/lib/python3.6/site-packages/tensorflow/python/ops/nn_impl.py:180: add_dispatch_support.<locals>.wrapper (from tensorflow.python.ops.array_ops) is deprecated and will be removed in a future version.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
2020-10-22 12:41:36.023849: 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-10-22 12:41:36.326420: I tensorflow/core/platform/profile_utils/cpu_utils.cc:94] CPU Frequency: 2299965000 Hz
2020-10-22 12:41:36.327496: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x5502350 executing computations on platform Host. Devices:
2020-10-22 12:41:36.327602: I tensorflow/compiler/xla/service/service.cc:175]   StreamExecutor device (0): <undefined>, <undefined>
2020-10-22 12:41:36.679930: 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.
2020-10-22 12:41:36.890241: W tensorflow/core/framework/allocator.cc:107] Allocation of 3406823424 exceeds 10% of system memory.
^Z
[1]+  Stopped                 python3 model.py

您應該嘗試在 google colab 上運行您的代碼。 我認為即使您使用的 batch_size 為 1,您的 PC 上也沒有足夠的資源用於您嘗試運行的任務。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM