使用 VSCode 和 Remote-SSH 加载 Lmod 模块
我正在尝试在远程集群上开发Python代码。如果我直接在集群上执行此操作,则必须先加载 Anaconda Lmod 模块,然后才能访问任何 conda 环境:
module load Anaconda3/2020.11
为了提高生活质量,我想使用带有 Remote-SSH 扩展的 VSCode 来工作在集群上。但是,我似乎无法加载选择 conda 环境作为 Python 解释器所需的模块。当我运行 Python 脚本时,在 VSCode 终端中运行 module load XX
命令似乎没有应用这些设置。
有没有办法在连接到远程计算机后使用 VSCode 加载模块,以便我可以访问 conda 环境并运行我的代码?
I am trying to develop Python code on a remote cluster. If I were doing this directly on the cluster, I would have to load an Anaconda Lmod module before I could access any of my conda environments:
module load Anaconda3/2020.11
As a quality of life improvement, I would like to use VSCode with the Remote-SSH extension to work on the cluster. However, I cannot seem to load the module that I need in order to select my conda environment as the Python interpreter. Running the module load XX
command in the VSCode terminal does not seem to apply the settings when I run a Python script.
Is there a way for me to load the module using VSCode after I connect to the remote machine so that I can access my conda environment and run my code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我遇到了同样的问题,并通过在 vscode 服务器启动时加载 lmod 模块来解决它。
这个问题中经过验证的答案给我带来了走向解决方案。
您只需将
module load Anaconda3/2020.11
命令放入主目录的.profile
文件中即可。如果集群上不存在,您可以创建一个。I had the same problem and solved it by loading the lmod modules when the vscode server starts.
The verified answer in this issue brought me towards the solution.
You can just put the
module load Anaconda3/2020.11
command in your.profile
file in your home directory. If none exists on the cluster you can just create one.至少对于 Jupyter Notebooks 现在有一个解决方案:
在远程会话中打开一个终端,
然后复制 url,单击“选择内核”>“现有的jupyter服务器>输入 url,选择内核并开始。
请注意,在此设置中 pylance 仍然无法工作。
更多信息请参阅文档。
At least for Jupyter Notebooks there is a solution now:
Open a terminal within your remote session, do
then copy the url, click select kernel > existing jupyter server > enter url, select the kernel and go.
Note that pylance still does not work in this setup.
More infos in the docs.