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