我试图在python 3中创建机器连接,但是我试图编译我的代码--在Cuda 10.0/cuDNN 7.5.0中得到了这个错误,有人能帮我吗?
RTX 2080
我上的是: Keras (2.2.4) tf-夜-gpu (1.14.1.dev20190510)
无法创建cudnn句柄: CUDNN_STATUS_INTERNAL_ERROR
代码erorr:tensorflow.python.framework.errors_impl.UnknownError: Failed to get convolution algorithm. This is probably because cuDNN failed to initialize, so try looking to see if a warning log message was printed above.
这是我的代码:
model = Sequential()
model.add(Conv2D(32, (3, 3), activation='relu', input_shape=(50, 50, 1)))
model.add(MaxPooling2D((2, 2)))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D((2, 2)))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(Flatten())
model.add(Dense(1, activation='softmax'))
model.summary()
model.compile(optimizer='adam',
loss='binary_crossentropy',
metrics=['accuracy'])
model.fit(x, y, epochs=1, batch_size=n_batch)OOM分配张量时,使用shape24946,32,48,48,48,类型float /job:localhost/replica:0/task:0/device:GPU:0,通过分配器GPU__bfc
发布于 2019-12-19 19:37:44
使用Tensorflow 2.0、CUDA 10.0和CUDNN 7.5为我工作:
gpus = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(gpus[0], True)还有一些其他的答案(比如venergiac这里的答案)使用过时的Tensorflow 1.x语法。如果您使用的是最新的tensorflow,则需要使用我在这里提供的代码。
如果您得到以下错误:
Physical devices cannot be modified after being initialized然后问题就会解决了,把gpus = tf.config .您导入tensorflow的直接下面的行,即
import tensorflow as tf
gpus = tf.config.experimental.list_physical_devices('GPU')
tf.config.experimental.set_memory_growth(gpus[0], True)发布于 2019-05-10 12:43:48
有两种可能的解决方案。
GPU内存分配问题
添加以下代码
import tensorflow as tf
gpu_options = tf.GPUOptions(per_process_gpu_memory_fraction=0.5)
config = tf.ConfigProto(gpu_options=gpu_options)
config.gpu_options.allow_growth = True
session = tf.Session(config=config)也检查一下这个问题
您的NVIDIA驱动程序有问题
作为张贴的那里,您需要升级您的NVIDIA驱动程序使用ODE驱动程序。
请查看NVIDIA文档的驱动程序版本
发布于 2020-02-19 08:44:59
如果您使用的是Tensorflow 2.0,Roko的答案应该会奏效。
如果您想将确切的内存量设置为限制(例如,1024 to或2GB等),还有另一种方法来限制您的GPU内存的使用。
使用以下代码:
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=1024)])
except RuntimeError as e:
print(e)此代码将限制您的第一个GPU的内存使用最多1024 to。只需根据需要更改gpus和memory_limit的索引即可。
https://stackoverflow.com/questions/56008683
复制相似问题