Tensorflow stuck after "Created TensorFlow device"

Viewed 632

I'm working on Ubuntu 18.04 with tensorflow==2.2.

I've installed cuda 10.1. My GPU is detected but the program seems to be stucked after "Created TensorFlow device" or at least takes 2-3 minutes to run.

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 |
+-----------------------------------------------------------------------------+

Importing works fine:

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

Output:

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')]

But this seems to be stucked:

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)
...

I've installed tensorflow with pip3 install tensorflow==2.2 and also tried pip3 install tensorflow-gpu.

Any ideas?

1 Answers

Please check below if you have followed all the required steps properly to install Tensorflow-gpu on ubuntu.

STEP 1: Nvidia Drivers
STEP 2: Installation of NVIDIA CUDA
STEP 3: Installation of Deep Neural Network library (cuDNN)
STEP 4: Finally installing TENSORFLOW with GPU support

pip install --upgrade tensorflow-gpu

STEP 5: Checking the installation

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

You can check this reference to complete all these steps, then execute the same above code. Please let us know if issue still persists.

Related