tensorflow - “尝试使用没有 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)
解决方案
为了社区的利益,在这里提供解决方案
这个问题是因为当 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)
推荐阅读
- python-3.x - 如何通过ip地址请求https?
- arrays - 需要帮助使用类显示随机数生成器选择并输出到文件
- swift - 当我在另一个类中声明一个类时有什么问题吗?
- python - 为什么我的 Python POST 请求会引导我进入初始网页?
- python - PyCharm-Project 可执行文件
- reactjs - 嵌套形式的反应和派生状态
- swift - 2 .onReceive() 功能与定时器不工作
- python - 基于模糊匹配查找和替换列表中的值
- python - 分类变量处理期间的数据泄漏?
- javascript - 由于某些奇怪的原因,Js 在控制台中输出错误的日期