mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-09 06:58:11 -05:00
ruff: suppressible-exception (#5182)
* fix: use contextlib to suppress errors * enable rule SIM105 --------- Co-authored-by: George Hotz <72895+geohot@users.noreply.github.com>
This commit is contained in:
@@ -27,6 +27,7 @@ lint.select = [
|
||||
"RET506", # superfluous-else-raise
|
||||
"RET507", # superfluous-else-continue
|
||||
"A", # builtin-variable-shadowing, builtin-argument-shadowing, builtin-attribute-shadowing
|
||||
"SIM105", # suppressible-exception
|
||||
"FURB110",# if-exp-instead-of-or-operator
|
||||
]
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import os, atexit, functools
|
||||
import os, atexit, functools, contextlib
|
||||
from collections import defaultdict
|
||||
from typing import List, Any, DefaultDict, Union
|
||||
from tinygrad.ops import UnaryOps, BinaryOps, ReduceOps, LoadOps, BufferOps, TernaryOps, LazyOp
|
||||
@@ -8,8 +8,7 @@ from tinygrad.codegen.uops import UOps, UOp, UPat
|
||||
from tinygrad.shape.symbolic import NumNode
|
||||
from tinygrad.lazy import LazyBuffer
|
||||
|
||||
try: import networkx as nx
|
||||
except ImportError: pass
|
||||
with contextlib.suppress(ImportError): import networkx as nx
|
||||
|
||||
# **** debugging and graphing ****
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
from __future__ import annotations
|
||||
import os, ctypes, pathlib, re, fcntl, functools, mmap, struct, tempfile, hashlib, subprocess, time, array
|
||||
import os, ctypes, contextlib, pathlib, re, fcntl, functools, mmap, struct, tempfile, hashlib, subprocess, time, array
|
||||
from typing import Tuple, List, Any
|
||||
from dataclasses import dataclass
|
||||
from tinygrad.device import HCQCompatCompiled, HCQCompatAllocator, Compiler, CompileError, BufferOptions
|
||||
@@ -458,10 +458,7 @@ class NVDevice(HCQCompatCompiled):
|
||||
fd_uvm_2 = os.open("/dev/nvidia-uvm", os.O_RDWR | os.O_CLOEXEC)
|
||||
NVDevice.root = rm_alloc(self.fd_ctl, nv_gpu.NV01_ROOT_CLIENT, 0, 0, None).hObjectNew
|
||||
uvm.initialize(self.fd_uvm)
|
||||
try:
|
||||
uvm.mm_initialize(fd_uvm_2, uvmFd=self.fd_uvm)
|
||||
except RuntimeError:
|
||||
pass # this error is okay, CUDA hits it too
|
||||
with contextlib.suppress(RuntimeError): uvm.mm_initialize(fd_uvm_2, uvmFd=self.fd_uvm) # this error is okay, CUDA hits it too
|
||||
|
||||
NVDevice.gpus_info = (nv_gpu.nv_ioctl_card_info_t*64)()
|
||||
nv_iowr(NVDevice.fd_ctl, nv_gpu.NV_ESC_CARD_INFO, NVDevice.gpus_info)
|
||||
|
||||
Reference in New Issue
Block a user