navidia-smi显示有gpu
Lenovo:~$ nvidia-smi
Fri Apr 1 17:17:59 2022
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.47.03 Driver Version: 510.47.03 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... On | 00000000:01:00.0 Off | N/A |
| N/A 32C P8 N/A / N/A | 45MiB / 2048MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1710 G /usr/lib/xorg/Xorg 4MiB |
| 0 N/A N/A 9350 C python3 39MiB |
+-----------------------------------------------------------------------------+
但是在tensorflow-gpu中,显示找不到GPU,返回一个空集。并且测试其是否在GPU上运行,显示False
physical_devices=tf.config.experimental.list_physical_devices("GPU")
print(physical_devices)
[ ]
写命令nvcc- V,也显示正确
nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_Mar__8_18:18:20_PST_2022
Cuda compilation tools, release 11.6, V11.6.124
Build cuda_11.6.r11.6/compiler.31057947_0