@KZ400 (Shoot You)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

AttributeErrorが治らない。

解決したいこと

attributeerrorが治りません。with構文で発生しています。
自分でも調べてみましたがエラーが起きる原因がわからないです。
環境はUbuntu18.4を使用しています。

発生している問題・エラー

pol.png

または、問題・エラーが起きている画像をここにドラッグアンドドロップ

該当するソースコード

# TensorRTにモデルを読み込む
    with get_engine(onnx_file_path, engine_file_path) as engine, engine.create_execution_context() as context:

        # TensorRT用にバッファメモリをあてる
        inputs, outputs, bindings, stream = common.allocate_buffers(engine)

自分で試したこと

with関数に()の記載がないのでエラーが出るなどの記事がありましたが、()はあるのでなぜエラーが出るのかわからないです。また、現在、Ubuntu18.4で実行しているのですが、別のUbuntuでは動作確認しています。バージョンも同じです。また、pytohn3のバージョンも同じです。

0 likes

1Answer

オブジェクトのクラスや__enter__属性を持っているか確認してみてはいかがでしょうか?

engine = get_engine(onnx_file_path, engine_file_path)
print(type(engine))
print(hasattr(engine, '__enter__'))
engine = engine.__enter__()
context = engine.create_execution_context()
print(type(context))
print(hasattr(context, '__enter__'))
context = context.__enter__()
context.__exit__()
entine.__exit__()
0Like

Your answer might help someone💌