【问题标题】:Testing GPU is available or not for tensorflow测试 GPU 是否可用于 tensorflow
【发布时间】:2021-01-13 14:57:23
【问题描述】:

在这里我检查了我是否使用 GPU。我安装了所有东西,但我不知道这个错误是什么意思。请帮助解决此错误。

 import tensorflow as tf
 print(tf.test.is_gpu_available())


C:\Users\vinot\AppData\Local\Programs\Python\Python37\python.exe "C:\Program Files\JetBrains\PyCharm 2020.2.1\plugins\python\helpers\pydev\pydevconsole.py" --mode=client --port=60324
    import sys; print('Python %s on %s' % (sys.version, sys.platform))
    sys.path.extend(['D:\\python\\python_work\\pythonProject', 'D:/python/python_work/pythonProject'])
    PyDev console: starting.
    Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
    >>> runfile('D:/python/python_work/pythonProject/hello world.py', wdir='D:/python/python_work/pythonProject')
    2021-01-13 23:51:37.257501: W tensorflow/stream_executor/platform/default/dso_loader.cc:55] Could not load dynamic library 'cudart64_100.dll'; dlerror: cudart64_100.dll not found
    2021-01-13 23:51:38.887931: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
    2021-01-13 23:51:38.890213: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
    2021-01-13 23:51:38.921531: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties: 
    name: GeForce RTX 3070 major: 8 minor: 6 memoryClockRate(GHz): 1.725
    pciBusID: 0000:01:00.0
    2021-01-13 23:51:38.921695: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check.
    2021-01-13 23:51:38.921899: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0
    Traceback (most recent call last):
      File "<input>", line 1, in <module>
      File "C:\Program Files\JetBrains\PyCharm 2020.2.1\plugins\python\helpers\pydev\_pydev_bundle\pydev_umd.py", line 197, in runfile
        pydev_imports.execfile(filename, global_vars, local_vars)  # execute the script
      File "C:\Program Files\JetBrains\PyCharm 2020.2.1\plugins\python\helpers\pydev\_pydev_imps\_pydev_execfile.py", line 18, in execfile
        exec(compile(contents+"\n", file, 'exec'), glob, loc)
      File "D:/python/python_work/pythonProject/hello world.py", line 2, in <module>
        print(tf.test.is_gpu_available())
      File "C:\Users\vinot\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\framework\test_util.py", line 1432, in is_gpu_available
        for local_device in device_lib.list_local_devices():
      File "C:\Users\vinot\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\client\device_lib.py", line 41, in list_local_devices
        for s in pywrap_tensorflow.list_devices(session_config=session_config)
      File "C:\Users\vinot\AppData\Local\Programs\Python\Python37\lib\site-packages\tensorflow_core\python\pywrap_tensorflow_internal.py", line 2249, in list_devices
        return ListDevices()
    tensorflow.python.framework.errors_impl.InternalError: cudaGetDevice() failed. Status: cudaGetErrorString symbol not found.

【问题讨论】:

  • 此方法已弃用,不确定其替换是否有帮助,但您不妨试试 - tf.config.list_physical_devices('GPU')

标签: python tensorflow gpu


【解决方案1】:

在 Tensorflow API Docs 中,tf.test.is_gpu_available() 方法已被弃用。要更新,请使用:

tf.config.list_physical_devices('GPU')

【讨论】:

    猜你喜欢
    • 2017-07-14
    • 1970-01-01
    • 2017-10-28
    • 1970-01-01
    • 2023-02-06
    • 2019-08-17
    • 2017-02-21
    • 1970-01-01
    • 2020-12-04
    相关资源
    最近更新 更多