Try   HackMD

Keras 2.x & Tensorflow 2.x 安裝疑難雜症

tags: ISLab, Keras, Tensorflow, ML
  • 2020/02/11
    • Python: 3.7.6
    • Tensorflow: 2.1.0
    • Keras: 2.3.1
    • CUDA: 10.1.2

Build the environment

  1. Install Keras
pip install keras
  1. Install Tensorflow

For GPU and CPU

pip install tensorflow

or Preview build (CPU)

pip install tf-nightly
  • Testing
import keras # Keras would call Tensorflow.

Help

  • Tensorflow is installed, but "ImportError: DLL load failed".
  • AttributeError: module 'tensorflow' has no attribute 'get_default_graph'
    • Tensorflow and keras version not match.

Ref:
https://www.tensorflow.org/install/pip
https://github.com/keras-team/keras

GPU support

tf.config.experimental.list_physical_devices('GPU') print("Num GPUs Available: ", len( tf.config.experimental.list_physical_devices('GPU')))

Help

  • If it shows "cudart64_101.dll" or "cudart64_100.dll" not found,
    "cudart64_101.dll" is in CUDA 10.1
    "cudart64_100.dll" is here

Ref:
https://www.tensorflow.org/install/gpu
https://www.joe0.com

Keras Example