tensorflow.python.framework.errors_impl.InternalError: Failed to create session. Solution summary
recently wrote a simple tensorflow program to test new computers. Because the new computer is two different Nvidia graphics CARDS, you need to set up which GPU to use each time, or you will always pop up the error of not being able to create a session, and there seem to be several kinds of errors.
solution:
adds the following code to the program:
import os
os.environ["CUDA_VISIBLE_DEVICES"] = '0' #使用编号为0的gpu
config = tf.ConfigProto()
config.gpu_options.per_process_gpu_memory_fraction = 0.5
config.gpu_options.allow_growth = True
this method resolves the error
in the above picture
other solutions that cannot create sessions:
change python test.py
to CUDA_VISIBLE_DEVICES=0 python test.py
when running the program