Tensorflow not detecting GPU
Hi **@RetusRieben** ,
- Make sure you have installed the appropriate NVIDIA drivers for your GPU. TensorFlow requires compatible NVIDIA drivers to communicate with the GPU.
- Ensure that the user running TensorFlow has the necessary permissions to access the GPU. Sometimes, permissions issues can prevent GPU detection.
- Sometimes, TensorFlow may be built without GPU support. You can check this by running.
```
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
```

Thank you! 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 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? Same issue here.  
I have `Nvidia RTX 4060` Laptop, and command from above show nothing about GPU. 

```powershell
# python -c "import tensorflow as tf; print(tf.config.list_physical_devices())"
[PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')]
```
 I experience same issue with TF 2.16.1, to be honest only workable fix for me was to rollback to 2.15.1  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!_ > 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.  @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 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. 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:
> ***@***.***>
>
 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!
 @MohanKrishnaGR 
What OS did you install this on? (Via WSL or native conda on Win?) 

That is the annoying fact. 

1. You can install with Conda which is totally Python made. So Conda installs some (unknown, but working) CUDA packages.
2. Python 11, is can't be *that* different from 12, so what changed and how to fix?

If possible, can you please help by:

* Can you check to see if you can find the python packages installed by Conda? 
* What is the exact output of your `pip install tensorflow[and-cuda]==2.15.1`?  
  A log would be great! Can you paste it here within tripple back quotes (```)?
* Can you search you python installation directory for `*.whl`? 
* Try to install using:   
  `python -m pip install --only-binary :all: tensorflow[and-cuda]==2.15.1`  
  And take note of download URLs and output.


References:
https://packaging.python.org/en/latest/discussions/package-formats/
https://realpython.com/python-wheels/
https://opensource.com/article/23/1/packaging-python-modules-wheels
 My Gpu is detected but I get a long cryptic warning when I use the relevant
command for detecting gpu in 2.15.1. When I tried to do conda update my
tensorflow version changed to cpu one ??

On Wed, 22 May 2024 at 10:24 PM, eabase ***@***.***> wrote:

> @MohanKrishnaGR <https://github.com/MohanKrishnaGR>
> What OS did you install this on? (Via WSL or native conda on Win?)
>
> That is the annoying fact.
>
>    1. You can install with Conda which is totally Python made. So Conda
>    installs some (unknow, but working) CUDA packages.
>    2. Python 11, is can't be *that* different from 12, so what changed
>    and how to fix?
>
> —
> Reply to this email directly, view it on GitHub
> <https://github.com/tensorflow/tensorflow/issues/64881#issuecomment-2125375814>,
> or unsubscribe
> <https://github.com/notifications/unsubscribe-auth/AIVENFAOSJ3NO7PDXJLZFMDZDTIDPAVCNFSM6AAAAABFSYT73OVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMRVGM3TKOBRGQ>
> .
> You are receiving this because you commented.Message ID:
> ***@***.***>
>
 @mhlhr There's no point of telling us it is cryptic, unless you also provide the message... :wink: @learning-to-play  This duplicates https://github.com/tensorflow/tensorflow/issues/63362 (edit: changed to right issue) Are you satisfied with the resolution of your issue?
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=Yes&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/64881">Yes</a>
<a href="https://docs.google.com/forms/d/e/1FAIpQLSfaP12TRhd9xSxjXZjcZFNXPGk4kc1-qMdv3gc6bEP90vY1ew/viewform?entry.85265664=No&entry.2137816233=https://github.com/tensorflow/tensorflow/issues/64881">No</a>

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

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


### Relevant log output

```shell
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
```
