gemini-code-assist[bot] commented on code in PR #18697: URL: https://github.com/apache/tvm/pull/18697#discussion_r2741960942
########## docs/how_to/tutorials/customize_opt.py: ########## @@ -1,4 +1,4 @@ -# Licensed to the Apache Software Foundation (ASF) under one +# Licensed to the Apache Software Foundation (ASF) under one Review Comment:  The file starts with a UTF-8 Byte Order Mark (BOM), which can cause issues with script execution in some environments. It should be removed. ```suggestion # Licensed to the Apache Software Foundation (ASF) under one ``` ########## docs/how_to/tutorials/customize_opt.py: ########## @@ -103,9 +109,17 @@ def forward(self, x): # Import cublas pattern -import tvm.relax.backend.cuda.cublas as _cublas - - +try: + import tvm.relax.backend.cuda.cublas as _cublas +except ImportError as e: + if "tvm_ffi" in str(e): + import sys + print("Error: TVM needs to be built with CUDA support.", file=sys.stderr) + print("Please build TVM from source with CUDA enabled.", file=sys.stderr) + print("See: https://tvm.apache.org/docs/install/from_source.html", file=sys.stderr) + sys.exit(1) + else: + raise Review Comment:  Checking the exception string for `"tvm_ffi"` is a bit brittle, as the error message could change in future TVM versions. A more robust approach is to use `tvm.runtime.enabled("cuda")` to check if CUDA support is compiled in. This directly checks for the feature availability rather than relying on a specific error message string. ```suggestion try: import tvm.relax.backend.cuda.cublas as _cublas except ImportError: import tvm.runtime if not tvm.runtime.enabled("cuda"): import sys print("Error: This tutorial requires TVM to be built with CUDA support.", file=sys.stderr) print("Please build TVM from source with CUDA enabled.", file=sys.stderr) print("See: https://tvm.apache.org/docs/install/from_source.html", file=sys.stderr) sys.exit(1) else: raise ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
