Skip to content

Conversation

@StevePotter
Copy link
Contributor

I needed to deploy FoundationStereo as a docker container and found problems with the current dockerfile:

  • It does not include FoundationStereo code
  • It doesn't include the same packages as the conda environment.yml
  • It uses the cuda dev build, which makes the image unnecessarily large
  • It doesn't include the model weights

This PR updates the dockerfile to address those problems.

  1. FoundationStereo code is now available at /FoundationStereo
  2. The same packages from environment.yml are now included. Note that I had to make a copy of environment.yml because the conda create didn't work with it. If PR Fix conda installation error #110 is merged, it can use the environment.yml from the root
  3. I used a multi-stage build to reduce the size of the image. The image was around 25gb, and is now 13gb (17 if you download the weights). The first stage builds the conda environment and the second stage copies only the necessary files to run FoundationStereo. Pretty standard docker build stuff.
  4. The model weights are included in the docker image. This is done via the PRETRAINED_WEIGHTS docker build arg. This allows you to use the large, small, or onnx model weights. It defaults to the large weights. If you make the build arg empty, it will not include any weights. But it defaults to large, which seems reasonable because adds the weights is likely the first thing a user will want to do. I also downloaded dino and other dependency weights. This could have been done by running run_demo.py, but that would require that the docker build machine have a GPU, and would require disabling docker buildkit. So I wrote a script, download_weights.py, that doesn't require a CPU. Now someone can build the docker image and run this model without any internet connection.

Please note that I made a copy of the model weights to my huggingface account. I didn't want to do this, but the current weights are on Google Drive and using gdown can result in throttling and thus build failures. After that kept happening to me, I decided to use huggingface. I recommend putting the weights onto HF with an nvidia account.

I think it would be great if you published this image. You could publish versions with various model weights. This can be done with github actions and I'd be happy to help with that as I have experience with that. Then someone could simply pull the image down and start using it.

Regarding run_container.sh, Bowen this is clearly for your dev purposes, as your name is in it lol. If you want to run this container for development, you can use docker compose or modify that script to be a little more generic. I can help with that too.

Thanks, great work on this model. I hope this PR helps address the deployment side a bit for those looking to test it out

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

Successfully merging this pull request may close these issues.

1 participant