Tensorflow doesn't seem to see my gpu

前端 未结 6 2032
面向向阳花
面向向阳花 2020-12-09 01:19

I\'ve tried tensorflow on both cuda 7.5 and 8.0, w/o cudnn (my GPU is old, cudnn doesn\'t support it).

When I execute device_lib.list_local_devices(),

6条回答
  •  抹茶落季
    2020-12-09 01:59

    Summary:

    1. check if tensorflow sees your GPU (optional)
    2. check if your videocard can work with tensorflow (optional)
    3. find versions of CUDA Toolkit and cuDNN SDK, compatible with your tf version
    4. install CUDA Toolkit
    5. install cuDNN SDK
    6. pip uninstall tensorflow; pip install tensorflow-gpu
    7. check if tensorflow sees your GPU

    * source - https://www.tensorflow.org/install/gpu

    Detailed instruction:

    1. check if tensorflow sees your GPU (optional)

      from tensorflow.python.client import device_lib
      def get_available_devices():
          local_device_protos = device_lib.list_local_devices()
          return [x.name for x in local_device_protos]
      print(get_available_devices()) 
      # my output was => ['/device:CPU:0']
      # good output must be => ['/device:CPU:0', '/device:GPU:0']
      
    2. check if your card can work with tensorflow (optional)

      • my PC: GeForce GTX 1060 notebook (driver version - 419.35), windows 10, jupyter notebook
      • tensorflow needs Compute Capability 3.5 or higher. (https://www.tensorflow.org/install/gpu#hardware_requirements)

      • https://developer.nvidia.com/cuda-gpus

      • select "CUDA-Enabled GeForce Products"
      • result - "GeForce GTX 1060 Compute Capability = 6.1"
      • my card can work with tf!
    3. find versions of CUDA Toolkit and cuDNN SDK, that you need

      a) find your tf version

      import sys
      print (sys.version)
      # 3.6.4 |Anaconda custom (64-bit)| (default, Jan 16 2018, 10:22:32) [MSC v.1900 64 bit (AMD64)]
      import tensorflow as tf
      print(tf.__version__)
      # my output was => 1.13.1
      

      b) find right versions of CUDA Toolkit and cuDNN SDK for your tf version

      https://www.tensorflow.org/install/source#linux
      * it is written for linux, but worked in my case
      see, that tensorflow_gpu-1.13.1 needs: CUDA Toolkit v10.0, cuDNN SDK v7.4
      
    4. install CUDA Toolkit

      a) install CUDA Toolkit 10.0

      https://developer.nvidia.com/cuda-toolkit-archive
      select: CUDA Toolkit 10.0 and download base installer (2 GB)
      installation settings: select only CUDA
          (my installation path was: D:\Programs\x64\Nvidia\Cuda_v_10_0\Development)
      

      b) add environment variables:

      system variables / path must have:
          D:\Programs\x64\Nvidia\Cuda_v_10_0\Development\bin
          D:\Programs\x64\Nvidia\Cuda_v_10_0\Development\libnvvp
          D:\Programs\x64\Nvidia\Cuda_v_10_0\Development\extras\CUPTI\libx64
          D:\Programs\x64\Nvidia\Cuda_v_10_0\Development\include
      
    5. install cuDNN SDK

      a) download cuDNN SDK v7.4

      https://developer.nvidia.com/rdp/cudnn-archive (needs registration, but it is simple)
      select "Download cuDNN v7.4.2 (Dec 14, 2018), for CUDA 10.0"
      

      b) add path to 'bin' folder into "environment variables / system variables / path":

      D:\Programs\x64\Nvidia\cudnn_for_cuda_10_0\bin
      
    6. pip uninstall tensorflow pip install tensorflow-gpu

    7. check if tensorflow sees your GPU

      - restart your PC
      - print(get_available_devices()) 
      - # now this code should return => ['/device:CPU:0', '/device:GPU:0']
      

提交回复
热议问题