Skip to content

Commit

Permalink
Enhance error message when ImportError encountered (#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
baijumeswani committed Jun 12, 2024
1 parent eb5262a commit 39daaea
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions src/python/__init__.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,18 @@

from onnxruntime_genai import _dll_directory

__version__ = "@VERSION_INFO@"
__id__ = "@TARGET_NAME@"

try:
# Try importing onnxruntime_genai. If an ImportError is raised,
# it could be because the cuda dlls could not be found on windows.
# Try adding the cuda dlls path to the dll search directory
# and import onnxruntime_genai again.
from onnxruntime_genai.@PACKAGE_DIR_NAME@ import *
except ImportError:
_dll_directory.add_dll_directory()
from onnxruntime_genai.@PACKAGE_DIR_NAME@ import *

__version__ = "@VERSION_INFO@"
except ImportError as e:
if __id__ == "onnxruntime-genai-cuda":
# Try importing onnxruntime_genai. If an ImportError is raised,
# it could be because the cuda dlls could not be found on windows.
# Try adding the cuda dlls path to the dll search directory
# and import onnxruntime_genai again.
_dll_directory.add_dll_directory()
from onnxruntime_genai.@PACKAGE_DIR_NAME@ import *
else:
raise e

0 comments on commit 39daaea

Please sign in to comment.