autodistill / autodistill-yolov8

YOLOv8 Target Model plugin for Autodistill
https://docs.autodistill.com
GNU Affero General Public License v3.0
42 stars 11 forks source link

device handling in yolov8.py: device=device? #3

Open ReinhardLojewski opened 1 year ago

ReinhardLojewski commented 1 year ago

Just a question: Tried to run the code on windows, and DEVICE overwrote function parameter for self.yolo.train when run with cpu argument on machine with gpu. Is this behaviour intended?

call in main

target_model.train(DATA_YAML_PATH, epochs=2, device = 'cpu')

yolov8.py

DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")

class YOLOv8(DetectionTargetModel): def init(self, model_name): self.yolo = YOLO(model_name)

def train(self, dataset_yaml, epochs=300, device=DEVICE):
    print('My sanity', device)
    #self.yolo.train(data=dataset_yaml, epochs=epochs, device=DEVICE)     # CURRENT VERSION 
    self.yolo.train(data=dataset_yaml, epochs=epochs, device=device)         # now takes user definition of defice

Best regards, Reinhard

adriansletten commented 1 year ago

I have the same issue when running this notebook in google colab. No matter what I change the device to I always get the following error: ValueError: Invalid CUDA 'device=cuda' requested. Use 'device=cpu' or pass valid CUDA device(s) if available, i.e. 'device=0' or 'device=0,1,2,3' for Multi-GPU.

adriansletten commented 1 year ago

A quick fix is to import version 0.1.0 from pip. pip install autodistill-yolov8==0.1.0

capjamesg commented 12 months ago

Apologies for the friction you ran into getting started. I pushed a change to enable mps acceleration support for YOLOv8 training in Autodistill but the default device configuration wasn't set up properly.

Upgrade to autodistill-yolov8 0.1.3:

pip install --upgrade autodistill-yolov8==0.1.3

Use this code to train:

target_model.train(DATA_YAML_PATH, epochs=50, devices=[0,1...])

Where devices is the list of CUDA device IDs you want to use in training.

MuhammadShifa commented 5 months ago

Hi @capjamesg , I am importing the YOLOv8Base, but my window system is hanging and doesn't move forward, also it doesn't show any issue. Look like stuck in the import statements. Tested both versions as suggested above.

>>> from autodistill_yolov8 import YOLOv8Base