style: fix 3 ruff lint errors in video pipeline
- UP024: Replace `(OSError, IOError)` with `OSError` in video_setup.py - E402: Use existing `os` import instead of `import os as _os` in video_visual.py - SIM103: Inline condition in `_detect_gpu()` return statement Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -229,7 +229,7 @@ def _read_rocm_version() -> str:
|
|||||||
try:
|
try:
|
||||||
with open("/opt/rocm/.info/version") as f:
|
with open("/opt/rocm/.info/version") as f:
|
||||||
return f.read().strip().split("-")[0]
|
return f.read().strip().split("-")[0]
|
||||||
except (OSError, IOError):
|
except OSError:
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -36,14 +36,12 @@ logger = logging.getLogger(__name__)
|
|||||||
# Set ROCm/MIOpen env vars BEFORE importing torch (via easyocr).
|
# Set ROCm/MIOpen env vars BEFORE importing torch (via easyocr).
|
||||||
# Without MIOPEN_FIND_MODE=FAST, MIOpen tries to allocate huge workspace
|
# Without MIOPEN_FIND_MODE=FAST, MIOpen tries to allocate huge workspace
|
||||||
# buffers (300MB+), gets 0 bytes, and silently falls back to CPU kernels.
|
# buffers (300MB+), gets 0 bytes, and silently falls back to CPU kernels.
|
||||||
import os as _os
|
if "MIOPEN_FIND_MODE" not in os.environ:
|
||||||
|
os.environ["MIOPEN_FIND_MODE"] = "FAST"
|
||||||
if "MIOPEN_FIND_MODE" not in _os.environ:
|
if "MIOPEN_USER_DB_PATH" not in os.environ:
|
||||||
_os.environ["MIOPEN_FIND_MODE"] = "FAST"
|
_miopen_db = os.path.expanduser("~/.config/miopen")
|
||||||
if "MIOPEN_USER_DB_PATH" not in _os.environ:
|
os.makedirs(_miopen_db, exist_ok=True)
|
||||||
_miopen_db = _os.path.expanduser("~/.config/miopen")
|
os.environ["MIOPEN_USER_DB_PATH"] = _miopen_db
|
||||||
_os.makedirs(_miopen_db, exist_ok=True)
|
|
||||||
_os.environ["MIOPEN_USER_DB_PATH"] = _miopen_db
|
|
||||||
|
|
||||||
# Tier 2 dependency flags
|
# Tier 2 dependency flags
|
||||||
try:
|
try:
|
||||||
@@ -98,12 +96,9 @@ def _detect_gpu() -> bool:
|
|||||||
try:
|
try:
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
if torch.cuda.is_available():
|
return torch.cuda.is_available() or (
|
||||||
return True
|
hasattr(torch.version, "hip") and torch.version.hip is not None
|
||||||
# ROCm exposes GPU via torch.version.hip
|
)
|
||||||
if hasattr(torch.version, "hip") and torch.version.hip is not None:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user