# How to deal with no GPU during docker build time

**URL:** </static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-deal-with-no-gpu-during-docker-build-time%2F28544%3E%5C
**Category:** Spaces\
**Created:** [December 28, 2022, 7:36am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-deal-with-no-gpu-during-docker-build-time%2F28544 "2022-12-28T07:36:55Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fjenett](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/fjenett/32/59016_2.png) [@fjenett](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ffjenett)%5C
**Post date:** [December 28, 2022, 7:36am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-deal-with-no-gpu-during-docker-build-time%2F28544%2F1 "2022-12-28T07:36:56Z")

</div>

Hey, i ran into an issue with new docker image support on spaces … and not sure, if this is standard behaviour, or specific to HF.

I am building an app that needs `neural_renderer`. When i add this requirement to the Dockerfile it fails during build with `No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda'`. After some trial-error i figured that i can install neural renderer after app start.

So i assume that there is no GPU backing during docker build time and it only becomes available after container start. Sounds like a common problem … or am i missing something obvious?

My original question on HF Discord:

> **[Discord - A New Way to Chat with Friends & Communities](https://discord.com/channels/879548962464493619/897391062975385640/1057313620989583370)**
>
> Discord is the easiest way to communicate over voice, video, and text. Chat, hang out, and stay close with your friends and communities.

---

<div class="post-metadata">

**Author:** ![fjenett](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/fjenett/32/59016_2.png) [@fjenett](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ffjenett)%5C
**Post date:** [December 29, 2022, 7:26am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-deal-with-no-gpu-during-docker-build-time%2F28544%2F2 "2022-12-29T07:26:51Z")

</div>

Here is some info from NVIDIA: [Advanced topics · NVIDIA/nvidia-docker Wiki · GitHub](https://github.com/NVIDIA/nvidia-docker/wiki/Advanced-topics#default-runtime)

Seems like my assumption is right and there is no GPU avail during docker build. So my question to the HF team is: **how can one deal with that?**

---

<div class="post-metadata">

**Author:** ![fjenett](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/fjenett/32/59016_2.png) [@fjenett](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Ffjenett)%5C
**Post date:** [December 29, 2022, 7:31am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-deal-with-no-gpu-during-docker-build-time%2F28544%2F3 "2022-12-29T07:31:49Z")

</div>

Here is a howto for a NVIDIA GPU-backed runtime. This allows one to build the container image on your local system (or any other GPU system), submit it to Docker hub and then inherit from there during build on HF.

> <https://stackoverflow.com/questions/59691207/docker-build-with-nvidia-runtime>

---

<div class="post-metadata">

**Author:** ![kopyl](https://avatars.discourse-cdn.com/v4/letter/k/3bc359/32.png) [@kopyl](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fkopyl)%5C
**Post date:** [October 23, 2023, 2:33am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-deal-with-no-gpu-during-docker-build-time%2F28544%2F4 "2023-10-23T02:33:00Z")

</div>

I had a couple of errors. I thought the first one was due to the absence of GPU during the installation, but it turned out that it was actually second.

> <https://github.com/turboderp/exllamav2/issues/126>
>
> When i build a Docker image on a machine with no GPU, after executing this \`pyth…on setup.py install --user\` i get a huge error:
> 
> https://pastebin.com/bCBcTszR
> 
> How can i install the app without GPU?

I fixed them both by:

1. Running `RUN apt update && apt install -y libpython3.10-dev` before `RUN python setup.py install --user`
2. Replacing `RUN python setup.py install --user` with `RUN TORCH_CUDA_ARCH_LIST=Turing python setup.py install --user` (added `TORCH_CUDA_ARCH_LIST=Turing`)

Hope it helped you

---

<div class="post-metadata">

**Author:** ![radames](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/radames/32/28246_2.png) [@radames](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Fu%2Fradames)%5C
**Post date:** [October 23, 2023, 3:53am UTC](/static-proxy?url=https%3A%2F%2Fdiscuss.huggingface.co%2Ft%2Fhow-to-deal-with-no-gpu-during-docker-build-time%2F28544%2F5 "2023-10-23T03:53:15Z")

</div>

Thank you for the clarification, @kopyl. Apologies for the delay, @fjenett. You’re correct about Docker’s buildtime in Spaces, it doesn’t provide access to GPU hardware. Thus, any GPU-related commands shouldn’t be executed during your Dockerfile’s build step. For instance, commands like `nvidia-smi` or `torch.cuda.is_available()` can’t be run while building an image. @fjenett, your suggestion to build a wheel or a container on a GPU supported system and then loading it into Spaces later is excellent.
