replicate / cog

Containers for machine learning
https://cog.run
Apache License 2.0
7.83k stars 545 forks source link

Windows support #352

Open andreasjansson opened 2 years ago

andreasjansson commented 2 years ago

Cog currently only works on Mac and Linux. We should support Windows as well.

User data

See also

(This is edited by @andreasjansson and @bfirsh. Consider it a wiki!

halr9000 commented 2 years ago

Would love to see cog work on Windows, either in wsl2 or otherwise. I've tried "all" of the ways to make AI art on Windows:

  1. Python/win32 w/native libraries and binaries w/Conda , not containerized, CLI only. Works great, plenty of support available from Nvidia, Pytorch. Miniconda was my preferred distro. Was able to run several of the non-pixray projects (e.g. dall-e, vqgan, bigsleep) out there with zero to few modifications, but some required some futzing with pip & conda deps. I gave up on a couple of projects for various reasons, usually as they were very unpythonic and the design choices led to a huge mess to try and make them run on Windows. Disco-diffusion was a fail so far, I want to keep trying at that one.
  2. Same as 1 but using VSCode & Jupyter for the notebook experience. This path was 100% new to me so I had a lot of catch up learning to do and did not get as far as I did with # 1, but had some successes.
  3. Same as 1 but with a nice web UI from this project https://github.com/tnwei/vqgan-clip-app/. Worked great until I hit VRAM limits, which for some reason were a bit lower at similar quality levels as compared to some others. I might come back to this one and put in some safeguards to keep it from crashing.
  4. Same as 1 w/o Conda. This was a pain, saw no point in continuing.
  5. Python/Linux in WSL2 w/Conda, not containerized. I got 1 or 2 projects working as-is, which was neat as I'd not done much with WSL before. But given that I had already made a lot of progress in 1, the added initial setup steps and slight awkwardness dealing with the filesystem wrapper or vscode integration -- while surprisingly solid given that we're talking about Linux on Windows -- I learned what I need to and moved on.

At some point during the above fun, I came across pixray and wanted to see what I could do, especially as you'd wrapped multiple generators in one project, and I was hoping the container-based approach meant quick and easy setup, that being the point. Then I saw cog was going to make it even easier!

Oh well, I did not get very far with projects 6 (pixray/cog) or 7 (pixray/docker). Gave up on these, but would love to come back to it!

If anyone is interested in my notes on the above, you can find them here:

https://halr9000.notion.site/Project-BYOGPU-Running-locally-on-Windows-441c7e1435cb44a39551367a1e5c0934

and here

https://halr9000.notion.site/WIP-How-to-Create-AI-Art-Locally-on-Windows-38fd2638d1db4502a10a365567607c6d

bfirsh commented 2 years ago

This is super helpful information, thanks @halr9000. Do you need to run this locally, or would it be helpful if there was some way of running Cog models in the cloud somewhere?

E.g. we could have a way to make it easy to run on a GPU machine on Google Cloud, or something. That way you wouldn't have to deal with all this, but it would mean you'd have to pay for GPU time on Google Cloud.

halr9000 commented 2 years ago

Local is my goal, yes. I know of ways to get it done in the cloud where I'd use linux anyway. I am somewhat close to getting pixray w/vqgan working non-containerized, but it's a hack of requirements.txt -> environment.yml for conda, and I'm still fiddling with it. Unable to get diffvg to install yet, I see that it'll just disable that drawer.

Here's what I have so far but I don't love it. Trying a few diff version combinations w/py 3.8, 3.9, pytorch, etc.

--- environment.yml ---

name: pixray
channels:
  - pytorch
  - conda-forge
  - fastai
  - defaults
dependencies:
  - python>=3.9
  - pip

  - pytorch
  - torchvision
  - torchtext
  - numpy
  - tqdm
  - matplotlib
  - braceexpand
  - einops
  - imageio
  - ipython
  - kornia
  - omegaconf
  - pillow
  - pyyaml
  - scikit-learn
  - scikit-image
  - torch-optimizer
  - PyWavelets
  - sentencepiece
  - svgpathtools
  - cssutils
  - cmake
  - lpips
  - sentence-transformers
  - py-opencv
  - timm

  - pip:
    - colorthief
    - torch-tools
    - git+https://github.com/bfirsh/taming-transformers.git@7a6e64ee
    - git+https://github.com/openai/CLIP@40f5484
    - git+https://github.com/pvigier/perlin-numpy@6f077f8
    # - git+https://github.com/pixray/diffvg
    - git+https://github.com/fbcotter/pytorch_wavelets
    - git+https://github.com/pixray/aphantasia@7e6b3bb
    - resmem
bfirsh commented 2 years ago

Some data from @nicholascelestin on how to run it in WSL: https://canary.discord.com/channels/775512803439280149/852636181492793344/989652053397733376

markliuyuxiang commented 2 years ago

WSL2 is awesome

bfirsh commented 2 years ago

Some work on this: https://github.com/replicate/cog/pull/681