# Mac M1 gpu not detected

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmac-m1-gpu-not-detected%2F27340%3E%5C
**Category:** Beginners\
**Created:** [December 6, 2022, 12:17pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmac-m1-gpu-not-detected%2F27340 "2022-12-06T12:17:11Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![vainaixr](https://avatars.discourse-cdn.com/v4/letter/v/5f8ce5/32.png) [@vainaixr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvainaixr)%5C
**Post date:** [December 6, 2022, 12:17pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmac-m1-gpu-not-detected%2F27340%2F1 "2022-12-06T12:17:11Z")

</div>

I have a gpu on my pc, but it does not show up when I use,

```auto
import torch
print([torch.cuda.device(i) for i in range(torch.cuda.device_count())])

```

is there a further setting required to use the gpu  
these are some further details regarding the gpu on my pc

```auto
Chipset Model:	Apple M1
  Type:	GPU
  Bus:	Built-In
  Total Number of Cores:	8

```

---

<div class="post-metadata">

**Author:** ![garg-aayush](https://avatars.discourse-cdn.com/v4/letter/g/dec6dc/32.png) [@garg-aayush](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fgarg-aayush)%5C
**Post date:** [December 6, 2022, 1:28pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmac-m1-gpu-not-detected%2F27340%2F2 "2022-12-06T13:28:31Z")

</div>

The GPU on Mac is not Nvidia’s kind. It is M1 GPU designed by Apple.  
You need to first set the device to `mps`.

See this for more details on installation and usage:  
[Running PyTorch on the M1 GPUtype or paste code here](https://sebastianraschka.com/blog/2022/pytorch-m1-gpu.html)

---

<div class="post-metadata">

**Author:** ![vainaixr](https://avatars.discourse-cdn.com/v4/letter/v/5f8ce5/32.png) [@vainaixr](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fvainaixr)%5C
**Post date:** [December 6, 2022, 1:47pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmac-m1-gpu-not-detected%2F27340%2F3 "2022-12-06T13:47:55Z")

</div>

thanks for the info, it now detects the gpu,

```auto
conda install pytorch -c pytorch-nightly

```

```auto
import torch
if torch.backends.mps.is_available():
    mps_device = torch.device("mps")
    x = torch.ones(1, device=mps_device)
    print(x)
else:
    print ("MPS device not found.")

```

which outputs,

```auto
UserWarning: The operator 'aten::nonzero' is not currently supported on the MPS backend and will fall back to run on the CPU. This may have performance implications. 
tensor([1.], device='mps:0')

```

---

<div class="post-metadata">

**Author:** ![garg-aayush](https://avatars.discourse-cdn.com/v4/letter/g/dec6dc/32.png) [@garg-aayush](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fgarg-aayush)%5C
**Post date:** [December 6, 2022, 2:53pm UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmac-m1-gpu-not-detected%2F27340%2F4 "2022-12-06T14:53:23Z")

</div>

> [@vainaixr](#):
>
> ```auto
> The operator 'aten::nonzero' is not currently supported on the MPS backend and will fall back to run on the CPU. This may have performance implications. 
> tensor([1.], device='mps:0'
> 
> ```

This is a `UserWarning`. You can ignore it for not. Most likely, some bug in the current `nightly` version. Don’t worry about it.

---

<div class="post-metadata">

**Author:** ![Smomitya](https://avatars.discourse-cdn.com/v4/letter/s/9f8e36/32.png) [@Smomitya](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2FSmomitya)%5C
**Post date:** [January 3, 2023, 5:11am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fmac-m1-gpu-not-detected%2F27340%2F6 "2023-01-03T05:11:52Z")

</div>

I have the same issue with current stable version. Moreover, it seems that all computations are going to be on CPU.
