Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
arcanite24 opened this issue Aug 12, 2024 · 5 comments

Comments

@arcanite24
Copy link

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

@MartinTremblay
Copy link

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

@TemporalLabsLLC-SOL
Copy link

TemporalLabsLLC-SOL commented Aug 14, 2024

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
Copy link

Got

Which Python Version are you on?

@TemporalLabsLLC-SOL
Copy link

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?

@arcanite24
Copy link
Author

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

Closing now.

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

No branches or pull requests

3 participants