from zdl.utils.env.terminal import Terminal


class GPU(Terminal):

    @classmethod
    def supported(cls):
        try:
            if int(cls.checkOutput('nvidia-smi > /dev/null '
                                   '&& nvidia-smi --query-gpu=name --format=csv,noheader | wc -l')) > 0:
                return True
            return False
        except Exception:
            return False

    @classmethod
    def cards(cls):
        try:
            return cls.checkOutput('nvidia-smi --query-gpu=name --format=csv,noheader')
        except Exception:
            return None

cefdd8bcd7cdda2af1633b087f9ac23f6f59ca47
<mask token>


class GPU(Terminal):
    <mask token>
    <mask token>

<mask token>


class GPU(Terminal):
    <mask token>

    @classmethod
    def cards(cls):
        try:
            return cls.checkOutput(
                'nvidia-smi --query-gpu=name --format=csv,noheader')
        except Exception:
            return None

<mask token>


class GPU(Terminal):

    @classmethod
    def supported(cls):
        try:
            if int(cls.checkOutput(
                'nvidia-smi > /dev/null && nvidia-smi --query-gpu=name --format=csv,noheader | wc -l'
                )) > 0:
                return True
            return False
        except Exception:
            return False

    @classmethod
    def cards(cls):
        try:
            return cls.checkOutput(
                'nvidia-smi --query-gpu=name --format=csv,noheader')
        except Exception:
            return None

from zdl.utils.env.terminal import Terminal


class GPU(Terminal):

    @classmethod
    def supported(cls):
        try:
            if int(cls.checkOutput(
                'nvidia-smi > /dev/null && nvidia-smi --query-gpu=name --format=csv,noheader | wc -l'
                )) > 0:
                return True
            return False
        except Exception:
            return False

    @classmethod
    def cards(cls):
        try:
            return cls.checkOutput(
                'nvidia-smi --query-gpu=name --format=csv,noheader')
        except Exception:
            return None

from zdl.utils.env.terminal import Terminal


class GPU(Terminal):

    @classmethod
    def supported(cls):
        try:
            if int(cls.checkOutput('nvidia-smi > /dev/null '
                                   '&& nvidia-smi --query-gpu=name --format=csv,noheader | wc -l')) > 0:
                return True
            return False
        except Exception:
            return False

    @classmethod
    def cards(cls):
        try:
            return cls.checkOutput('nvidia-smi --query-gpu=name --format=csv,noheader')
        except Exception:
            return None
