1. 选择虚拟环境
ctrl+shift+p-----> >Python: Select Interpreter
2. 设置Configuration
在Run--->Add Configuration 添加configuration,内容为:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "python:evaluate_ndf",
"type": "python",
"request": "launch",
"cwd":"/home/Documents/ndf_robot/src/ndf_robot/eval",
"program": "evaluate_ndf.py",
"console": "integratedTerminal",
"justMyCode": false,
"args": [
"--demo_exp", "grasp_rim_hang_handle_gaussian_precise_w_shelf",
"--object_class", "mug",
"--opt_iterations", "500",
"--only_test_ids",
"--rand_mesh_scale",
"--model_path", "multi_category_weights",
"--save_vis_per_model",
"--config", "eval_mug_gen",
"--exp", "test_mug_eval",
"--pybullet_viz"],
"env":{"CUDA_VISIBLE_DEVICES":"0,1,2,3"}
}
]
}
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: 当前文件",
"type": "python",
"request": "launch",
"program": "/home/dl/anaconda3/lib/python3.7/site-packages/torch/distributed/launch.py",//可执行文件路径
"console": "integratedTerminal",
"args": [
"--nproc_per_node=1",
"tools/train.py",
"--model",
"bisenetv1",
],
"env": {"CUDA_VISIBLE_DEVICES":"0"},
}
]
}
3. 若用ssh远程连接服务器,先进行如下步骤(或者只进行红色字体的部分也可以):
安装Remote-ssh插件
本地生成秘钥对并授权
打开PowerShell,输入以下命令生成秘钥:
ssh-keygen -t rsa -b 4096 -f C:\Users\xxxx\.ssh\id_rsa-remote-ssh
执行以下命令将公钥拷贝至远端服务器:
ssh-copy-id -i "C:/Users/xxxx/.ssh/id_rsa-remote-ssh.pub" -p 32768 root@172.10.0.3
如果在PowerShell中无法执行ssh-copy_id命令,可在git的bash中执行。
配置Remote-SSH插件
在visual studio code界面按下快捷键Ctrl + Shift + p,选择Remote-SSH:connect to host... >Configure SSH Hosts... > C:\User\xxx\.ssh\config进入配置文件中,在文件中添加以下配置信息:
Host subscribe-dev
HostName 10.168.11.11
User root
Port 32768
IdentityFile C:\DevEnv\conf\ssh\id_rsa-remote-ssh
Host:在vscode中显示的远程连接名称。
HostName:远端开发环境主机ip地址。
User:登入用户名。
Port:ssh服务端口号。
IdentityFile:本地秘钥文件路径。
配置完成后就可以在vscode的远程资源管理器中看到这台新添加的远程主机。