我的电脑只有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笔记本,现在运行了两个内核。(TensorFlow 2.6.0并安装了CUDA和cuDNN,按照TensorFlow指南)
第一个内核可以运行我的Keras Sequential模型没有问题。
但是当我在第二个内核中学习相同的代码时,出现以下错误。
Attempting to perform BLAS operation using StreamExecutor without BLAS support [[node sequential_3/dense_21/MatMul (defined at \AppData\Local\Temp/ipykernel_14764/3692363323.py:1) ]] [Op:__inference_train_function_7682]
Function call stack: train_function
如何才能学习多个内核而没有任何问题,并共享它们与仅有的1个GPU?
虽然我不熟悉TensorFlow 1.x.x版本。
我刚刚通过以下方式解决了这个问题。这个问题是因为当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)