我试图训练一个Resnet50,但无论我做什么都失败了,因为Jupyter笔记本的内核正在死亡(The kernel appears to have died. It will restart automatically
),它开始训练的那一刻我有GeForce® GTX 1060 Ti,当我在训练中做nvidia-smi
时,(虽然持续了1秒钟)与过去相比,我只看到80 MB的内存被分配,然后内核就死了,好像它尝试了但失败了。
要求如下:
pandas==0.25.1
numpy==1.17.2
opencv-python==4.1.1.26
scikit-image==0.15.0
scikit-learn==0.21.3
tensorflow-gpu==1.14.0
Keras==2.2.5
matplotlib==3.1.1
Pillow==6.1.0
albumentations==0.3.2
tqdm==4.35.0
jupyter
我很满意。下面是我如何设置培训课程的:
config = tf.ConfigProto()
config.gpu_options.allow_growth = False
config.gpu_options.per_process_gpu_memory_fraction = 0.9
sess = tf.Session(config=config)
keras.backend.set_session(sess)
keras.__version__
os.environ["CUDA_VISIBLE_DEVICES"] = '0' #yes, this is the ID of my GPU.
# create the FCN model
model_mobilenet = ResNet50(input_shape=(1024, 1024, 3), include_top=False) # use the Resnet
model_x8_output = Conv2D(128, (1, 1), activation='relu')(model_mobilenet.layers[-95].output)
model_x8_output = UpSampling2D(size=(8, 8))(model_x8_output)
model_x8_output = Conv2D(3, (3, 3), padding='same', activation='sigmoid')(model_x8_output)
MODEL_x8 = Model(inputs=model_mobilenet.input, outputs=model_x8_output)
MODEL_x8.compile(loss='binary_crossentropy', optimizer=Adam(lr=1e-3), metrics=[jaccard_distance])
MODEL_x8.fit_generator(train_generator, steps_per_epoch=300, epochs=100, verbose=1, validation_data=val_generator, validation_steps=10)
Epoch 1/100
1/300 [..............................] - ETA: 1:01:59 - loss: 0.7193 - jaccard_distance: 0.1125
我已尝试设置:
config.gpu_options.allow_growth
到True
。config.gpu_options.per_process_gpu_memory_fraction
转换为任何其他任意值,例如0.1
- 注解:
#os.environ["CUDA_VISIBLE_DEVICES"] = 0
都没用我很欣赏建设性的回答。
先谢了。
- EDIT:* 我现在尝试将其作为脚本(而不是笔记本)运行,当Tensorflow会话行出现时,终端抛出以下内容:
2020-01-28 13:44:55.756819: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcudart.so.10.0'; dlerror: libcudart.so.10.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/username/ros_ws/devel/lib:/opt/ros/melodic/lib
2020-01-28 13:44:55.757047: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcublas.so.10.0'; dlerror: libcublas.so.10.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/username/ros_ws/devel/lib:/opt/ros/melodic/lib
2020-01-28 13:44:55.757313: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcufft.so.10.0'; dlerror: libcufft.so.10.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/username/ros_ws/devel/lib:/opt/ros/melodic/lib
2020-01-28 13:44:55.757526: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcurand.so.10.0'; dlerror: libcurand.so.10.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/username/ros_ws/devel/lib:/opt/ros/melodic/lib
2020-01-28 13:44:55.757736: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcusolver.so.10.0'; dlerror: libcusolver.so.10.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/username/ros_ws/devel/lib:/opt/ros/melodic/lib
2020-01-28 13:44:55.757940: I tensorflow/stream_executor/platform/default/dso_loader.cc:53] Could not dlopen library 'libcusparse.so.10.0'; dlerror: libcusparse.so.10.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/username/ros_ws/devel/lib:/opt/ros/melodic/lib
2020-01-28 13:44:55.808416: I tensorflow/stream_executor/platform/default/dso_loader.cc:42] Successfully opened dynamic library libcudnn.so.7
2020-01-28 13:44:55.808444: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1663] Cannot dlopen some GPU libraries. Skipping registering GPU devices...
这很奇怪,因为我没有CUDA 10,而是9.0,所以这个问题根本不应该被问到。我的Tensorflow版本出错了吗?
3条答案
按热度按时间t30tvxxf1#
最有可能的原因是没有足够的内存来存储数据/模型。您的输入图像大小也是1024 X1024。我想让您尝试使用像256甚至128这样的小图像大小进行训练,只是看看它是否至少工作。
另外,你的GPU是否被TF检测到?
polkgigr2#
好的,知道了。
问题是我的tensorflow=gpu版本(1.14)与CUDA版本(9.0)不兼容。我不得不安装低于1.13的版本。但这不是唯一的问题。我的CuDNN版本(705)也有问题,我不得不将我的Tensorflow-gpu一直降低到1.9.0。
现在一切正常了。
uqdfh47h3#
就我而言(windows 10,rtx 3050 ti图形处理器与vram的4 GB),通过卸载CUDA 11解决了"内核似乎已死亡"错误(及其相关的cuDNN)和安装CUDA 10.1(和cuDNN 2.2.0)以及卸载tensorflow 图形处理器2.3.0和安装tensorflow 图形处理器2.2.0(python 3.8为我工作,而tensorflow网站已经测试python 3.5,所以我没有降级python).然而,我不满意的结果,因为我的GPU需要太长的时间来制作模型相比,我的核心i7英特尔CPU.
总之,这个错误似乎与GPU和CUDA版本不兼容有关,可以通过降低CUDA的级别并根据新的CUDA安装相应的版本来修复。