[Solved] Tensorflow2.0 Error: Function call stack:distributed_function

It can be clearly said that GPU resources are insufficient. What’s more, when using jupyters provided by various platforms to use GPU, when opening multiple tap pages, because tensorflow takes up all the resources as much as possible, only the first one will start successfully without setting the resource usage in advance, and the rest will cause the above error

You can close all pages first, then restart, and configure as follows

# import tensorflow as tf 
import os

os.environ['CUDA_VISIBLE_DEVICES']="0" # Specify which GPU to train
config=tf.compat.v1.ConfigProto() 
# Set the maximum occupied GPU to no more than 80% of the video memory (optional)
config.gpu_options.per_process_gpu_memory_fraction=0.5
config.gpu_options.allow_growth = True # Set dynamic GPU memory allocation
sess=tf.compat.v1.Session(config=config)

Read More: