MCPcopy
hub / github.com/feast-dev/feast / get_torch

Function get_torch

sdk/python/feast/torch_wrapper.py:22–39  ·  view source on GitHub ↗

Return the torch module if available, else raise a friendly error. This prevents crashing on import if CUDA libs are missing.

()

Source from the content-addressed store, hash-verified

20
21
22def get_torch():
23 """
24 Return the torch module if available, else raise a friendly error.
25
26 This prevents crashing on import if CUDA libs are missing.
27 """
28 if TORCH_AVAILABLE:
29 return _torch
30 else:
31 error_message = (
32 "Torch is not available or failed to import.\n"
33 "Original error:\n"
34 f"{_torch_import_error}\n\n"
35 "If you are on a CPU-only system, make sure you install the CPU-only torch wheel:\n"
36 " pip install torch torchvision -f https://download.pytorch.org/whl/cpu\n"
37 "Or check your CUDA installation if using GPU torch.\n"
38 )
39 raise ImportError(error_message) from _torch_import_error

Callers 7

to_tensorMethod · 0.90
__init__Method · 0.90
generate_answerMethod · 0.90
to_tensorMethod · 0.90
test_get_online_featuresFunction · 0.90

Calls

no outgoing calls