下载NVIDA GPU Cloud (NGC) 容器。
使用VS Code Docker 扩展在Visual Studio Code中创建/home/bob/foobar.py
import ptvsd
import time
ptvsd.enable_attach(address = ('0.0.0.0', 5678))
ptvsd.wait_for_attach()
time.sleep(2)
print("all righty then")
在最后一行设置断点。
调试|添加配置
Docker:附加到节点
在launch.json添加到“配置”
{
"name": "Python Attach (Remote Debug ptsvd default)",
"type": "python",
"request": "attach",
"pathMappings": [
{
"localRoot": "/home/bob", // You may also manually specify the directory containing your source code.
"remoteRoot": "/home/bob" // Linux example; adjust as necessary for your OS and situation.
}
],
"port": 5678, // Set to the remote port.
"host": "0.0.0.0" // Set to your remote host's public IP address.
},
打开终端窗口:
$ docker load -i foo.tar
$ docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
nvidia/cuda 9.0-base 9dcd7cd95db6 2 weeks ago 135MB
nvcr.io/nvidia/cuda latest 506c995952d1 7 weeks ago 2.74GB
$ docker run -p 5678:5678 latest
root@deadbeef: python -m pip install --user --upgrade ptvsd
root@deadbeef: python foobar.py
使用配置“Python Attach (Remote Debug ptsvd default)”启动调试器。它在断点处停止。