Lightning-AI / pytorch-lightning

Pretrain, finetune ANY AI model of ANY size on multiple GPUs, TPUs with zero code changes.
https://lightning.ai
Apache License 2.0
28.33k stars 3.38k forks source link

Option to install only the `apps` part of the lightning framework #15245

Closed KogaiIrina closed 11 months ago

KogaiIrina commented 2 years ago

🚀 Feature

Option to install only the apps part of the lightning framework. Something along the lines of pip install lightning[apps].

Motivation

I have an unresolvable dependency conflict between the protobuf version required by tensorboard required by lightning and my other dependency.

Pitch

It would be great to have the option to install only the apps part when I don't need the other parts with their dependencies.

Alternatives

N/A


If you enjoy Lightning, check out our other projects! âš¡

cc @borda @Borda @carmocca @otaj @justusschock

awaelchli commented 2 years ago

@KogayIrina Thanks for checking out Lightning Apps!

Afaik we are actually working on this. You can already install only the apps part today, by installing the package lightning-app from PyPi.

I believe the the lightning[apps], lightning[pytorch] etc syntax does not work yet but we will be supported it in the future as this was the plan all along. Please correct me if I'm wrong @Borda @carmocca.

KogaiIrina commented 2 years ago

@awaelchli Hi. Thank you for the response. lightning-app looks what I want, but I installed lightning-app instead of lightning in a fresh conda environment and got this error:

$ lightning run app app.py 
Traceback (most recent call last):
  File "/home/irina/miniconda3/envs/masterpiece-creator/bin/lightning", line 5, in <module>
    from lightning_app.cli.lightning_cli import main
  File "/home/irina/miniconda3/envs/masterpiece-creator/lib/python3.8/site-packages/lightning_app/cli/lightning_cli.py", line 30, in <module>
    from lightning_app.utilities.app_logs import _app_logs_reader
  File "/home/irina/miniconda3/envs/masterpiece-creator/lib/python3.8/site-packages/lightning_app/utilities/app_logs.py", line 11, in <module>
    from lightning_app.utilities.logs_socket_api import _LightningLogsSocketAPI
  File "/home/irina/miniconda3/envs/masterpiece-creator/lib/python3.8/site-packages/lightning_app/utilities/logs_socket_api.py", line 8, in <module>
    from lightning.app.core import constants
ModuleNotFoundError: No module named 'lightning'
tchaton commented 2 years ago

Hey there,

Yes, you would need to use from lightning_app in your code instead of lightning.app.

Best T.C

KogaiIrina commented 2 years ago

Hi, @tchaton

File "/home/irina/miniconda3/envs/masterpiece-creator/lib/python3.8/site-packages/lightning_app/utilities/logs_socket_api.py", line 8, in from lightning.app.core import constants

It looks like the error comes not from my code but from the lightning internals.

rohitgr7 commented 2 years ago

hey @KogayIrina this was fixed herE: https://github.com/Lightning-AI/lightning/pull/15124 must be in the recent release. Mind try that out?

KogaiIrina commented 2 years ago

Hi, @rohitgr7 ^_^

I am using the latest lightning-app version available on pypi, 0.7.0.

$ lightning run app app.py
Traceback (most recent call last):
  File "/home/irina/miniconda3/envs/masterpiece-creator-test-app/bin/lightning", line 5, in <module>
    from lightning_app.cli.lightning_cli import main
  File "/home/irina/miniconda3/envs/masterpiece-creator-test-app/lib/python3.8/site-packages/lightning_app/cli/lightning_cli.py", line 30, in <module>
    from lightning_app.utilities.app_logs import _app_logs_reader
  File "/home/irina/miniconda3/envs/masterpiece-creator-test-app/lib/python3.8/site-packages/lightning_app/utilities/app_logs.py", line 11, in <module>
    from lightning_app.utilities.logs_socket_api import _LightningLogsSocketAPI
  File "/home/irina/miniconda3/envs/masterpiece-creator-test-app/lib/python3.8/site-packages/lightning_app/utilities/logs_socket_api.py", line 8, in <module>
    from lightning.app.core import constants
ModuleNotFoundError: No module named 'lightning'

$ pip list | grep lightning
lightning-app          0.7.0
lightning-cloud        0.5.7
lightning-utilities    0.3.0

Here is the lightning-app version of the code I am running: https://github.com/KogayIrina/masterpiece-creator/tree/test-lightning-app (I used a fresh conda environment for the test)

awaelchli commented 2 years ago

That is expected and we are aware of it. I believe the installation through lightning[app] would solve this problem so that one can have the imports in the standardized lightning way.

cc @Borda @carmocca @otaj @justusschock

KogaiIrina commented 2 years ago

Hi, @awaelchli So, the lightning-app package is unusable right now, right?

To me, from the stack trace, it looks like the error comes from the lightning_app module code (it contains the lightning import), not my code. My code contains correct lightning_app imports.

rohitgr7 commented 2 years ago

looks like that PR wasn't included in patch release. This will work once v1.8 is released in few days :)

KogaiIrina commented 2 years ago

@rohitgr7 thank you for the update :)

Borda commented 2 years ago

lets proceed it together with #15542