What is an easy way to debug on tensorflow with docker?

Viewed 232

My local machine is a Linux Mint Tricia including Docker and Visual Studio Code.

I start a docker container by this command.

$ docker run -it --name for_study -p 8888:8888 --mount type=bind,src=/home/evan/Projects,dst=/projects --gpus all tensorflow/tensorflow:1.14.0-gpu-py3

My purpose is to debug a code of '/home/evan/Projects' that work on tensorflow with docker.

My assumption is to attach debug to bash on this container ('for_study'), but I have no idea how to attach.

What I tried:
I use Visual Studio Code.
- using plugin: Docker 1.1.0
- using plugin: Remote-Containers 0.117.0

Which one to choose?
enter image description here

launch.json

{
    "version": "0.2.0",
    "configurations": [

        {
            "name": "Python: Attach using Process Id",
            "type": "python",
            "request": "attach",
            "processId": "${command:pickProcess}"
        }
    ]
}

Sorry, I'm docker beginner.
If PyCharm Pro is easier, I will buy it.

Thanks.

1 Answers

It was resolved.

In conclusion, I use PyCharm Pro.

  1. you have a Docker Image which you want to run/debug. If you custom container, you have to create image from the container using 'commit' docker command.
  2. Setting > Project:{Project Name} > Project Interpreter : Set your Docker image.
  3. Run > Edit Configrations > [+] Python > Script path : Set your .py file AND > Python interpreter : Set your Docker image.
  4. Run/Debug it.

You don't have to start docker container.

Related