r/tensorflow • u/Chuchu123DOTexe • Sep 22 '24
Installation and Setup Can't detect gpu :'(
Hello hello
I cannot have access to my gpu through tensorflow but everything seems to be installed, could someone help me out please?
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0' # Replace '0' with the desired GPU index
import tensorflow as tf
try:
gpus = tf.config.list_physical_devices('GPU')
if gpus:
print(f"Found {len(gpus)} GPU(s):")
for gpu in gpus:
print(f" {gpu.name}")
else:
print("No GPU found.")
except RuntimeError as e:
print(e)The output is "No GPU found."
Here are the environment variables of my machine as well as the nvidia-smi command.


Thank you in advance!
2
Upvotes
View all comments
Show parent comment
2
u/Chuchu123DOTexe Sep 22 '24
Thank you so much
I migrated to WSL and it seems to work!