Tensorflow 에서 GPU 가능 여부 확인 법

    Tensorflow가 내 GPU를 활용하고 있는지 확인하려면, tensorflow에서 제공하는 device_lib 라이브러리를 활용하면 된다.

    (mrc) [root@nipa2019-0010 mrc] python
    Python 3.6.8 |Anaconda, Inc.| (default, Dec 30 2018, 01:22:34) 
    [GCC 7.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from tensorflow.python.client import device_lib
    >>> device_lib.list_local_devices()

    from tensorflow.python.client import device_lib

    device_lib.list_local_devices()

     

    위와 같은 명령어를 수행하면 필자의 경우 아래와 같은 정보를 화면에 보여주었다.

    2020-06-15 14:57:48.947748: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
    2020-06-15 14:57:49.156328: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:964] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
    2020-06-15 14:57:49.157817: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 0 with properties: 
    name: Tesla V100-PCIE-32GB major: 7 minor: 0 memoryClockRate(GHz): 1.38
    pciBusID: 0000:00:05.0
    totalMemory: 31.75GiB freeMemory: 31.44GiB
    2020-06-15 14:57:49.308937: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:964] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
    2020-06-15 14:57:49.310258: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1411] Found device 1 with properties: 
    name: Tesla V100-PCIE-32GB major: 7 minor: 0 memoryClockRate(GHz): 1.38
    pciBusID: 0000:00:06.0
    totalMemory: 31.75GiB freeMemory: 31.44GiB
    2020-06-15 14:57:49.310338: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1490] Adding visible gpu devices: 0, 1
    2020-06-15 14:57:50.139037: I tensorflow/core/common_runtime/gpu/gpu_device.cc:971] Device interconnect StreamExecutor with strength 1 edge matrix:
    2020-06-15 14:57:50.139088: I tensorflow/core/common_runtime/gpu/gpu_device.cc:977]      0 1 
    2020-06-15 14:57:50.139137: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 0:   N N 
    2020-06-15 14:57:50.139148: I tensorflow/core/common_runtime/gpu/gpu_device.cc:990] 1:   N N 
    2020-06-15 14:57:50.139312: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/device:GPU:0 with 30503 MB memory) -> physical GPU (device: 0, name: Tesla V100-PCIE-32GB, pci bus id: 0000:00:05.0, compute capability: 7.0)
    2020-06-15 14:57:50.586570: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1103] Created TensorFlow device (/device:GPU:1 with 30503 MB memory) -> physical GPU (device: 1, name: Tesla V100-PCIE-32GB, pci bus id: 0000:00:06.0, compute capability: 7.0)
    [name: "/device:CPU:0"
    device_type: "CPU"
    memory_limit: 268435456
    locality {
    }
    incarnation: 869474478715071609
    , name: "/device:GPU:0"
    device_type: "GPU"
    memory_limit: 31985477223
    locality {
      bus_id: 1
      links {
      }
    }
    incarnation: 12179460544041194412
    physical_device_desc: "device: 0, name: Tesla V100-PCIE-32GB, pci bus id: 0000:00:05.0, compute capability: 7.0"
    , name: "/device:GPU:1"
    device_type: "GPU"
    memory_limit: 31985477223
    locality {
      bus_id: 1
      links {
      }
    }
    incarnation: 3329334536086686166
    physical_device_desc: "device: 1, name: Tesla V100-PCIE-32GB, pci bus id: 0000:00:06.0, compute capability: 7.0"
    ]

    GPU가 잡힌 것을 확인 할 수 있고, 이는 이 GPU를 이용하여 작업이 가능하다는 의미이다.

     

     

    반응형

    댓글

    Designed by JB FACTORY