code: def __init__(self, device: str):
      device_id = int(device.split(":")[1]) if ":" in device else 0
      if not CUDACPU:
          check(cuda.cuInit(0))
          check(
              cuda.cuDeviceGet(
                  ctypes.byref(device := cuda.CUdevice()), device_id
              )
          )
          self.context = init_c_var(
              cuda.CUcontext(),
              lambda x: check(
                  cuda.cuCtxCreate_v2(ctypes.byref(x), 0, device)
              ),
          )
          check(
              cuda.cuDeviceComputeCapability(
                  ctypes.byref(major := ctypes.c_int()),
                  ctypes.byref(minor := ctypes.c_int()),
                  device_id,
              )
          )
      self.arch = (
          f"sm_{major.value}{minor.value}" if not CUDACPU else "sm_35"
      )
  
      from tinygrad.runtime.graph.cuda import CUDAGraph
  
      super().__init__(
          CUDAAllocator(self) if not CUDACPU else MallocAllocator,
          LinearizerOptions(
              "CUDA",
              supports_float4_alu=False,
              global_max=[65535, 65535, 2147483647],
              local_max=[64, 1024, 1024],
          ),
          CUDARenderer,
          functools.partial(compile_cuda, arch=self.arch),
          f"compile_cuda_{self.arch}",
          functools.partial(CUDAProgram, self),
          graph=CUDAGraph if not CUDACPU else None,
      )
  
imports: from __future__ import annotations
  import subprocess, hashlib, tempfile, ctypes, ctypes.util, functools, re
  from pathlib import Path
  from typing import Tuple, Optional
  import gpuctypes.cuda
  from tinygrad.helpers import DEBUG, getenv, from_mv, init_c_var, colored, cpu_time_execution, compile_cuda_style, encode_args_cuda_style, time_execution_cuda_style
  from tinygrad.device import Compiled, LRUAllocator, MallocAllocator
  from tinygrad.codegen.kernel import LinearizerOptions
  from tinygrad.renderer.cstyle import CUDARenderer
label_desc: Use image node_id 1 to create a new CUDADevice object from inherited base classes: Compiled with example: obj = CUDADevice(device)