Python Tensorflow 2.0rc未检测到GPU

Python Tensorflow 2.0rc未检测到GPU,python,keras,tensorflow2.0,Python,Keras,Tensorflow2.0,TF2当前未检测到GPU,我从TF1.14迁移,其中使用 tf.keras.utils.multi_gpu_model(model=model, gpus=2) 正在返回一个错误 ValueError: To call `multi_gpu_model` with `gpus=2`, we expect the following devices to be available: ['/cpu:0', '/gpu:0', '/gpu:1']. However this machine only

TF2当前未检测到GPU,我从TF1.14迁移,其中使用

tf.keras.utils.multi_gpu_model(model=model, gpus=2)
正在返回一个错误

ValueError: To call `multi_gpu_model` with `gpus=2`, we expect the following devices to be available: ['/cpu:0', '/gpu:0', '/gpu:1']. However this machine only has: ['/cpu:0', '/xla_cpu:0', '/xla_gpu:0', '/xla_gpu:1', '/xla_gpu:2', '/xla_gpu:3']. Try reducing `gpus`.
运行
nvidia smi
返回以下信息

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 418.67       Driver Version: 418.67       CUDA Version: 10.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  Tesla K80           Off  | 00000000:09:00.0 Off |                    0 |
| N/A   46C    P0    62W / 149W |      0MiB / 11441MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   1  Tesla K80           Off  | 00000000:0A:00.0 Off |                    0 |
| N/A   36C    P0    71W / 149W |      0MiB / 11441MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   2  Tesla K80           Off  | 00000000:86:00.0 Off |                    0 |
| N/A   38C    P0    58W / 149W |      0MiB / 11441MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+
|   3  Tesla K80           Off  | 00000000:87:00.0 Off |                    0 |
| N/A   31C    P0    82W / 149W |      0MiB / 11441MiB |     73%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+
也是我的TF版本,是专为cuda打造的

2.0.0-rc0

请让我知道我做错了什么,以便我可以修复它。

CUDA应该是10.0版,而不是10.1版

我建议您-

  • 请先检查您的Cuda版本。确保它是10.0

  • 如果是10.0,那么检查您的TF版本是否适用于GPU

  • 检查TF是否可以使用命令访问GPU

  • 我想前2点已经被你解决了。如果TF也可以访问您的GPU,那么正如您在
    值错误中看到的那样,它实际上有GPU的名称。我不能谈论
    tf.keras.utils.multi\u gpu\u model()
    函数,因为我没有在tf中使用它。但是我建议您将
    与tf.device('/gpu:0'):
    一起使用。在这里,您可以调用
    模型
    或定义模型
  • 如果第4点也不起作用,那么只需添加以下行

  • 在文件的顶部,使用tf.device('/gpu:0')删除

    ,我建议您-

  • 请先检查您的Cuda版本。确保它是10.0

  • 如果是10.0,那么检查您的TF版本是否适用于GPU

  • 检查TF是否可以使用命令访问GPU

  • 我想前2点已经被你解决了。如果TF也可以访问您的GPU,那么正如您在
    值错误中看到的那样,它实际上有GPU的名称。我不能谈论
    tf.keras.utils.multi\u gpu\u model()
    函数,因为我没有在tf中使用它。但是我建议您将
    与tf.device('/gpu:0'):
    一起使用。在这里,您可以调用
    模型
    或定义模型
  • 如果第4点也不起作用,那么只需添加以下行

  • 在文件顶部,使用tf.device('/gpu:0')删除

    您从pip安装了哪个软件包
    tensorflow
    tensorflow gpu
    ?tensorflow gpu,我使用命令pip install tensorflow gpu==2.0.0-RC0从pip安装了哪个软件包
    tensorflow
    tensorflow gpu
    ?tensorflow gpu,我使用命令pip install tensorflow gpu==2.0.0-rc0
    value = tf.test.is_gpu_available(
        cuda_only=False,
        min_cuda_compute_capability=None
    )
    print ('***If TF can access GPU: ***\n\n',value) # MUST RETURN True IF IT CAN!!
    
    import os
    os.environ["CUDA_VISIBLE_DEVICES"] = "0,1,2,3" # 0,1,2,3 are number of GPUs