Download the NVIDA GPU Cloud (NGC)
container.
Create /home/bob/foobar.py in Visual Studio
Code with the VS Code Docker
Extension
import ptvsd
import time
ptvsd.enable_attach(address = ('0.0.0.0', 5678))
ptvsd.wait_for_attach()
time.sleep(2)
print("all righty then")
Set a breakpoint on the last line.
Debug|Add Configuration
Docker: Attach to Node
In launch.json add to "configurations"
{
"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.
},
Open a Terminal window:
$ 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
Start the debugger with configuration "Python Attach (Remote Debug ptsvd default)". It stops at the breakpoint.