# 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 ``` 2. Install Tensorflow For GPU and CPU ``` pip install tensorflow ``` or Preview build (CPU) ``` pip install tf-nightly ``` - Testing ```python= import keras # Keras would call Tensorflow. ``` ### Help - Tensorflow is installed, but "ImportError: DLL load failed". - Install [Microsoft Visual C++ Redistributable](https://support.microsoft.com/zh-tw/help/2977003/the-latest-supported-visual-c-downloads) - 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 - Requirements - [NVIDIA® GPU drivers](https://www.nvidia.com/drivers) - CUDA 10.1 requires 418.x or higher. - [CUDA® Toolkit](https://developer.nvidia.com/cuda-toolkit-archive) - TensorFlow supports CUDA 10.1 (TensorFlow >= 2.1.0) - [cuDNN SDK](https://developer.nvidia.com/cudnn) - (>= 7.6) - Testing ```python= 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](https://www.joe0.com/wp-content/uploads/2019/10/cudart64_100.dll_.zip) > Ref: > https://www.tensorflow.org/install/gpu > [https://www.joe0.com](https://www.joe0.com/2019/10/19/how-resolve-tensorflow-2-0-error-could-not-load-dynamic-library-cudart64_100-dll-dlerror-cudart64_100-dll-not-found/) ## Keras Example - [Link](https://github.com/keras-team/keras/tree/master/examples)