- 先增加调试启动脚本
{
"name": "Python: Remote Attach",
"type": "python",
"request": "attach",
"connect": {
"host": "localhost",
"port": 5678
},
"pathMappings": [
{
"localRoot": "${workspaceFolder}/docker/dior",
"remoteRoot": "/dior"
}
]
}
- Docker的启动命令加上
RUN pip3 install debugpy
CMD python3 -m debugpy --listen 0.0.0.0:5678 dior_server.py
- 启动容器shell参考,启动完后VSCode启动调试即可跟踪Docker内python的断点运行
docker rm dior --force
docker run --gpus all -t -d -v ${PWD}/checkpoints:/dior/checkpoints -v ${PWD}/dataroot:/dior/dataroot -v ${PWD}/tasks:/dior/tasks \\
-v ${PWD}/invoke.sh:/dior/invoke.sh -v ${PWD}/demo.py:/dior/demo.py \\
-v ${PWD}/DIOR.py:/dior/DIOR.py -v ${PWD}/dior_server.py:/dior/dior_server.py \\
-v /root/ai-try-on/docker/minio/data/dior/task:/dior/minio \\
-p 9093:9093 -p 5678:5678 --name="dior" dior