连接远程服务器后VS Code无法调用本地NVIDIA GPU问题求助
问题描述
本地已配置TensorFlow + NVIDIA GPU,VS Code原本能正常使用本地GPU,但连接远程服务器并打开新窗口后,本地VS Code无法访问本地GPU(远程服务器GPU可正常访问),PyCharm仍能检测到本地GPU。
测试代码
import tensorflow as tf a = tf.constant(1.) b = tf.constant(2.) print(a + b) print(tf.__version__) print(tf.test.gpu_device_name()) print('GPU:', tf.config.list_physical_devices(device_type='GPU')) print('CPU:', tf.config.list_physical_devices(device_type='CPU')) print(tf.test.is_gpu_available())
PyCharm正常输出
tf.Tensor(3.0, shape=(), dtype=float32) 2.9.0 /device:GPU:0 GPU: [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')] CPU: [PhysicalDevice(name='/physical_device:CPU:0', device_type='CPU')] True
VS Code报错信息
Could not load dynamic library 'cusolver64_11.dll'; dlerror: cusolver64_11.dll not found 2023-11-01 23:38:43.654110: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1850] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use the GPU. Follow the guide at TensorFlow GPU Installation Guide for how to download and set up the required libraries for your platform.
确认本地存在cusolver64_11.dll文件
解决方法
- 检查VS Code的Python解释器:连接远程后VS Code可能自动切换到远程环境,点击左下角解释器选择器,确认选中本地安装TensorFlow GPU的Python环境。
- 重置VS Code窗口与远程连接:关闭远程窗口回到本地,按
Ctrl+Shift+P(Windows/Linux)或Cmd+Shift+P(Mac)执行"重新加载窗口",再运行测试代码。 - 验证环境变量:确保
cusolver64_11.dll所在的CUDAbin路径已添加到系统PATH,关闭VS Code后重启生效。 - 清理远程扩展缓存:关闭VS Code,删除
%USERPROFILE%\.vscode\extensions下远程相关缓存文件夹,重新启动。 - 核对版本兼容性:TensorFlow 2.9.0对应CUDA 11.2、cuDNN 8.1.0,确认本地CUDA版本匹配,若不匹配则更换对应版本并配置环境变量。
内容的提问来源于stack exchange,提问作者Houxiong Yao
相关产品推荐
相关产品推荐

