tensorflow: Tensorflow not detecting GPU

Issue type

Build/Install

Have you reproduced the bug with TensorFlow Nightly?

No

Source

binary

TensorFlow version

2.16.1

Custom code

No

OS platform and distribution

SUSE Linux Enterprise Server 15 SP3

Mobile device

No response

Python version

3.10.13

Bazel version

No response

GCC/compiler version

No response

CUDA/cuDNN version

CUDA 12.4

GPU model and memory

NVIDIA A2, 16GB

Current behavior?

TensorFlow is not recognising the NVIDIA A2 GPU or any other CUDA devices on my Server.

Standalone code to reproduce the issue

python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

Relevant log output

python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
2024-04-02 08:37:38.517925: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-04-02 08:37:38.570940: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-04-02 08:37:39.624139: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
2024-04-02 08:37:40.270665: E external/local_xla/xla/stream_executor/cuda/cuda_driver.cc:282] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected
2024-04-02 08:37:40.270724: I external/local_xla/xla/stream_executor/cuda/cuda_diagnostics.cc:134] retrieving CUDA diagnostic information for host: HOST
2024-04-02 08:37:40.270738: I external/local_xla/xla/stream_executor/cuda/cuda_diagnostics.cc:141] hostname: HOST
2024-04-02 08:37:40.270865: I external/local_xla/xla/stream_executor/cuda/cuda_diagnostics.cc:165] libcuda reported version is: 550.54.14
2024-04-02 08:37:40.270887: I external/local_xla/xla/stream_executor/cuda/cuda_diagnostics.cc:169] kernel reported version is: 550.54.14
2024-04-02 08:37:40.270896: I external/local_xla/xla/stream_executor/cuda/cuda_diagnostics.cc:248] kernel version seems to match DSO: 550.54.14

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 18 (2 by maintainers)

Most upvoted comments

Apparently, TF has not been compiled with CUDA for windows, which is outrageous in this day and age. All documentation state to downgrade to some other version or recompile use WSL. Both ridiculous statements just showing laziness for wanting to dive into the issue. If you can do it before, and in WSL, it should be straight forward to do it also in MSYS/MinGW.

PS. I don’t roll back, I only roll forward!

I absolutely agree. I now also installed it also on Win11 and the only way I managed to do so was via Conda. For someone that is not allowed to use conda that is a big issue, I did not find another way. But that is a indeed ridiculous.

Apparently, TF has not been compiled with CUDA for windows, which is outrageous in this day and age. All documentation state to downgrade to some other version or recompile use WSL. Both ridiculous statements just showing laziness for wanting to dive into the issue. If you can do it before, and in WSL, it should be straight forward to do it also in MSYS/MinGW.

PS. I don’t roll back, I only roll forward!

Unfortunately, like all you, I wasn’t able to access my GPU as backend in TF. I have also tried all the way of installing it -pip, .deb, .tar… It’s very hard to access GPU with other versions.

At last, I found a method for accessing GPU as backend, only by using python3.11 and TensorFlow 2.15.1, other than these versions nothing suits.

try this by creating a virtual environment:

conda create -n tmpenv python=3.11
conda activate tmpenv
pip install tensorflow[and-cuda]==2.15.1

if all your GPU driver and cuda is installed, you should be able to run this command:

nvidia-smi

to check if GPU is detected by TF:

python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"

probably you should get:

[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

Let me know, if this works for you all!

Wonder why it is so difficult to install Tensor flow for GPU now. Tensor Flow 2.16.1 is so full of bugs and can only work on WSL and that too doesn’t detect my GPU. Tried on different machines with same issue of Nvidia GPU not being detected. Only solution was to roll back to 2.15.1 that too after getting some weird warnings after command executions. Would prefer to use PyTorch instead of TensorFlow. PyTorch is so easy to install & use with minimum complications.

On Wed, May 15, 2024, 10:56 PM eabase @.***> wrote:

I wonder if we could extract the latest TF package binaries from Conda, as it seem to work there? Maybe install Conda in VM and lookup the packages. Sad way to have to fix this though.

— Reply to this email directly, view it on GitHub https://github.com/tensorflow/tensorflow/issues/64881#issuecomment-2113127123, or unsubscribe https://github.com/notifications/unsubscribe-auth/AIVENFB4235FWSAL5XFQHOLZCOOTRAVCNFSM6AAAAABFSYT73OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMJTGEZDOMJSGM . You are receiving this because you commented.Message ID: @.***>

@RetusRieben or pip but install TF 2.15.1 (I’m not saying it’s great solution, but at least working somehow)

Agreed with you both, that it’s just outrageous not compile libs properly. Hope it will be fixed soon

Same issue here.
I have Nvidia RTX 4060 Laptop, and command from above show nothing about GPU.

# python -c "import tensorflow as tf; print(tf.config.list_physical_devices())"
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]

I tried installing Tensorflow using both conda and pip. My Nvidia Gpu is not detected when I do print(tf.config.list_physical_devices(‘GPU’)). I had installed using python3 -m pip install tensorflow[and-cuda]. Should i try Tensorflow version 2.15.1?

python3 -c “import tensorflow as tf; print(tf.config.list_physical_devices(‘GPU’))” 2024-04-04 14:42:07.986529: I tensorflow/core/util/port.cc:113] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable TF_ENABLE_ONEDNN_OPTS=0. 2024-04-04 14:42:08.027002: I tensorflow/core/platform/cpu_feature_guard.cc:210] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations. To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags. 2024-04-04 14:42:08.826422: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT 2024-04-04 14:42:09.350663: E external/local_xla/xla/stream_executor/cuda/cuda_driver.cc:282] failed call to cuInit: CUDA_ERROR_NO_DEVICE: no CUDA-capable device is detected 2024-04-04 14:42:09.350711: I external/local_xla/xla/stream_executor/cuda/cuda_diagnostics.cc:134] retrieving CUDA diagnostic information for host: Host 2024-04-04 14:42:09.350722: I external/local_xla/xla/stream_executor/cuda/cuda_diagnostics.cc:141] hostname: Host 2024-04-04 14:42:09.350809: I external/local_xla/xla/stream_executor/cuda/cuda_diagnostics.cc:165] libcuda reported version is: 550.54.14 2024-04-04 14:42:09.350834: I external/local_xla/xla/stream_executor/cuda/cuda_diagnostics.cc:169] kernel reported version is: 550.54.14 2024-04-04 14:42:09.350845: I external/local_xla/xla/stream_executor/cuda/cuda_diagnostics.cc:248] kernel version seems to match DSO: 550.54.14

the following output is generated if I run

python3 -c “import tensorflow as tf; print(tf.config.list_physical_devices(‘GPU’))”

My user has ROOT rights