網頁

2021年2月24日 星期三

TensorFlow2.4.1 CUBLAS_STATUS_ALLOC_FAILED 問題解決方法

 在網路上找到的解決方法 .


import tensorflow as tf

gpus = tf.config.experimental.list_physical_devices('GPU')

if gpus:

    try:

        # Currently, memory growth needs to be the same across GPUs

        for gpu in gpus:

            tf.config.experimental.set_memory_growth(gpu, True)

        logical_gpus = tf.config.experimental.list_logical_devices('GPU')

        print(len(gpus), "Physical GPUs,", len(logical_gpus), "Logical GPUs")

    except RuntimeError as e:

        # Memory growth must be set before GPUs have been initialized

        print(e)


2021年2月7日 星期日

Install Windows 10 + python 3.8.5 + CUDA 11.1 + cuDNN 8.1.0 + TensorFlow 2.4.1

1. Create python 3.8.5 Environment

2. Update Nvidia graphic driver version to 461.40

https://www.nvidia.com/download/index.aspx?lang=en-us

3. Download and Install CUDA 11.1 for Windows 10

https://developer.nvidia.com/cuda-toolkit-archive

4. Download and unzip cuDNN 8.1.0

https://developer.nvidia.com/rdp/cudnn-download#a-collapse805-110

Copy bin, include, lib three folders under cuda unzip folder to 

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1

Copy bin folder under cuda unzip folder to 

<anaconda_install_path>\Anaconda3\envs\<env_name>\Library

Add :

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.1\lib\x64

to [Path] System Environment variable

5. Install cudatoolkit 11.0.221
    conda install cudatoolkit

6. Install TensorFlow 2.4.1  (This version include TensorFlow-GPU and Keras)
    pip install --upgrade tensorflow

7. Verify TensorFlow 
    from tensorflow.python.client import device_lib
    
    print(device_lib.list_local_devices())

8. Verify Keras (tensorflow.keras)
     
    import keras ==> import tensorflow.keras