Error converting SDXL model to ONNX with optimum-cli


I followed the instructions from the link above to install optimum-cli and to convert the SDXL model to ONNX. But I got this error. Does anyone know what could be wrong? Thank you.

$ optimum-cli export onnx --model stabilityai/stable-diffusion-xl-base-1.0 --task stable-diffusion-xl sd_xl_onnx/
Framework not specified. Using pt to export the model.
Keyword arguments {'subfolder': '', 'trust_remote_code': False} are not expected by StableDiffusionXLImg2ImgPipeline and will be ignored.
Loading pipeline components...: 100%|███████████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:00<00:00,  9.37it/s]
Traceback (most recent call last):
  File "/opt/anaconda3/envs/onnx/bin/optimum-cli", line 8, in <module>
  File "/opt/anaconda3/envs/onnx/lib/python3.7/site-packages/optimum/commands/", line 163, in main
  File "/opt/anaconda3/envs/onnx/lib/python3.7/site-packages/optimum/commands/export/", line 285, in run
  File "/opt/anaconda3/envs/onnx/lib/python3.7/site-packages/optimum/exporters/onnx/", line 371, in main_export
  File "/opt/anaconda3/envs/onnx/lib/python3.7/site-packages/optimum/exporters/onnx/", line 1029, in onnx_export_from_model
    dtype = get_parameter_dtype(model) if framework == "pt" else model.dtype
  File "/opt/anaconda3/envs/onnx/lib/python3.7/site-packages/diffusers/", line 137, in __getattr__
    raise AttributeError(f"'{type(self).__name__}' object has no attribute '{name}'")
AttributeError: 'StableDiffusionXLImg2ImgPipeline' object has no attribute 'dtype'

This is the output from “optimum-cli env”:

- `optimum` version: 1.18.0
- `transformers` version: 4.30.2
- Platform: Darwin-23.4.0-x86_64-i386-64bit
- Python version: 3.7.6
- Huggingface_hub version: 0.16.4
- PyTorch version (GPU?): 1.13.1 (cuda availabe: False)
- Tensorflow version (GPU?): not installed (cuda availabe: NA)