Illegal instruction (core dumped) after running import tensorflow

后端 未结 6 708
南方客
南方客 2020-11-29 08:21

I created a fresh virtual environment: virtualenv -p python2 test_venv/ And installed tensorflow: pip install --upgrade --no-cache-dir tensorflow

相关标签:
6条回答
  • 2020-11-29 08:33

    I had a similar issue and it turned out that it is due to I have slightly old CPU and that doesn't work very well with 1.6+ versions of TensorFlow https://www.tensorflow.org/install/source

    Note: Starting with TensorFlow 1.6, binaries use AVX instructions which may not run on older CPUs.

    So as mentioned before you can either install TensorFlow 1.5, or if you still want the latest version of TF, you will need to install it with conda instead (both solutions worked with me)

    For conda installation:

    conda create -n tensorflow
    conda install tensorflow-gpu -n tensorflow
    

    https://github.com/tensorflow/tensorflow/issues/17411

    0 讨论(0)
  • 2020-11-29 08:35

    Unfortunately, 1.6 has given many people the same error. I received it after installing 1.7 on a machine with an old Core2 CPU. I've settled with 1.5, as I can't fit the big graphics card in the machine with the up-to-date processor!

    0 讨论(0)
  • 2020-11-29 08:40

    I would use older version. Looks like your CPU does not support AVX instructions.

    Quoting from their Release Page

    Breaking Changes
    Prebuilt binaries are now built against CUDA 9.0 and cuDNN 7.
    Prebuilt binaries will use AVX instructions. This may break TF on older CPUs.
    

    You have atleast two options:

    1. Use tensorflow 1.5 or older

    2. Build from source

    Regarding your concern for differences, you will miss out on new features, but most basic features and documentations are not that different.

    0 讨论(0)
  • 2020-11-29 08:45

    As explained in the accepted answer, this issue can be fixed either by installing older version of TensorFlow (v1.5) or building from source. Between the two, building from source is arguably a preferred route despite the additional effort. Granted that the binary contains the most updated components of TensorFlow.

    This article explains how to build TensorFlow from sources and optimizes for the older CPU. The key is in detecting the CPU flags and enable all the CPU flags for optimization when configuring the build.

    The following command is used to detect common CPU optimization flags:

    $ grep flags -m1 /proc/cpuinfo | cut -d ":" -f 2 | tr '[:upper:]' '[:lower:]' | { read FLAGS; OPT="-march=native"; for flag in $FLAGS; do case "$flag" in "sse4_1" | "sse4_2" | "ssse3" | "fma" | "cx16" | "popcnt" | "avx" | "avx2") OPT+=" -m$flag";; esac; done; MODOPT=${OPT//_/\.}; echo "$MODOPT"; }
    

    If by executing the command, -mavx and/or -mavx2 is not shown, it can be confirmed that AVX support is missing and the source build should be done with other optimization flags displayed in the output.

    In a related article, the common root cause of this issue is discussed in more details, which is provided as an additional reference.

    0 讨论(0)
  • 2020-11-29 08:53

    The following steps worked for me. (remove exsisting tensorflow)

    inside conda virtual env

    step 1: install keras-application using pip

    step 2: install tensorflow (no need to downgrade)

    0 讨论(0)
  • 2020-11-29 08:56

    There is an issue on github about this, which seems to have gotten little interest from the tensorflow team, unfortunately.

    There are a few community builds around the web that might work depending on your situation:

    • https://github.com/fo40225/tensorflow-windows-wheel
    • https://github.com/yaroslavvb/tensorflow-community-wheels
    • https://github.com/lakshayg/tensorflow-build
    • https://github.com/mind/wheels
    0 讨论(0)
提交回复
热议问题