ai-toolkit icon indicating copy to clipboard operation
ai-toolkit copied to clipboard

Error for Flux Dev Lora => TypeError: unsupported operand type(s) for |: 'torch._C._TensorMeta' and 'NoneType'

Open arcanite24 opened this issue 1 year ago • 4 comments

I'm getting this error while trying to run a Flux Lora training task:

(venv) user@r-nerijs-jupyterlab-qxnn9y4h-dc689-8q6yc:~/app/data/flux/ai-toolkit$ python run.py config/test.yaml 
Running 1 job
Error running job: unsupported operand type(s) for |: 'torch._C._TensorMeta' and 'NoneType'

========================================
Result:
 - 0 completed jobs
 - 1 failure
========================================
Traceback (most recent call last):
  File "/data/flux/ai-toolkit/run.py", line 90, in <module>
    main()
  File "/data/flux/ai-toolkit/run.py", line 86, in main
    raise e
  File "/data/flux/ai-toolkit/run.py", line 77, in main
    job = get_job(config_file, args.name)
  File "/data/flux/ai-toolkit/toolkit/job.py", line 28, in get_job
    from jobs import ExtensionJob
  File "/data/flux/ai-toolkit/jobs/__init__.py", line 1, in <module>
    from .BaseJob import BaseJob
  File "/data/flux/ai-toolkit/jobs/BaseJob.py", line 5, in <module>
    from jobs.process import BaseProcess
  File "/data/flux/ai-toolkit/jobs/process/__init__.py", line 6, in <module>
    from .TrainVAEProcess import TrainVAEProcess
  File "/data/flux/ai-toolkit/jobs/process/TrainVAEProcess.py", line 19, in <module>
    from toolkit.data_loader import ImageDataset
  File "/data/flux/ai-toolkit/toolkit/data_loader.py", line 20, in <module>
    from toolkit.config_modules import DatasetConfig, preprocess_dataset_raw_config
  File "/data/flux/ai-toolkit/toolkit/config_modules.py", line 615, in <module>
    class GenerateImageConfig:
  File "/data/flux/ai-toolkit/toolkit/config_modules.py", line 637, in GenerateImageConfig
    latents: Union[torch.Tensor | None] = None,  # input latent to start with,
TypeError: unsupported operand type(s) for |: 'torch._C._TensorMeta' and 'NoneType'

Running on a fresh install, A100 and yaml based on the template in config/templates

arcanite24 avatar Aug 12 '24 21:08 arcanite24

Got the same error on a fresh install on 4090 on wsl2.

MartinTremblay avatar Aug 13 '24 16:08 MartinTremblay

Okay. I found a fix.

cd /ai-toolkit/toolkit sudo nano config_modules.py

SCROLL DOWN TO line 637, closer to the bottom. It's indented one and blends in. It's near the image parameter function

You are looking for THIS LINE - latents: Union[torch.Tensor | None] = None

Change the operator from | to , like BELOW

latents: Union[torch.Tensor, None] = None I am now training.

TemporalLabsLLC-SOL avatar Aug 14 '24 21:08 TemporalLabsLLC-SOL

Got

Which Python Version are you on?

TemporalLabsLLC-SOL avatar Aug 14 '24 21:08 TemporalLabsLLC-SOL

I'm getting this error while trying to run a Flux Lora training task:

(venv) user@r-nerijs-jupyterlab-qxnn9y4h-dc689-8q6yc:~/app/data/flux/ai-toolkit$ python run.py config/test.yaml 
Running 1 job
Error running job: unsupported operand type(s) for |: 'torch._C._TensorMeta' and 'NoneType'

========================================
Result:
 - 0 completed jobs
 - 1 failure
========================================
Traceback (most recent call last):
  File "/data/flux/ai-toolkit/run.py", line 90, in <module>
    main()
  File "/data/flux/ai-toolkit/run.py", line 86, in main
    raise e
  File "/data/flux/ai-toolkit/run.py", line 77, in main
    job = get_job(config_file, args.name)
  File "/data/flux/ai-toolkit/toolkit/job.py", line 28, in get_job
    from jobs import ExtensionJob
  File "/data/flux/ai-toolkit/jobs/__init__.py", line 1, in <module>
    from .BaseJob import BaseJob
  File "/data/flux/ai-toolkit/jobs/BaseJob.py", line 5, in <module>
    from jobs.process import BaseProcess
  File "/data/flux/ai-toolkit/jobs/process/__init__.py", line 6, in <module>
    from .TrainVAEProcess import TrainVAEProcess
  File "/data/flux/ai-toolkit/jobs/process/TrainVAEProcess.py", line 19, in <module>
    from toolkit.data_loader import ImageDataset
  File "/data/flux/ai-toolkit/toolkit/data_loader.py", line 20, in <module>
    from toolkit.config_modules import DatasetConfig, preprocess_dataset_raw_config
  File "/data/flux/ai-toolkit/toolkit/config_modules.py", line 615, in <module>
    class GenerateImageConfig:
  File "/data/flux/ai-toolkit/toolkit/config_modules.py", line 637, in GenerateImageConfig
    latents: Union[torch.Tensor | None] = None,  # input latent to start with,
TypeError: unsupported operand type(s) for |: 'torch._C._TensorMeta' and 'NoneType'

Running on a fresh install, A100 and yaml based on the template in config/templates

Which python version are you on?

TemporalLabsLLC-SOL avatar Aug 14 '24 21:08 TemporalLabsLLC-SOL

I was using Python 3.9, updated to 3.10 and it's running fine.

Closing now.

arcanite24 avatar Aug 17 '24 18:08 arcanite24