Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docker/Packaging support #7

Open
Frama-99 opened this issue May 12, 2020 · 9 comments
Open

Docker/Packaging support #7

Frama-99 opened this issue May 12, 2020 · 9 comments

Comments

@Frama-99
Copy link
Owner

Package all dependencies with docker

@Frama-99
Copy link
Owner Author

Frama-99 commented Jun 6, 2020

Update on May 28:

Unfortunately, Docker containers that can leverage the GPU can only be run on Linux systems. In order to run docker containers that utilize Nvidia GPUs, a special utility, nvidia-docker, is required, which is only available on Linux. To explain in more detail, these are the steps needed to successfully run a docker container:

  • Build a docker image from a file called a Dockerfile. DLC provides us with such a docker file. This file is like a "spec" that contains all the dependencies needed to run a certain application. These dependencies can include ones that are system level, which saves us the hassle of installing things like CUDA, which is something that anaconda can't do. We can build this image on any host OS, as long as we have the Dockerfile and a docker daemon, which is available on Windows, MacOS, and Linux. The docker image contains a functional OS (usually Linux) that will run on top of the host system (e.g. a Windows docker daemon can run an instance that contains a Linux system).
  • Spin up a container (an instance of the image) from the image that we just built. In the case of using GPU with DLC, this is the step that can only be done on a Linux host. Even though the Windows docker daemon is able to spin up the Linux system in the DLC container, it cannot leverage the GPU since it lacks the nvidia-docker utility, which needs to run on top of the docker daemon and is only available on Linux. I tried to save the image built on my Linux system and transfer it to my Windows system, but that didn't run, which makes sense.
  • Interact with the container using a shell (e.g. bash). I successfully did this on my Linux machine and successfully detected the GPU on my system. This shows that the docker approach can be done, but only if the user to which we're distributing the image has a Linux system as the host.

Currently it does not look like it would be easier to distribute a docker image since I imagine that most of our target audience would have a Windows machine. A DLC docker image that is CPU only would work, but realistically I think using a conda environment to set up volunteers' computers would be easier. Since a docker image contains an entire functional OS, it can get very large (~15 GB for an image with CUDA as well as GUI libraries, likely 10 GB without CUDA). We would also need to deal with the transfer of files from a container to the host system, as well as paths in config files becoming incompatible. I think at that point it would be easier to install anaconda, install the environment with the provided .yaml file, and run python -m deeplabcut to launch the GUI for marking.

@Frama-99
Copy link
Owner Author

Frama-99 commented Jun 6, 2020

Update June 4:

Successfully used pyinstaller and Advanced Installer to package DLC. You can find the CPU-only DLC installer at the link here. The GPU compatible installer can be found here. I tested the former on a VM with a clean installation of Windows 10 (to make sure that the installation isn't dependent on things already installed on my own machine) and did not notice any glaring issues. I haven't been able to test the latter since I don't have access to a clean installation of Windows that is equipped with a graphics card.

There are still a few kinks to be worked out, namely:

  • Since I have not yet requested a license, there is a popup that says something along the lines of "this installation is for evaluation purposes only". This does not impact the functionality of the install though. I will get on requesting a license tomorrow.
  • There is no icon (or might be a generic looking icon) for the DLC application. Planning on fixing this soon.

@Frama-99
Copy link
Owner Author

Frama-99 commented Jun 6, 2020

Since the executable takes a while to load, next to-do would be to add a splash screen or a simple message on the cmd prompt to tell the user that the application is loading. Probably need to do this through adding some code in the DLC launch script.

@Frama-99
Copy link
Owner Author

Frama-99 commented Jun 6, 2020

Right now, need to right-click do "run as administrator" in order for read/write permissions to work. This is likely fixable in Advanced Installers (i.e. to get an automatic prompt of admin privilege). Another idea would be to default the install directory to a user's AppData folder so that non-admins would be able to use it.

@Frama-99
Copy link
Owner Author

Frama-99 commented Jun 10, 2020

When Tensorpack is used as an augmentation method to generate the training dataset, the train network step runs into an error.

@Frama-99
Copy link
Owner Author

Frama-99 commented Jun 15, 2020

When Tensorpack is used as an augmentation method to generate the training dataset, the train network step runs into an error.

This has been solved by adding multiprocessing.freeze_support() to the file that launches DLC. For reference, see this: https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Multiprocessing

Additionally, several files need to be added to the install directory. They are the following

DLC/tensorpack
|----dataflow
     |----imgaug
          |----geometry.py
          |----imgproc.py
          |----misc.py
          |----noise.py
|----tfutils
     |----optimizer.py

One strange behavior is that after the training is started, the launch message of the .py file that calls the DLC GUI ("Loading DeepLabCut... This may take about 30 seconds.") is printed for 8 times. Initial speculation is that each one of these corresponds to a thread on the computer- perhaps this can be avoided by adding if __name__ == '__main__' in the launch script.

@Frama-99
Copy link
Owner Author

perhaps this can be avoided by adding if name == 'main' in the launch script.

This was more or less the right guess. It turns out that it was printing that message many times because the print statement that prints out the message is placed before multiprocessing.freeze_support(). After placing it after, the message is no longer displayed repeatedly.

@Frama-99 Frama-99 changed the title Docker support Docker/Packaging support Jun 15, 2020
@Frama-99
Copy link
Owner Author

Right now, need to right-click do "run as administrator" in order for read/write permissions to work. This is likely fixable in Advanced Installers (i.e. to get an automatic prompt of admin privilege). Another idea would be to default the install directory to a user's AppData folder so that non-admins would be able to use it.

This has been addressed by choosing the option in Advanced Installer that defaults the install location to AppData when someone without admin rights run the installer, while defaulting to Program Files when an admin runs it.

@Frama-99
Copy link
Owner Author

Since the executable takes a while to load, next to-do would be to add a splash screen or a simple message on the cmd prompt to tell the user that the application is loading. Probably need to do this through adding some code in the DLC launch script.

This has been successfully added.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant