Skip to content

Segmentation fault (core dumped) on tf.Session() #19347

Closed

Description

@BenisonSam

I just installed TensorFlow and to test the installation, I tried the following code and as soon as I initiate the TF Session, I am getting the Segmentation fault (core dumped) error.

bafhf@remote-server:~$ python
Python 3.6.5 |Anaconda, Inc.| (default, Apr 29 2018, 16:14:56) 
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
/home/bafhf/anaconda3/envs/ismll/lib/python3.6/site-packages/h5py/__init__.py:36: FutureWarning: Conversion of the second argument of issubdtype from `float` to `np.floating` is deprecated. In future, it will be treated as `np.float64 == np.dtype(float).type`.
  from ._conv import register_converters as _register_converters
>>> tf.Session()
2018-05-15 12:04:15.461361: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1349] Found device 0 with properties: 
name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235
pciBusID: 0000:04:00.0
totalMemory: 11.17GiB freeMemory: 11.10GiB
Segmentation fault (core dumped)

My nvidia-smi is:

Tue May 15 12:12:26 2018       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 390.30                 Driver Version: 390.30                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla K80           On   | 00000000:04:00.0 Off |                    0 |
| N/A   38C    P8    26W / 149W |      0MiB / 11441MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  Tesla K80           On   | 00000000:05:00.0 Off |                    2 |
| N/A   31C    P8    29W / 149W |      0MiB / 11441MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
                                                                           
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

And nvcc --version is:

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

Also gcc --version is:

gcc (Ubuntu 5.4.0-6ubuntu1~16.04.9) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Following is my PATH:

/home/bafhf/bin:/home/bafhf/.local/bin:/usr/local/cuda/bin:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib:/home/bafhf/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

and the LD_LIBRARY_PATH:

/usr/local/cuda/bin:/usr/local/cuda/lib:/usr/local/cuda/extras/CUPTI/lib


I am running this on a server and I don't have root privileges. Still I managed to install everything as per the instructions on the official website.

Seems like the GPU is allocating memory for the process for a second and then the core segmentation dumped error is thrown.

terminal output

I downgraded my tensorflow version from v1.8 to v1.5. The issue still remains.


Is there any way address or debug this issue?

