2

I've created a conda environment and installed tensorflow as such:

conda create -n foo python=3.10 conda activate foo conda install mamba mamba install tensorflow -c conda-forge mamba install cudnn cudatoolkit 

This installed TensorFlow 2.10.0. I've installed CUDA 11.2 and cuDNN 8.1, and then try to run the following:

import tensorflow as tf print(f"GPUs available: {tf.config.list_physical_devices('GPU')}") 

but it just returns an empty list. I have a 3060ti that I want to use for my ML projects but TensorFlow is not detecting it. I found similar questions to mine, like this, this and this but they use the old version of TensorFlow, which would install tensorflow-gpu and is no longer supported. How can I fix this, or even attempt to troubleshoot it.

I'm using a Windows 10 machine

Output of nvidia-smi:

+-----------------------------------------------------------------------------+ | NVIDIA-SMI 528.24 Driver Version: 528.24 CUDA Version: 12.0 | |-------------------------------+----------------------+----------------------+ | GPU Name TCC/WDDM | Bus-Id Disp.A | Volatile Uncorr. ECC | | Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. | | | | MIG M. | |===============================+======================+======================| | 0 NVIDIA GeForce ... WDDM | 00000000:09:00.0 On | N/A | | 30% 43C P8 16W / 200W | 809MiB / 8192MiB | 3% Default | | | | N/A | +-------------------------------+----------------------+----------------------+ +-----------------------------------------------------------------------------+ | Processes: | | GPU GI CI PID Type Process name GPU Memory | | ID ID Usage | |=============================================================================| | 0 N/A N/A 7176 C+G ...perience\NVIDIA Share.exe N/A | | 0 N/A N/A 9240 C+G C:\Windows\explorer.exe N/A | | 0 N/A N/A 12936 C+G ...cw5n1h2txyewy\LockApp.exe N/A | | 0 N/A N/A 13652 C+G ...e\PhoneExperienceHost.exe N/A | | 0 N/A N/A 14020 C+G ...2txyewy\TextInputHost.exe N/A | | 0 N/A N/A 14888 C+G ...ser\Application\brave.exe N/A | | 0 N/A N/A 15112 C+G ...5n1h2txyewy\SearchApp.exe N/A | | 0 N/A N/A 16516 C+G ...oft OneDrive\OneDrive.exe N/A | | 0 N/A N/A 18296 C+G ...aming\Spotify\Spotify.exe N/A | | 0 N/A N/A 18624 C+G ...in7x64\steamwebhelper.exe N/A | | 0 N/A N/A 18672 C+G ...\app-1.0.9010\Discord.exe N/A | | 0 N/A N/A 18828 C+G ...lPanel\SystemSettings.exe N/A | | 0 N/A N/A 19284 C+G ...Central\Razer Central.exe N/A | | 0 N/A N/A 20020 C+G ...arp.BrowserSubprocess.exe N/A | | 0 N/A N/A 22912 C+G ...8wekyb3d8bbwe\Cortana.exe N/A | | 0 N/A N/A 24848 C+G ...ontend\Docker Desktop.exe N/A | | 0 N/A N/A 25804 C+G ...y\ShellExperienceHost.exe N/A | | 0 N/A N/A 27064 C+G ...8bbwe\WindowsTerminal.exe N/A | +-----------------------------------------------------------------------------+ 

Output of nvcc -V:

Copyright (c) 2005-2021 NVIDIA Corporation Built on Sun_Feb_14_22:08:44_Pacific_Standard_Time_2021 Cuda compilation tools, release 11.2, V11.2.152 Build cuda_11.2.r11.2/compiler.29618528_0 

I ran a dummy code as such:

import tensorflow as tf import numpy as np def make_nn(): model = tf.keras.models.Sequential() model.add(tf.keras.layers.Dense(1, input_shape=(1,))) model.compile(loss='mean_squared_error', optimizer='sgd') return model def dataset(): x = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9]) y = np.array([1, 2, 3, 4, 5, 6, 7, 8, 9]) return tf.data.Dataset.from_tensor_slices((x, y)).batch(1) def main(): model = make_nn() model.fit(dataset(), epochs=1, steps_per_epoch=9) if __name__ == '__main__': print(f"GPUs available: {tf.config.list_physical_devices('GPU')}") print(f"Built with cuda: {tf.test.is_built_with_cuda()}") main() 

and it gave me the following log:

GPUs available: [] Built with cuda: False 2023-02-06 09:47:32.744450: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2023-02-06 09:47:32.779280: I tensorflow/core/common_runtime/process_util.cc:146] Creating new thread pool with default inter op setting: 2. Tune using inter_op_parallelism_threads for best performance. 

Looks like it's using a CPU build

16
  • At first I'd check if GPU driver is installed and up to date. Commented Feb 6, 2023 at 9:28
  • Did you create an account to NVidia then download and install cuDNN? Commented Feb 6, 2023 at 9:30
  • @Gameplay Just updated, wasn't it :( Commented Feb 6, 2023 at 9:33
  • @Corralien yes, I did Commented Feb 6, 2023 at 9:34
  • 1
    OK, so you are using a non-GPU enabled version of Tensorflow. Probably not the one installed by conda. Commented Feb 6, 2023 at 12:45

3 Answers 3

1

I had to download the right version of cudnn from the NVIDIA website. I didn't know before that I needed to install cudnn both on Win11 and conda's virtual environment

Sign up to request clarification or add additional context in comments.

Comments

0

Probably not the best solution, but I downgraded TensorFlow back to version 2.6.0 which was previously installed and it worked, which is a bummer, I wanted to try some more recent features, but for the time being looks like this will suffice. If anyone is facing the same issues, this is the current conda environment that I'm using

Comments

-1

If you use conda-forge you may need to set the environment variable CONDA_OVERRIDE_CUDA to force installing the gpu enabled version of tensorflow as explained here https://conda-forge.org/docs/user/tipsandtricks.html#installing-cuda-enabled-packages-like-tensorflow-and-pytorch. Under bash that would be something like

CONDA_OVERRIDE_CUDA="11.2" conda install "tensorflow==2.8" -c conda-forge 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.