torch.cuda.is_available()返回false

—用实验室的服务器跑代码,突然有一天显示GPU不可用了,排查了一堆,师兄帮着修改了.bashrc文件,在他的电脑一切正常,但自己的vscode一直返回False

CMD终端返回为True,怀疑是vscode环境变量被污染了

CMD终端查看环境变量的结果:(xxx代指用户名)

(wavenet) xxx@h3c-R5500-G5:~$ echo $PATH
/media/h3c/users/xxx/.conda/envs/wavenet/bin:/media/h3c/users/shared_app/miniconda3/condabin:/media/h3c/users/shared_app/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

vscode终端查看环境变量的结果:(xxx代指用户名)

/media/h3c/users/xxx/.vscode-server/cli/servers/Stable-fee1edb8d6d72a0ddff41e5f71a671c23ed924b9/server/bin/remote-cli:/media/h3c/users/xxx/.conda/envs/wavenet/bin:/media/h3c/users/shared_app/miniconda3/condabin:/media/h3c/users/shared_app/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/media/h3c/users/xxx/.vscode-server/cli/servers/Stable-fee1edb8d6d72a0ddff41e5f71a671c23ed924b9/server/bin/remote-cli:/media/h3c/users/shared_app/miniconda3/bin:/media/h3c/users/shared_app/miniconda3/condabin:/media/h3c/users/shared_app/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

分行后的结果如下

/media/h3c/users/xxx/.vscode-server/cli/servers/Stable-fee1edb8d6d72a0ddff41e5f71a671c23ed924b9/server/bin/remote-cli:/media/h3c/users/fanqilin1/.conda/envs/wavenet/bin:
/media/h3c/users/shared_app/miniconda3/condabin:
/media/h3c/users/shared_app/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:
/media/h3c/users/xxx/.vscode-server/cli/servers/Stable-fee1edb8d6d72a0ddff41e5f71a671c23ed924b9/server/bin/remote-cli:
/media/h3c/users/shared_app/miniconda3/bin:
/media/h3c/users/shared_app/miniconda3/condabin:
/media/h3c/users/shared_app/miniconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
---

与CMD终端的环境变量相比频繁出现.vscode-server/cli/servers/…

一开始参考了这篇博客的处理方式https://juejin.cn/post/7356049143954997302

找到.vscode-server/extensions/ms-python.python-2024.12.3-linux-x64/python_files/deactivate/bash/envVars.txt里面的PATH并修改,但是重连服务器发现PATH又自动修改回来了


解决方案:

直接在CMD终端连接服务器输入以下命令删除.vscode-server文件夹

rm -rf ~/.vscode-server/

重新打开vscode连接服务器(会生成新的.vscode-server文件夹)
在这里插入图片描述可喜可贺~

Logo

欢迎来到由智源人工智能研究院发起的Triton中文社区,这里是一个汇聚了AI开发者、数据科学家、机器学习爱好者以及业界专家的活力平台。我们致力于成为业内领先的Triton技术交流与应用分享的殿堂,为推动人工智能技术的普及与深化应用贡献力量。

更多推荐