Activity

  1. achalshah20 commented on May 17, 2018

    @achalshah20
    Contributor

    How did you install tensorflow? From sources, using bazel/cmake?

  2. added
    stat:awaiting response
    on May 17, 2018
  3. tensorflowbutler commented on May 17, 2018

    @tensorflowbutler
    Member

    Thank you for your post. We noticed you have not filled out the following field in the issue template. Could you update them if they are relevant in your case, or leave them as N/A? Thanks.
    Have I written custom code
    OS Platform and Distribution
    TensorFlow installed from
    Bazel version
    CUDA/cuDNN version
    GPU model and memory
    Exact command to reproduce

  4. BenisonSam commented on May 17, 2018

    @BenisonSam
    Author

    I first installed tensorflow in an anaconda env using conda. It gave me the Segmentation fault error. So dumped that conda env, created a new conda env and then used bazel to build and generate the the whl package to install it. It still gives me the same error. I followed the same process for version r1.5. Each time I tried something new, I removed the old conda env just to make sure I don't pick up anything residual from earlier process. And every time I am getting the same error.

  5. BenisonSam commented on May 17, 2018

    @BenisonSam
    Author

    Have I written custom code: N/A
    OS Platform and Distribution: Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-116-generic x86_64)
    TensorFlow installed from: Both using conda as well as bazel build whl package inside conda env
    Bazel version: 0.12 and 0.11 in individual tries
    CUDA/cuDNN version: CUDA 9.0 cuDNN 1.7
    GPU model and memory: 2 Tesla K80's (see the nvidia-smi output shown in the question)
    Exact command to reproduce:

    import tensorflow as tf
    tf.Session()
    

    tf.Session() causes the error

    Hope this information is adequate.

  6. achalshah20 commented on May 17, 2018

    @achalshah20
    Contributor

    I am confused. Are you using cuda 9 or 9.1? In the original post you posted LD_LIBRARY_PATH as

    
    > and the LD_LIBRARY_PATH:
    > 
    > /home/bafhf/cuda-9.1/lib64:/home/bafhf/cuda-9.1/extras/CUPTI/lib64:
    
    

    You can get a stacktrace by running your python file using gdb.

    1. gdb python
    2. run file.py
    3. bt
  7. BenisonSam commented on May 17, 2018

    @BenisonSam
    Author

    I am sorry for the mixup, I should have corrected that.

    I tried first with CUDA 9.1, got the error. So switched to CUDA 9.0 to check whether that's the issue. But seems like error is still there with CUDA 9.0 also. So its at least not a CUDA problem. Right now I am sticking with CUDA 9.0.

    I have corrected the original post now.

  8. BenisonSam commented on May 17, 2018

    @BenisonSam
    Author

    I have got the stacktrace.

    >>> tf.Session()
    [New Thread 0x7fff95a22700 (LWP 6916)]
    [New Thread 0x7fff98223700 (LWP 6917)]
    [New Thread 0x7fff9aa24700 (LWP 6918)]
    [New Thread 0x7fff9d225700 (LWP 6919)]
    [New Thread 0x7fffe3a42700 (LWP 6920)]
    [New Thread 0x7fffe1241700 (LWP 6921)]
    [New Thread 0x7fffdea40700 (LWP 6922)]
    [New Thread 0x7fffde23f700 (LWP 6923)]
    [New Thread 0x7fffd9a3e700 (LWP 6924)]
    [New Thread 0x7fffd723d700 (LWP 6925)]
    [New Thread 0x7fffd4a3c700 (LWP 6926)]
    [New Thread 0x7fffd423b700 (LWP 6927)]
    [New Thread 0x7fffd3a3a700 (LWP 6928)]
    [New Thread 0x7fffd3239700 (LWP 6929)]
    [New Thread 0x7fffcca38700 (LWP 6930)]
    [New Thread 0x7fffca237700 (LWP 6931)]
    [New Thread 0x7fffc7a36700 (LWP 6932)]
    [New Thread 0x7fffc5235700 (LWP 6933)]
    [New Thread 0x7fffc2a34700 (LWP 6934)]
    [New Thread 0x7fffc0233700 (LWP 6935)]
    [New Thread 0x7fffbda32700 (LWP 6936)]
    [New Thread 0x7fffbb231700 (LWP 6937)]
    [New Thread 0x7fffb8a30700 (LWP 6938)]
    [New Thread 0x7fffb622f700 (LWP 6939)]
    [New Thread 0x7fffb3a2e700 (LWP 6940)]
    [New Thread 0x7fffb122d700 (LWP 6941)]
    [New Thread 0x7fffaea2c700 (LWP 6942)]
    [New Thread 0x7fffac22b700 (LWP 6943)]
    [New Thread 0x7fffa9a2a700 (LWP 6944)]
    [New Thread 0x7fffa7229700 (LWP 6945)]
    [New Thread 0x7fffa4a28700 (LWP 6946)]
    [New Thread 0x7fffa0227700 (LWP 6947)]
    [New Thread 0x7fff9fa26700 (LWP 6948)]
    [New Thread 0x7fff59e9d700 (LWP 6949)]
    [New Thread 0x7fff5969c700 (LWP 6950)]
    [New Thread 0x7fff58e9b700 (LWP 6951)]
    [New Thread 0x7ffecbfff700 (LWP 6952)]
    [New Thread 0x7ffecb7fe700 (LWP 6953)]
    [New Thread 0x7ffecaffd700 (LWP 6954)]
    [New Thread 0x7ffeca7fc700 (LWP 6955)]
    [New Thread 0x7ffec9ffb700 (LWP 6956)]
    [New Thread 0x7ffec97fa700 (LWP 6957)]
    [New Thread 0x7ffec8ff9700 (LWP 6958)]
    [New Thread 0x7ffeaffff700 (LWP 6959)]
    2018-05-17 23:27:46.350913: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1349] Found device 0 with properties: 
    name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235
    pciBusID: 0000:04:00.0
    totalMemory: 11.17GiB freeMemory: 11.10GiB
    [New Thread 0x7ffeaf7fe700 (LWP 6960)]
    [New Thread 0x7ffeaeffd700 (LWP 6961)]
    
    Thread 86 "python" received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0x7ffeaeffd700 (LWP 6961)]
    0x00007fff67a448d5 in ?? () from /usr/lib/x86_64-linux-gnu/libcuda.so.1
    (gdb) bt
    #0  0x00007fff67a448d5 in ?? () from /usr/lib/x86_64-linux-gnu/libcuda.so.1
    #1  0x00007fff67b94914 in ?? () from /usr/lib/x86_64-linux-gnu/libcuda.so.1
    #2  0x00007fff67b30e80 in ?? () from /usr/lib/x86_64-linux-gnu/libcuda.so.1
    #3  0x00007ffff7bc16ba in start_thread () from /lib/x86_64-linux-gnu/libpthread.so.0
    #4  0x00007ffff78f741d in clone () from /lib/x86_64-linux-gnu/libc.so.6
    
  9. achalshah20 commented on May 17, 2018

    @achalshah20
    Contributor

    Does it work outside conda enviornment?

    1. sudo pip install tensorflow-gpu

    python
    import tensorflow as tf
    tf.Session()

  10. BenisonSam commented on May 17, 2018

    @BenisonSam
    Author

    @achalshah20 No it doesn't work outside conda as well

  11. viksit commented on May 18, 2018

    @viksit

    @BenisonSam

    Look at your nvidia-smi output - the second GPU has an ECC code of 2. This error manifests itself irrespective of a CUDA version of TF version error, and usually as a segfault, and sometimes, with the CUDA_ERROR_ECC_UNCORRECTABLE flag in the stack trace.

    "Uncorrectable ECC error" usually refers to a hardware failure. ECC is Error Correcting Code, a means to detect and correct errors in bits stored in RAM. A stray cosmic ray can disrupt one bit stored in RAM every once in a great while, but "uncorrectable ECC error" indicates that several bits are coming out of RAM storage "wrong" - too many for the ECC to recover the original bit values.

    This could mean that you have a bad or marginal RAM cell in your GPU device memory.

    Marginal circuits of any kind may not fail 100%, but are more likely to fail under the stress of heavy use - and associated rise in temperature.

    Your best option is to change your GPU machine -- this points to a hardware level failure.

    See https://stackoverflow.com/questions/11839555/cuda-uncorrectable-ecc-error-encountered

  12. achalshah20 commented on May 18, 2018

    @achalshah20
    Contributor

    @BenisonSam Sometimes reboot just take away "Uncorrectable ECC error". If it doesn't go then it may be a hardware failure as @viksit suggested.

  13. BenisonSam commented on May 18, 2018

    @BenisonSam
    Author

    I agree with @achalshah20 because these GPUs are shared GPUs. I am student and this is a shared machine in our university. Other students whose accounts were created and configured by our former admin is up and working and they are still able to use the GPU.

    I am configuring this new account of mine for a project and am facing this issue. My over all setup is same as theirs, but I don't know what I am doing differently which makes it not work for me.

    Also since there are multiple K80 nodes, is there a need for OpenMPI/NCCL setup of any kind?

  14. removed
    stat:awaiting response
    on May 26, 2018
  15. tensorflowbutler commented on Jun 10, 2018

    @tensorflowbutler
    Member

    Nagging Assignee @poxvoculi: It has been 23 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

  16. sanfern commented on Jun 16, 2018

    @sanfern

    I am also see similar issue on Tensorflow 1.8.0-gpu, any resolution for this issue.

  17. BenisonSam commented on Jun 22, 2018

    @BenisonSam
    Author

    After restarting the server as @achalshah20 mentioned, the ECC error was gone which @viksit pointed out. Then I was able to use both my K80 cards for my tensorflow implementations. Thanks for all your help!

  18. bulutmf commented on Oct 11, 2018

    @bulutmf

    In case anyone still interested in, I happened to had the same issue, with "Volatile Uncorr. ECC" output. My problem was incompatible versions as shown below:

    Loaded runtime CuDNN library: 7.1.1 but source was compiled with: 7.2.1.  CuDNN library major and minor version needs to match or have higher minor version in case of CuDNN 7.0 or later version. If using a binary install, upgrade your CuDNN library.  If building from sources, make sure the library loaded at runtime is compatible with the version specified during compile configuration.
    Segmentation fault
    

    After I upgrade CuDNN library to 7.3.1 (which is greater than 7.2.1), segmentation fault error disappeared. To upgrade I did the following (as also documented in here).

    1. Download CuDNN library from NVIDIA website
    2. sudo tar -xzvf [TAR_FILE]
    3. sudo cp cuda/include/cudnn.h /usr/local/cuda/include
    4. sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
    5. sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions