【问题标题】:Tensorflow stuck after "Created TensorFlow device"TensorFlow 在“创建 TensorFlow 设备”后卡住
【发布时间】:2021-01-27 20:07:29
【问题描述】:

我正在使用 tensorflow==2.2 开发 Ubuntu 18.04。

我已经安装了 cuda 10.1。我的 GPU 被检测到,但程序似乎在 "Created TensorFlow device" 之后卡住了,或者至少需要 2-3 分钟才能运行。

nvcc --version

    nvcc: NVIDIA (R) Cuda compiler driver
    Copyright (c) 2005-2019 NVIDIA Corporation
    Built on Sun_Jul_28_19:07:16_PDT_2019
    Cuda compilation tools, release 10.1, V10.1.243

nvidia-smi

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 455.23.05    Driver Version: 455.23.05    CUDA Version: 11.1     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  GeForce GTX 750 Ti  On   | 00000000:01:00.0  On |                  N/A |
| 32%   34C    P0     1W /  38W |    320MiB /  2000MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                               
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1013      G   /usr/lib/xorg/Xorg                 24MiB |
|    0   N/A  N/A      1130      G   /usr/bin/gnome-shell               48MiB |
|    0   N/A  N/A      1343      G   /usr/lib/xorg/Xorg                178MiB |
|    0   N/A  N/A      1489      G   /usr/bin/gnome-shell               48MiB |
|    0   N/A  N/A      2643      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A      2734      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A      2778      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A      5438      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A      6178      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A      6691      G   /usr/lib/firefox/firefox            1MiB |
|    0   N/A  N/A      7007      G   /usr/lib/firefox/firefox            1MiB |
+-----------------------------------------------------------------------------+

导入工作正常:

import tensorflow as tf
tf.config.list_physical_devices("GPU")

输出:

Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce GTX 750 Ti computeCapability: 5.0
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

但这似乎卡住了:

print(tf.reduce_sum(tf.random.normal([1000, 1000])))

Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1425 MB memory) -> physical GPU (device: 0, name: GeForce GTX 750 Ti, pci bus id: 0000:01:00.0, compute capability: 5.0)
...

我已经使用pip3 install tensorflow==2.2 安装了 tensorflow,还尝试了pip3 install tensorflow-gpu

有什么想法吗?

【问题讨论】:

    标签: python tensorflow machine-learning


    【解决方案1】:

    请检查您是否已正确按照所有必需的步骤在ubuntu 上安装Tensorflow-gpu

    第 1 步:Nvidia 驱动程序
    第 2 步:安装 NVIDIA CUDA
    第 3 步:安装深度神经网络库 (cuDNN)
    第 4 步:最后安装支持 GPU 的 TENSORFLOW

    pip install --upgrade tensorflow-gpu
    

    第 5 步:检查安装

    python -c "from tensorflow.python.client import device_lib;
    print(device_lib.list_local_devices())
    

    您可以查看this 参考以完成所有这些步骤,然后执行上述相同的代码。如果问题仍然存在,请告诉我们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-07-09
      • 1970-01-01
      • 2017-11-08
      • 2019-03-27
      • 1970-01-01
      • 2021-10-28
      • 1970-01-01
      • 2017-04-04
      相关资源
      最近更新 更多