Frama-99 / Whisking-Analysis

Analysis of landmark points generated by DeepLabCut for rodent whisking
MIT License
1 stars 0 forks source link

Docker/Packaging support #7

Open Frama-99 opened 4 years ago

Frama-99 commented 4 years ago

Package all dependencies with docker

Frama-99 commented 4 years ago

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:

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 commented 4 years ago

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:

Frama-99 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

Frama-99 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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.