網頁

2020年4月28日 星期二

Windows jupyter notebook 發生 InternalError: Blas GEMM launch failed

原因:GPU記憶體不足

解決方式:
from sklearn.preprocessing import RobustScaler
from keras.models import Model, load_model, Sequential
from keras.layers import Input
from keras.layers import LSTM, GRU, Bidirectional, BatchNormalization
from keras.layers import Dense, Dropout
from keras.layers import Concatenate
from keras import regularizers

在import Keras module下方再增加一段程式碼

import tensorflow as tf
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID"
os.environ["CUDA_VISIBLE_DEVICES"] = '0' # Set to -1 if CPU should be used CPU = -1 , GPU = 0

gpus = tf.config.experimental.list_physical_devices('GPU')
cpus = tf.config.experimental.list_physical_devices('CPU')

if gpus:
    try:
        # Currently, memory growth needs to be the same across GPUs
        for gpu in gpus:
            tf.config.experimental.set_memory_growth(gpu, True)
        logical_gpus = tf.config.experimental.list_logical_devices('GPU')
        print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")
    except RuntimeError as e:
        # Memory growth must be set before GPUs have been initialized
        print(e)
elif cpus:
    try:
        # Currently, memory growth needs to be the same across GPUs
        logical_cpus= tf.config.experimental.list_logical_devices('CPU')
        print(len(cpus), "Physical CPU,", len(logical_cpus), "Logical CPU")
    except RuntimeError as e:
        # Memory growth must be set before GPUs have been initialized
        print(e)











https://github.com/tensorflow/tensorflow/issues/11812

沒有留言:

張貼留言