tensorflow: Segmentation fault, import tensorflow, tensorflow 0.9, mac osx

I have followed the installation steps for GPU enabled tensorflow 0.9 on OSX, (https://www.tensorflow.org/versions/r0.9/get_started/os_setup.html#installation-for-mac-os-x), within a conda environment. The installation seems to go smoothly, but I get a seg fault error when importing tensorflow. I have tried the fixes from related threads without success.

See below for the segmentation fault error.

Environment info

Operating System: Mac OSX 10.10.5

Installed version of CUDA and cuDNN: CUDA 7.5 and cuDNN 5.1 (please attach the output of ls -l /path/to/cuda/lib/libcud*): $ ls -l /usr/local/cuda/lib/libcud* -rwxr-xr-x 1 root wheel 8280 Apr 13 02:02 /usr/local/cuda/lib/libcuda.dylib lrwxr-xr-x 1 root wheel 45 Apr 13 02:03 /usr/local/cuda/lib/libcudadevrt.a -> /Developer/NVIDIA/CUDA-7.5/lib/libcudadevrt.a lrwxr-xr-x 1 root wheel 50 Apr 13 02:03 /usr/local/cuda/lib/libcudart.7.5.dylib -> /Developer/NVIDIA/CUDA-7.5/lib/libcudart.7.5.dylib lrwxr-xr-x 1 root wheel 46 Apr 13 02:03 /usr/local/cuda/lib/libcudart.dylib -> /Developer/NVIDIA/CUDA-7.5/lib/libcudart.dylib lrwxr-xr-x 1 root wheel 49 Apr 13 02:03 /usr/local/cuda/lib/libcudart_static.a -> /Developer/NVIDIA/CUDA-7.5/lib/libcudart_static.a -rwxr-xr-x@ 1 lw17567 staff 58975112 Jun 10 04:30 /usr/local/cuda/lib/libcudnn.5.dylib lrwxr-xr-x@ 1 lw17567 staff 16 Jun 10 04:31 /usr/local/cuda/lib/libcudnn.dylib -> libcudnn.5.dylib -rw-r–r–@ 1 lw17567 staff 56392320 Jun 10 04:30 /usr/local/cuda/lib/libcudnn_static.a

Installed tensorflow 0.9 within anaconda 2 env,

pip version: pip 8.1.2 Python 2.7.12

The output from python -c "import tensorflow; print(tensorflow.__version__)".

$ python -c “import tensorflow; print(tensorflow.version)” I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.7.5.dylib locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.5.dylib locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.7.5.dylib locally Segmentation fault: 11

Steps to reproduce

1.) Create a conda environment 2.) Followed https://www.tensorflow.org/versions/r0.9/get_started/os_setup.html#installation-for-mac-os-x 3.) Launch python and import tensorflow

What have you tried?

  1. importing numpy before importing tensorflow
  2. ensuring that I’m outside the tensorflow source directory (well outside)
  3. adding /Developer/NVIDIA/CUDA-7.5/lib to the DYLD_LIBRARY_PATH, per #2773 4.) uninstalling and reinstalling everything and trying again.

Logs or other output that would be helpful

Output from bt, after using gdb to run test script with only line, ‘import tensorflow’ I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcublas.7.5.dylib locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcudnn.5.dylib locally I tensorflow/stream_executor/dso_loader.cc:108] successfully opened CUDA library libcufft.7.5.dylib locally

Program received signal SIGSEGV, Segmentation fault. 0x00007fff8d2b8f92 in strlen () from /usr/lib/system/libsystem_c.dylib

(gdb) bt #0 0x00007fff8d2b8f92 in strlen () from /usr/lib/system/libsystem_c.dylib #1 0x0000000104a0b4f0 in perftools::gputools::internal::DsoLoader::GetDsoHandle(tensorflow::StringPiece, void, perftools::gputools::internal::DsoLoader::LoadKind) ()

from /Users/lw17567/anaconda2/envs/tensorflow2/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so #2 0x0000000104a0c06c in perftools::gputools::internal::DsoLoader::GetLibcudaDsoHandle(void) ()

from /Users/lw17567/anaconda2/envs/tensorflow2/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so #3 0x0000000104a0d0d2 in std::__1::__function::__func, tensorflow::Status (void)>::operator()(void&&) ()

from /Users/lw17567/anaconda2/envs/tensorflow2/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so #4 0x0000000104a0c86f in perftools::gputools::internal::CachedDsoLoader::FetchHandleResult(std::__1::function) ()

from /Users/lw17567/anaconda2/envs/tensorflow2/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so #5 0x0000000104a0cdcf in perftools::gputools::internal::CachedDsoLoader::GetLibcudaDsoHandle() ()

from /Users/lw17567/anaconda2/envs/tensorflow2/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so —Type to continue, or q to quit— #6 0x0000000104a8ebe5 in perftools::gputools::initialize_cuda_gpu_executor()

() from /Users/lw17567/anaconda2/envs/tensorflow2/lib/python2.7/site-packages/tensorflow/python/_pywrap_tensorflow.so #7 0x00007fff5fc12d4b in ?? () #8 0x000000155fbfc830 in ?? () #9 0x0000000000000001 in ?? () #10 0x00000001034c02e8 in ?? () #11 0x00000001034c0740 in ?? () #12 0x00000001034c0420 in ?? () #13 0x00007fff5fc38660 in ?? () #14 0x00000000000001b8 in ?? () #15 0x00000001004613d0 in ?? () #16 0x00007fff5fbfc8a0 in ?? () #17 0x0000000000000713 in ?? () #18 0x00007fff5fc38598 in ?? () #19 0x00007fff5fc41a38 in ?? () #20 0x00007fff5fbfc830 in ?? () #21 0x00007fff5fc12ed8 in ?? () #22 0x00000001004613d0 in ?? () #23 0x0000b481cbaa22ee in ?? () #24 0x00007fff5fbfc890 in ?? () #25 0x00007fff5fc0f8d1 in ?? ()

—Type to continue, or q to quit— #26 0x0000000000000000 in ?? ()

If necessary, please see the full gdb output, and deviceQuery (CUDA sample) output in my related comments in #2773 .

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

Having the same problem, It appears that it fails when loading libcuda.dylib. Unfortunately, since https://github.com/tensorflow/tensorflow/pull/2878 it’s now looking for libcuda.1.dylib instead.

Creating a symlink or changing the name of libcuda.dylib to libcuda.1.dylib in /usr/local/cuda/lib seems to do the job.

@jrimestad Might be too late for your question, but for anyone who doesn’t know how to add the symlink:

sudo ln -sf /usr/local/cuda/lib/libcuda.dylib /usr/local/cuda/lib/libcuda.1.dylib

run this in terminal will do the trick.

In my case i was getting seg fault 11 when importing tensorflow to my virtual env python. Then I suspected I was doing some rookie mistake in my .bash_profile. I found this link The tell you to add this to your bash: export CUDA_HOME="/usr/local/cuda" export DYLD_LIBRARY_PATH="$CUDA_HOME/lib:$DYLD_LIBRARY_PATH" export PATH="$CUDA_HOME/bin:$PATH" I suspect it is crucial to define a CUDA_HOME variable on your bash. Now my tensorflow is up and running on python.

@Menerve we’ve been told that this is a bug in the naming / packaging for OS X cuda installs – I think we’re waiting for the real fix by them, which is to name the library with a .1, and maybe add the symlink.