首页 > 解决方案 > “尝试使用没有 BLAS 支持的 StreamExecutor 执行 BLAS 操作”错误发生

问题描述

我的电脑只有 1 个 GPU。

以下是我通过输入某人的代码得到的结果

[name: "/device:CPU:0" device_type: "CPU" memory_limit: 268435456
locality {} incarnation: 16894043898758027805, name: "/device:GPU:0"
device_type: "GPU" memory_limit: 10088284160
locality {bus_id: 1 links {}}
incarnation: 17925533084010082620
physical_device_desc: "device: 0, name: GeForce RTX 3060, pci bus id: 0000:17:00.0, compute 
capability: 8.6"]

我使用 jupyter notebook,现在运行 2 个内核。(TensorFlow 2.6.0 还安装了 CUDA 和 cuDNN 作为 TensorFlow 指南)

第一个内核可以从 Keras 运行我的 Sequential 模型。

但是当我在第二个内核中学习相同的代码时,我得到了如下错误。

尝试在不支持 BLAS 的情况下使用 StreamExecutor 执行 BLAS 操作 [[nodesequential_3/dense_21/MatMul(定义在 \AppData\Local\Temp/ipykernel_14764/3692363323.py:1)]] [Op:__inference_train_function_7682]

函数调用栈:train_function

我如何才能毫无问题地学习多个内核并仅使用 1 个 GPU 共享它们?

不过,我不熟悉 TensorFlow 1.xx 版本。


我刚刚解决了这个问题,如下所示。这个问题是因为当 keras 使用 gpu 运行时。它使用几乎所有的 vram。所以我需要为每个笔记本提供 memory_limit。这是我的代码如何解决它。您可以更改 memory_limit 值。

gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
  try:
    tf.config.experimental.set_virtual_device_configuration(
        gpus[0],[tf.config.experimental.VirtualDeviceConfiguration(memory_limit=5120)])
  except RuntimeError as e:
    print(e)

标签: tensorflowjupyter-notebookgputensorflow2.0blas

解决方案


为了社区的利益,在这里提供解决方案

这个问题是因为当 keras 使用 gpu 运行时,它几乎使用了所有vram. 所以我们需要给 memory_limit每个笔记本,如下所示

gpus = tf.config.experimental.list_physical_devices('GPU')
if gpus:
  try:
    tf.config.experimental.set_virtual_device_configuration(
        gpus[0],[tf.config.experimental.VirtualDeviceConfiguration(memory_limit=5120)])
  except RuntimeError as e:
    print(e)

(转述自 MCPMH)


推荐阅读