Binder Error on YOLOv5

I can not use Binder for our YOLOv5 repository:

Describe the bug
Dockerfile is built, and then:
Launching server... Internal Server Error

To Reproduce
Go to this link and wait for notebook to build:

Screenshots

Desktop (please complete the following information):
MacOS
Chrome

Additional context
Originally raised a bug report jupyter nviewer and was directed to raise an issue on this forum regarding this.

Since you are using a custom Dockerfile, I recommend looking at the following repo to see how to construct a Dockerfile compatible with Binder https://github.com/binder-examples/minimal-dockerfile

3 Likes

And if you want to keep your current Dockerfile in the root directory, make a directory called binder there and put the Dockerfile that Binder will specifically use there in that binder directory.

However, your current Dockerfile looks very minimal, you could probably just use an environment.yml file in your binder directory and accomplish the same thing more easily and have something that will build faster & more easily on MyBinder, see here. If you go that way, move your stuff from requirements.txt under pip in the new environment.yml. The use of Dockerfile is best reserved for the more trickier builds, see here. Granted, I only glanced cursorily at your repo and I may have missed some complexity that rules this out.

2 Likes

Thanks for the tips guys. I will refer to these in the future should we pursue Binder integration!

@fomightez @sgibson91 I’m circling around again as it’s been a year since this original issue. I was hoping things might have smoothed over in the intervening time, but still seeing errors, though they are more descriptive now:

Do you think that creating an environment.yml will solve this?

It looks like the Dockerfile in your repository doesn’t fulfil the requirements to run on mybinder.org, which is why it still doesn’t work. Try following @formightez’s advice of creating a binder/environment.yml.

1 Like

Yes, nothing fundamental has changed about MyBinder.org. Because the focus of one of the underlying tools, repo2docker, is to not require understanding Docker, Dockerfiles are to be avoided at all costs. Hence, my push towards using environment.yml which will weather updates to the all the tech behind MyBinder/Jupyter better than a Dockerfile. However, you’ve left your Dockerfile ‘as-is’ essentially and not followed what @sgibson91 and I advised about fixing your Dockerfile if you want to stick with the Dockerfile. I did follow the advice and build & launches using this Dockerfile placed in binder directory work fine. (The tutorial notebook doesn’t quite run, but at least a launch is working.) You can check out an active sessions from this launch URL:

https://mybinder.org/v2/gh/fomightez/yolov5/d020ad0a898f48c734781f4da660105ab5144003

I created that Dockerfile by just appending the main content of the minimal example indicated by @sgibson91 to the end of yours.


For the tutorial notebook to work:

Use this launch URL to use the tutorial notebook:

https://mybinder.org/v2/gh/fomightez/yolov5/HEAD?filepath=tutorial.ipynb

For that launch URL to work, I needed to alter the Dockerfile further so that the build copies the notebook to the working directory that is present on launches from MyBInder, instead of just the place you have the Dockerfile installing the repo contents. Additionally, I changed the Dockerfile to using apt-get to avoid a message about apt not having a CLI interface.

(I realized the use of the dockerfile obviates the use of a start file, which was my original avenue of adding the tutorial notebook and a big reason why I had several commits before realizing only those changes I just detailed above were needed.)

Note the first two cells of the tutorial notebook work now. The third cell has an issue with torch.hub.download_url_to_file() and says:

ImportError: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html

I think that cell could easily be replaced with the following:

# Download COCO val
!curl -L https://ultralytics.com/assets/coco2017val.zip -o tmp.zip
!unzip -q tmp.zip -d ../datasets && rm tmp.zip

So you’d need a slightly different version of the notebook to get placed in the sessions launched via MyBinder.org. I’d put one in the binder directory and then copy that one instead. However, you may wish to not have two notebooks to deal with and want to fix that cell using sed in the Dockerfile in the binder directory & so I’ll leave that to you to decide how you want to approach that. Especially since the cell following that, !python val.py ... to run YOLOv5x on COCO val, also fails due to shared memory resources, it seems. In other words, you may need to offer a simpler demonstration inside sessions launched via MyBinder.org so that it works with the more limited resources.

1 Like