microsoft / DirectML

DirectML is a high-performance, hardware-accelerated DirectX 12 library for machine learning. DirectML provides GPU acceleration for common machine learning tasks across a broad range of supported hardware and drivers, including all DirectX 12-capable GPUs from vendors such as AMD, Intel, NVIDIA, and Qualcomm.
MIT License
2.24k stars 301 forks source link

RuntimeError: Cannot set version_counter for inference tensor #622

Open Aditya5191 opened 3 months ago

Aditya5191 commented 3 months ago

I am trying to run YoloV8 on my AMD RX550 using DirectML and every time i run the training it fails with this error RuntimeError: Cannot set version_counter for inference tensor

from ultralytics import YOLO import torch_directml model = YOLO("yolov8n.yaml") dml = torch_directml.device() model.train(data="config.yaml", epochs=200, device=dml)

This works properly if i set device="cpu" Please help me with this.. I'm new to Machine learning stuff.

Hoernchen commented 2 months ago

Same issue with pytorch + autocast on a 6900xt...

larinius commented 2 weeks ago

I have same issue now. In 2023 used Comfy UI with the same AMD GPU and Direct ML device, it worked 100%. Maybe they broke something in resent updates?

larinius commented 1 week ago

I got working example with this:

    def generate(self, prompt, steps):
        self.load()
        try:
            with torch.no_grad():  # **Use no_grad instead of inference_mode**
                images = self.pipe(
                    prompt=[prompt],
                    num_inference_steps=steps,
                    guidance_scale=0.0,
                    height=256,
                    width=256,
                ).images
            return images
        finally:
            self.unload()