perf: Move expensive imports closer to usage (#1863)

* Move expensive imports closer to usage

Signed-off-by: William Easton <bill.easton@elastic.co>

* DCO Remediation Commit for William Easton <bill.easton@elastic.co>

I, William Easton <bill.easton@elastic.co>, hereby add my Signed-off-by to this commit: 8a7412ce5bb131a01bb6403067aeb948c9093b0b

Signed-off-by: William Easton <bill.easton@elastic.co>

* formatting fixes

Signed-off-by: William Easton <bill.easton@elastic.co>

* DCO Remediation Commit for William Easton <bill.easton@elastic.co>

I, William Easton <bill.easton@elastic.co>, hereby add my Signed-off-by to this commit: 8a7412ce5bb131a01bb6403067aeb948c9093b0b
I, William Easton <bill.easton@elastic.co>, hereby add my Signed-off-by to this commit: 963e34325071db5e844841f10c27b396a054a0a1

Signed-off-by: William Easton <bill.easton@elastic.co>

* Fix baseocrmodel test issue

Signed-off-by: William Easton <bill.easton@elastic.co>

---------

Signed-off-by: William Easton <bill.easton@elastic.co>
This commit is contained in:
William Easton
2025-07-01 15:27:17 -05:00
committed by GitHub
parent 56a0e104f7
commit 3089cf2d26
5 changed files with 22 additions and 15 deletions

View File

@@ -1,8 +1,6 @@
import logging
from typing import List, Optional
import torch
from docling.datamodel.accelerator_options import AcceleratorDevice
_log = logging.getLogger(__name__)
@@ -18,6 +16,8 @@ def decide_device(
1. AUTO: Check for the best available device on the system.
2. User-defined: Check if the device actually exists, otherwise fall-back to CPU
"""
import torch
device = "cpu"
has_cuda = torch.backends.cuda.is_built() and torch.cuda.is_available()