# ZeroGPU has not been initialized when trying to use space in other space

**URL:** <https://discuss.huggingface.co/t/zerogpu-has-not-been-initialized-when-trying-to-use-space-in-other-space/104575>\
**Category:** Spaces\
**Created:** [August 29, 2024, 9:30pm UTC](https://discuss.huggingface.co/t/zerogpu-has-not-been-initialized-when-trying-to-use-space-in-other-space/104575 "2024-08-29T21:30:29Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhargavssss](https://avatars.discourse-cdn.com/v4/letter/b/47e85d/32.png) [@Bhargavssss](https://discuss.huggingface.co/u/Bhargavssss)\
**Post date:** [August 29, 2024, 9:30pm UTC](https://discuss.huggingface.co/t/zerogpu-has-not-been-initialized-when-trying-to-use-space-in-other-space/104575/1 "2024-08-29T21:30:29Z")

</div>

Hi iam trying to access a hugging face space into other space

my app.py

```auto
import os
import gradio as gr
from huggingface_hub import HfApi
from gradio_client.exceptions import AuthenticationError

def load_space():
    # Try to get the token from environment variable
    hf_token = os.environ.get('api')
    
    if not hf_token:
        print("Warning: HUGGINGFACE_TOKEN environment variable not set.")
        print("Attempting to use Hugging Face CLI login...")
    
    try:
        # Attempt to load the space
        iface = gr.load(
            name="My space",
            hf_token=hf_token,
            src="spaces"
        )
        print("Space loaded successfully!")
        return iface
    except AuthenticationError as e:
        print(f"Authentication error: {e}")
        print("Please make sure you're logged in or using a valid token.")
        return None
    except Exception as e:
        print(f"An error occurred: {e}")
        return None

def main():
    iface = load_space()
    if iface:
        iface.queue(max_size=300)
        iface.launch(debug=False)
    else:
        print("Failed to load the space. Please check the error messages above.")

if __name__ == " __main__":
    main()

```

My output

# runtime error

## ZeroGPU has not been initialized

Container logs:

```auto
===== Application Startup at 2024-08-29 21:20:08 =====

Fetching Space from: https://huggingface.co/spaces/....
Loaded as API: https://---.hf.space ✔
Space loaded successfully!
Running on local URL: http://0.0.0.0:7860

To create a public link, set `share=True` in `launch()`.

```

---

<div class="post-metadata">

**Author:** ![John6666](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/john6666/32/27664_2.png) [@John6666](https://discuss.huggingface.co/u/John6666)\
**Post date:** [August 30, 2024, 2:14am UTC](https://discuss.huggingface.co/t/zerogpu-has-not-been-initialized-when-trying-to-use-space-in-other-space/104575/2 "2024-08-30T02:14:35Z")

</div>

Zero GPU spaces will cause an error if the spaces library is not imported first. (This has been made even stricter by a recent specification change.)

In addition, at least one function with the @spaces decorator must be present or an error will occur as well.  
Dummy functions are fine.

```py
import spaces
import os
import gradio as gr
from huggingface_hub import HfApi
from gradio_client.exceptions import AuthenticationError

@spaces.GPU
def dummy(): # just a dummy
    pass

def load_space():
    # Try to get the token from environment variable
    hf_token = os.environ.get('api')
    
    if not hf_token:
        print("Warning: HUGGINGFACE_TOKEN environment variable not set.")
        print("Attempting to use Hugging Face CLI login...")
    
    try:
        # Attempt to load the space
        iface = gr.load(
            name="My space",
            hf_token=hf_token,
            src="spaces"
        )
        print("Space loaded successfully!")
        return iface
    except AuthenticationError as e:
        print(f"Authentication error: {e}")
        print("Please make sure you're logged in or using a valid token.")
        return None
    except Exception as e:
        print(f"An error occurred: {e}")
        return None

def main():
    iface = load_space()
    if iface:
        iface.queue(max_size=300)
        iface.launch(debug=False)
    else:
        print("Failed to load the space. Please check the error messages above.")

if __name__ == " __main__":
    main()

```
