You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
RuntimeError: Expected u.is_cuda() to be true, but got false. (Could this error message be improved? If so, please report an enhancement request to PyTorch.)`
#56
Traceback (most recent call last): File "/home/renzecheng/gcx/ultralytics-main/mbyolo_train.py", line 44, in <module> "train": YOLO(model_conf).train(**args), File "/home/renzecheng/gcx/ultralytics-main/ultralytics/models/yolo/model.py", line 23, in __init__ super().__init__(model=model, task=task, verbose=verbose) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/engine/model.py", line 143, in __init__ self._new(model, task=task, verbose=verbose) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/engine/model.py", line 251, in _new self.model = (model or self._smart_load("model"))(cfg_dict, verbose=verbose and RANK == -1) # build model File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/tasks.py", line 342, in __init__ m.stride = torch.tensor([s / x.shape[-2] for x in _forward(torch.zeros(1, ch, s, s))]) # forward File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/tasks.py", line 340, in _forward return self.forward(x)[0] if isinstance(m, (Segment, Pose, OBB)) else self.forward(x) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/tasks.py", line 118, in forward return self.predict(x, *args, **kwargs) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/tasks.py", line 136, in predict return self._predict_once(x, profile, visualize, embed) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/tasks.py", line 157, in _predict_once x = m(x) # run File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, **kwargs) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/mamba_yolo.py", line 382, in forward x = input + self.drop_path(self.op(self.norm(X1))) File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, **kwargs) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/mamba_yolo.py", line 186, in forward y = self.forward_core(x, channel_first=(self.d_conv > 1)) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/mamba_yolo.py", line 165, in forward_corev2 x = cross_selective_scan( File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/common_utils_mbyolo.py", line 192, in cross_selective_scan ys: torch.Tensor = selective_scan( File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/common_utils_mbyolo.py", line 168, in selective_scan return SelectiveScan.apply(u, delta, A, B, C, D, delta_bias, delta_softplus, nrows, backnrows, ssoflex) File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/autograd/function.py", line 539, in apply return super().apply(*args, **kwargs) # type: ignore[misc] File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/cuda/amp/autocast_mode.py", line 113, in decorate_fwd return fwd(*args, **kwargs) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/common_utils_mbyolo.py", line 125, in forward out, x, *rest = selective_scan_cuda_core.fwd(u, delta, A, B, C, D, delta_bias, delta_softplus, 1) RuntimeError: Expected u.is_cuda() to be true, but got false. (Could this error message be improved? If so, please report an enhancement request to PyTorch.)
The text was updated successfully, but these errors were encountered:
In yolov9, you need edit class DetectionModel(BaseModel): for YOLOv8 and YOLOv11 is same method
class DetectionModel(BaseModel):
"""YOLOv8 detection model."""
def __init__(self, cfg="yolov8n.yaml", ch=3, nc=None, verbose=True): # model, input channels, number of classes
"""Initialize the YOLOv8 detection model with the given config and parameters."""
super().__init__()
self.yaml = cfg if isinstance(cfg, dict) else yaml_model_load(cfg) # cfg dict
# Define model
ch = self.yaml["ch"] = self.yaml.get("ch", ch) # input channels
if nc and nc != self.yaml["nc"]:
LOGGER.info(f"Overriding model.yaml nc={self.yaml['nc']} with nc={nc}")
self.yaml["nc"] = nc # override YAML value
self.model, self.save = parse_model(deepcopy(self.yaml), ch=ch, verbose=verbose) # model, savelist
self.names = {i: f"{i}" for i in range(self.yaml["nc"])} # default names dict
self.inplace = self.yaml.get("inplace", True)
# Build strides
m = self.model[-1] # Detect()
if isinstance(m, Detect): # includes all Detect subclasses like Segment, Pose, OBB, WorldDetect
s = 256 # 2x min stride
m.inplace = self.inplace
forward = lambda x: self.forward(x)[0] if isinstance(m, (Segment, Pose, OBB)) else self.forward(x)
try: #there add exception
m.stride = torch.tensor([s / x.shape[-2] for x in forward(torch.zeros(1, ch, s, s))]) # forward
except Exception as e:
if 'Not implemented on the CPU' in str(
e) or 'Input type (torch.FloatTensor) and weight type (torch.cuda.FloatTensor)' in str(
e) or 'CUDA tensor' in str(e) or 'is_cuda()' in str(e) or "Cannot find backend for cpu" in str(e):
self.model.to(torch.device('cuda'))
m.stride = torch.tensor([s / x.shape[-2] for x in
forward(torch.zeros(2, ch, s, s).to(torch.device('cuda')))]) # forward
else:
raise e
self.stride = m.stride
m.bias_init() # only run once
else:
self.stride = torch.Tensor([32]) # default stride for i.e. RTDETR
# Init weights, biases
initialize_weights(self)
if verbose:
self.info()
LOGGER.info("")
Traceback (most recent call last): File "/home/renzecheng/gcx/ultralytics-main/mbyolo_train.py", line 44, in <module> "train": YOLO(model_conf).train(**args), File "/home/renzecheng/gcx/ultralytics-main/ultralytics/models/yolo/model.py", line 23, in __init__ super().__init__(model=model, task=task, verbose=verbose) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/engine/model.py", line 143, in __init__ self._new(model, task=task, verbose=verbose) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/engine/model.py", line 251, in _new self.model = (model or self._smart_load("model"))(cfg_dict, verbose=verbose and RANK == -1) # build model File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/tasks.py", line 342, in __init__ m.stride = torch.tensor([s / x.shape[-2] for x in _forward(torch.zeros(1, ch, s, s))]) # forward File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/tasks.py", line 340, in _forward return self.forward(x)[0] if isinstance(m, (Segment, Pose, OBB)) else self.forward(x) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/tasks.py", line 118, in forward return self.predict(x, *args, **kwargs) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/tasks.py", line 136, in predict return self._predict_once(x, profile, visualize, embed) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/tasks.py", line 157, in _predict_once x = m(x) # run File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, **kwargs) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/mamba_yolo.py", line 382, in forward x = input + self.drop_path(self.op(self.norm(X1))) File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, **kwargs) File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1527, in _call_impl return forward_call(*args, **kwargs) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/mamba_yolo.py", line 186, in forward y = self.forward_core(x, channel_first=(self.d_conv > 1)) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/mamba_yolo.py", line 165, in forward_corev2 x = cross_selective_scan( File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/common_utils_mbyolo.py", line 192, in cross_selective_scan ys: torch.Tensor = selective_scan( File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/common_utils_mbyolo.py", line 168, in selective_scan return SelectiveScan.apply(u, delta, A, B, C, D, delta_bias, delta_softplus, nrows, backnrows, ssoflex) File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/autograd/function.py", line 539, in apply return super().apply(*args, **kwargs) # type: ignore[misc] File "/home/renzecheng/anaconda3/envs/mambaYolo-11/lib/python3.10/site-packages/torch/cuda/amp/autocast_mode.py", line 113, in decorate_fwd return fwd(*args, **kwargs) File "/home/renzecheng/gcx/ultralytics-main/ultralytics/nn/modules/common_utils_mbyolo.py", line 125, in forward out, x, *rest = selective_scan_cuda_core.fwd(u, delta, A, B, C, D, delta_bias, delta_softplus, 1) RuntimeError: Expected u.is_cuda() to be true, but got false. (Could this error message be improved? If so, please report an enhancement request to PyTorch.)
The text was updated successfully, but these errors were encountered: