段错误 核心已转储尝试解决

Posted bluebluesea

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了段错误 核心已转储尝试解决相关的知识,希望对你有一定的参考价值。

1.在进行

gdb python
r XX.py
where

调试时,报出以下错误:

1)每次运行都开38个线程,是否是线程超载[New Thread 0x7ffff2fd2700 (LWP 7415)]

[New Thread 0x7ffff27d1700 (LWP 7416)]
[New Thread 0x7fffeffd0700 (LWP 7417)]
[New Thread 0x7fffeb7cf700 (LWP 7418)]
[New Thread 0x7fffe8fce700 (LWP 7419)]
[New Thread 0x7fffe67cd700 (LWP 7420)]
[New Thread 0x7fffe3fcc700 (LWP 7421)]
[New Thread 0x7fffe17cb700 (LWP 7422)]
[New Thread 0x7fffdefca700 (LWP 7423)]
[New Thread 0x7fffdc7c9700 (LWP 7424)]
[New Thread 0x7fffd9fc8700 (LWP 7425)]
[New Thread 0x7fffd77c7700 (LWP 7426)]
[New Thread 0x7fffd4fc6700 (LWP 7427)]
[New Thread 0x7fffd27c5700 (LWP 7428)]
[New Thread 0x7fffcffc4700 (LWP 7429)]
[New Thread 0x7fffcd7c3700 (LWP 7430)]
[New Thread 0x7fffcafc2700 (LWP 7431)]
[New Thread 0x7fffc87c1700 (LWP 7432)]
[New Thread 0x7fffc5fc0700 (LWP 7433)]
[New Thread 0x7fffc37bf700 (LWP 7434)]
[New Thread 0x7fffc0fbe700 (LWP 7435)]
[New Thread 0x7fffbe7bd700 (LWP 7436)]
[New Thread 0x7fffbbfbc700 (LWP 7437)]
[New Thread 0x7fffb97bb700 (LWP 7438)]
[New Thread 0x7fffb6fba700 (LWP 7439)]
[New Thread 0x7fffb47b9700 (LWP 7440)]
[New Thread 0x7fffb1fb8700 (LWP 7441)]
[New Thread 0x7fffaf7b7700 (LWP 7442)]
[New Thread 0x7fffacfb6700 (LWP 7443)]
[New Thread 0x7fffaa7b5700 (LWP 7444)]
[New Thread 0x7fffa7fb4700 (LWP 7445)]
[New Thread 0x7fffa57b3700 (LWP 7446)]
[New Thread 0x7fffa2fb2700 (LWP 7447)]
[New Thread 0x7fffa07b1700 (LWP 7448)]
[New Thread 0x7fff9dfb0700 (LWP 7449)]
[New Thread
0x7fff9b7af700 (LWP 7450)] [New Thread 0x7fff98fae700 (LWP 7451)] [New Thread 0x7fff967ad700 (LWP 7452)] [New Thread 0x7fff93fac700 (LWP 7453)]

 

2)现在报出:

ERROR (theano.gpuarray): Could not initialize pygpu, support disabled
。。。
  File "pygpu/gpuarray.pyx", line 658, in pygpu.gpuarray.init
  File "pygpu/gpuarray.pyx", line 587, in pygpu.gpuarray.pygpu_init
GpuArrayException: cuDeviceGet: CUDA_ERROR_INVALID_DEVICE: invalid device ordinal

先不解决这个,先尝试测试一下:

发现,在import keras,也会报上述同样的错误!

 conda install mkl
conda install mkl-service
#使用以上两句均显示:
# All requested packages already installed.

conda install blas

 依旧不可以导入keras包。

 3)将原有的conda环境删除,又新创建了环境,用conda安装了mkl之后,尝试import keras之后,仍然报错:

Using Theano backend.
~/lib/python2.7/site-packages/theano/gpuarray/dnn.py:184: UserWarning: Your cuDNN version is more recent than Theano. 
If you encounter problems, try updating Theano or downgrading cuDNN to a version >= v5 and <= v7. warnings.warn("Your cuDNN version is more recent than " ERROR (theano.gpuarray): Could not initialize pygpu, support disabled Traceback (most recent call last): File "~/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 227, in <module> use(config.device) File "~/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 214, in use init_dev(device, preallocate=preallocate) File "~/lib/python2.7/site-packages/theano/gpuarray/__init__.py", line 99, in init_dev **args) File "pygpu/gpuarray.pyx", line 658, in pygpu.gpuarray.init File "pygpu/gpuarray.pyx", line 587, in pygpu.gpuarray.pygpu_init GpuArrayException: cuDeviceGet: CUDA_ERROR_INVALID_DEVICE: invalid device ordinal

在我的.theanorc配置文件中,是这么写的:

[global]
floatX = float32
device =cuda1

 

尝试去掉cuda编号?居然成功了!

Using Theano backend.
~/.conda/envs/xhs/lib/python2.7/site-packages/theano/gpuarray/dnn.py:184: UserWarning: Your cuDNN version is more recent than Theano.
If you encounter problems, try updating Theano or downgrading cuDNN to a version >= v5 and <= v7. warnings.warn("Your cuDNN version is more recent than " Using cuDNN version 7201 on context None Mapped name None to device cuda: GeForce GTX 1080 Ti (0000:03:00.0)

 

接下来尝试解决 上述的用户警告。

由于theano已经是1.0.4最新版本,无法再进行更新,只能尝试将cuDNN版本降级。

但是使用conda list查看所有安装的包:

cudnn                     6.0.21                cuda8.0_0    https://mirrors.tuna.tsinghua.edu.cn/a
#尝试此命令查看pygpu是否可用
DEVICE="cuda" python -c "import pygpu; pygpu.test()"

 

出现以下问题:https://github.com/Theano/Theano/issues/6420

此帮助里说,如果不是使用多个GPU可以忽略test_collectives error。

#尝试以下,
python test_gpu.py
~/.conda/envs/xhs/lib/python2.7/site-packages/theano/gpuarray/dnn.py:184: UserWarning: Your cuDNN version is more recent than Theano. If you encounter problems, try updating Theano or downgrading cuDNN to a version >= v5 and <= v7.
  warnings.warn("Your cuDNN version is more recent than "
Using cuDNN version 7201 on context None
Mapped name None to device cuda: GeForce GTX 1080 Ti (0000:03:00.0)
[GpuElemwise{exp,no_inplace}(<GpuArrayType<None>(float32, vector)>), HostFromGpu(gpuarray)(GpuElemwise{exp,no_inplace}.0)]
Looping 1000 times took 0.192847 seconds
Result is [1.2317803 1.6187935 1.5227807 ... 2.2077181 2.2996776 1.623233 ]
Used the gpu

 

发现其使用的cudnn版本是7.2,明明是6.0但是却调用了7.2?

查看cuda的版本信息发现:

nvcc -V

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2017 NVIDIA Corporation
Built on Fri_Sep__1_21:08:03_CDT_2017
Cuda compilation tools, release 9.0, V9.0.176

 

test_collectives error

以上是关于段错误 核心已转储尝试解决的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu20.04出现段错误核心已转储问题解决方案

C语言 文件方面 段错误 核心已转储 以及字符串查找删除的问题

linux 段错误

Linux:段错误(核心已转储) Segmentation fault (core dumped)(在Linux上如何得到一个段错误的核心转储)(笔记)(未完成,暂停)

段错误(核心已转储)的原因

运行我的代码时出现分段错误(核心转储)问题