Skip to content

[BUG][CUDAProvider] No attribute with name:'activation'is defined #23119

@Cookiee235

Description

@Cookiee235

Describe the issue

Bug Report

Loading and optimizing the model with CUDA crashed! In comparison, it can run well when executing optimization on the CPU.

The crash stack trace:

Traceback (most recent call last):
  File "test", line 7, in <module>
    optimized_model = optimizer.optimize_model(model_path, opt_level=1, use_gpu=True)  
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/software/onnxruntime/build/Linux/Release/onnxruntime/transformers/optimizer.py", line 381, in optimize_model
    temp_model_path = optimize_by_onnxruntime(
                      ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/software/onnxruntime/build/Linux/Release/onnxruntime/transformers/optimizer.py", line 206, in optimize_by_onnxruntime
    onnxruntime.InferenceSession(onnx_model, sess_options, providers=providers, **kwargs)
  File "/software/onnxruntime/build/Linux/Release/onnxruntime/capi/onnxruntime_inference_collection.py", line 465, in __init__
    self._create_inference_session(providers, provider_options, disabled_optimizers)
  File "/software/onnxruntime/build/Linux/Release/onnxruntime/capi/onnxruntime_inference_collection.py", line 537, in _create_inference_session
    sess.initialize_session(providers, provider_options, disabled_optimizers)
onnxruntime.capi.onnxruntime_pybind11_state.RuntimeException: [ONNXRuntimeError] : 6 : RUNTIME_EXCEPTION : Exception during initialization: /software/onnxruntime/onnxruntime/contrib_ops/cuda/fused_conv.cc:67 onnxruntime::contrib::cuda::FusedConv<T>::FusedConv(const onnxruntime::OpKernelInfo&) [with T = float] [ONNXRuntimeError] : 1 : FAIL : No attribute with name:'activation'is defined.

To reproduce

  1. Download model here
  2. Run the test script:
from onnxruntime.transformers import optimizer

model_path = "model_with_activation.onnx"
optimized_model_path = f"./opt.onnx"
optimized_model = optimizer.optimize_model(model_path, opt_level=1, use_gpu=True) 

Notice:

  1. use_gpu=True & opt_level >=1 --> crash
  2. use_gpu=False --> run well
  3. opt_level = 0 --> run well

Urgency

No response

Platform

Linux

OS Version

Ubuntu 12.04

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

5c1b7cc

ONNX Runtime API

Python

Architecture

X64

Execution Provider

CUDA

Execution Provider Library Version

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    model:transformerissues related to a transformer model: BERT, GPT2, Hugging Face, Longformer, T5, etc.staleissues that have not been addressed in a while; categorized by a bot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions