Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
ReinhardLojewski opened this issue Nov 8, 2023 · 4 comments
Open

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

ReinhardLojewski opened this issue Nov 8, 2023 · 4 comments

Comments

@ReinhardLojewski
Copy link

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
Copy link

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
Copy link

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

@capjamesg
Copy link
Member

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
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants