Runtime environment: Anaconda’s virtual environment
A lot of people say this is because of the CUDA version, but I’ve found that another reason is the Python version of TensorFlow. If you look at the picture, TensorFlow at this point is Python 2.7.
So when I’m using Python 2.7, I don’t get anything wrong
I got an error when I imported TensorFlow in Python 3.6
Use the Conda List to see the Python version
I found that the default version of Python is 2.7. I created this virtual environment with 3.6, but for some reason it changed to 2.7.
The solution. Re-create the Conda environment and re-install TensorFlow.
A lot of people say this is because of the CUDA version, but I’ve found that another reason is the Python version of TensorFlow. If you look at the picture, TensorFlow at this point is Python 2.7.
So when I’m using Python 2.7, I don’t get anything wrong
I got an error when I imported TensorFlow in Python 3.6
Use the Conda List to see the Python version
I found that the default version of Python is 2.7. I created this virtual environment with 3.6, but for some reason it changed to 2.7.
The solution. Re-create the Conda environment and re-install TensorFlow.
conda create --name tensorflow python=3.6
conda install tensorflow
conda install tensorflow-gpu
conda list
Once installed, you will notice that TensorFlow is now Python 3.6.
Look at the default Python version
Is 3.6. The TensorFlow version corresponds to the Python version, so it should work fine.
As for why the Python version of the Anaconda virtual environment changed, I’m not sure.