在VSCode中未检测到用于tensorflow 的GPU

iqjalb3h  于 2023-01-31  发布在  Vscode
关注(0)|答案(1)|浏览(469)

我已经安装了tensorflow和https://www.tensorflow.org/install/pip中提到的Ubuntu 22.04 GPU支持所需的依赖项。
我测试了GPU被检测到,就像上面的教程中提到的那样,它检测到了我的Nvidia GTX 1060。但是如果我尝试在VSCode中的GPU上运行Tensorflow,GPU就没有被检测到。
我有一个python脚本test-tf.py,代码如下:

import tensorflow as tf
print(tf.config.list_physical_devices('GPU'))

当我运行这个程序时,我得到了以下结果:

[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

当我在VSCode中运行.ipynb文件中的相同代码时,我得到:

[]
2022-12-27 18:59:38.079947: I tensorflow/compiler/xla/stream_executor/cuda/cuda_gpu_executor.cc:981] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
2022-12-27 18:59:38.080624: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory
2022-12-27 18:59:38.080767: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcublas.so.11'; dlerror: libcublas.so.11: cannot open shared object file: No such file or directory
2022-12-27 18:59:38.080843: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcublasLt.so.11'; dlerror: libcublasLt.so.11: cannot open shared object file: No such file or directory
2022-12-27 18:59:38.080894: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcufft.so.10'; dlerror: libcufft.so.10: cannot open shared object file: No such file or directory
2022-12-27 18:59:38.080940: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcurand.so.10'; dlerror: libcurand.so.10: cannot open shared object file: No such file or directory
2022-12-27 18:59:38.080986: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcusolver.so.11'; dlerror: libcusolver.so.11: cannot open shared object file: No such file or directory
2022-12-27 18:59:38.081032: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcusparse.so.11'; dlerror: libcusparse.so.11: cannot open shared object file: No such file or directory
2022-12-27 18:59:38.081076: W tensorflow/compiler/xla/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudnn.so.8'; dlerror: libcudnn.so.8: cannot open shared object file: No such file or directory
2022-12-27 18:59:38.081087: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1934] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...

如果我使用Jupyter Notebook运行相同的.ipynb文件,GPU会像预期的那样被检测到。只有在使用VSCode的笔记本时才会检测到。我已经确保使用了正确的conda环境。

p8h8hvxi

p8h8hvxi1#

同样的问题发生在我身上,但做以下解决了我的问题
转到vscode中的终端选项卡-〉单击新终端
在左下角点击“+”符号附近的下拉按钮,点击“设置默认配置文件”并选择“命令提示符”。
现在运行代码。

相关问题