carefree0910 / carefree-creator

AI magics meet Infinite draw board.
https://creator.nolibox.com/guest
MIT License
2.13k stars 216 forks source link

About torch requirement #16

Open mart-hill opened 1 year ago

mart-hill commented 1 year ago

Hi! I'd like to ask - does "pip install -e ." install torch for cuda (or torch in general) as well? I'm getting this after trying to use "uvicorn apis.interface:app --host 0.0.0.0 --port 8123":

File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users[username]\AppData\Local\Programs\Python\Python310\Scripts\uvicorn.exe__main.py", line 7, in File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1130, in call return self.main(*args, kwargs) File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1055, in main rv = self.invoke(ctx) File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 1404, in invoke return ctx.invoke(self.callback, ctx.params) File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\site-packages\click\core.py", line 760, in invoke return callback(*args, **kwargs) File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\main.py", line 404, in main run( File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\main.py", line 569, in run server.run() File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\server.py", line 60, in run return asyncio.run(self.serve(sockets=sockets)) File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\asyncio\runners.py", line 44, in run return loop.run_until_complete(main) File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\asyncio\base_events.py", line 646, in run_until_complete return future.result() File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\server.py", line 67, in serve config.load() File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\config.py", line 474, in load self.loaded_app = import_from_string(self.app) File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\importer.py", line 24, in import_from_string raise exc from None File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\site-packages\uvicorn\importer.py", line 21, in import_from_string module = importlib.import_module(module_str) File "C:\Users[username]\AppData\Local\Programs\Python\Python310\lib\importlib__init__.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 1050, in _gcd_import File "", line 1027, in _find_and_load File "", line 1006, in _find_and_load_unlocked File "", line 688, in _load_unlocked File "", line 883, in exec_module File "", line 241, in _call_with_frames_removed File "O:\AI\carefree-creator\carefree-creator.\apis\interface.py", line 3, in import torch ModuleNotFoundError: No module named 'torch'

It's true, that in this directory I don't have torch for cuda, or any other torch, but I thought pip would install that. :)

Greetings!

carefree0910 commented 1 year ago

Hi!

The pytorch website gives a fairly detailed instruction on how to install pytorch. 😆

The reason why I did not include pytorch in the setup.py is that, often it will be better to choose your own pytorch version based on your hardware (e.g. cpu? cuda? m1 chip? ...). 😉

Feel free to leave comments if you encountered any problem!

mart-hill commented 1 year ago

Hi! The problem stems from the fact, that I usually have pytorch installed inside venv, so I don't have to worry about it system-wide.

Thanks! :) I'll try to install it system-wide, though it's python - anything can happen. :P By the way, should I run "uvicorn apis.interface:app --host 0.0.0.0 --port 8123" with admin rights? Cause no matter what I type in the web browser, I get only a message about some JSON file, not the actual interface. :)

carefree0910 commented 1 year ago

Hi! If you have pytorch installed inside venv, then it should be ok! Just need to ensure that you have installed carefree-creator under the same venv, and your uvicorn command is using the same venv. 😉

After you run uvicorn apis.interface:app --host 0.0.0.0 --port 8123, you still need to visit https://creator.nolibox.com/guest for the WebUI, because carefree-creator is just the backend server! 😆

And in the WebUI, you'll need to turn on this switch:

image

to use your own server!