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

Missing component for share link tunneling for aarm64 #6053

Closed
1 task done
hillct opened this issue Oct 21, 2023 · 11 comments
Closed
1 task done

Missing component for share link tunneling for aarm64 #6053

hillct opened this issue Oct 21, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@hillct
Copy link

hillct commented Oct 21, 2023

Describe the bug

When using Gradio within a Jupyter notebook running on an ARM64 based host, he following message is displayed when calling .launch(share=True)

Could not create share link. Missing file: /usr/local/lib/python3.8/dist-packages/gradio/frpc_linux_aarch64_v0.2. 

Please check your internet connection. This can happen if your antivirus software blocks the download of this file. You can install manually by following these steps: 

1. Download this file: https://cdn-media.huggingface.co/frpc-gradio-0.2/frpc_linux_aarch64
2. Rename the downloaded file to: frpc_linux_aarch64_v0.2
3. Move the file to this location: /usr/local/lib/python3.8/dist-packages/gradio

When visited, he CDN URL yields a 403 Forbidden response. Needless to say, the expected behavior is for the file to be where the messaging indicates it is located.

I see two possibilities. Either the component was never compiled for aarm64 (or uploaded) through some oversight, or it exists in a different location in which is merely an issue of documentation

Have you searched existing issues? 🔎

  • I have searched and found no existing issues

Reproduction

Below is a Dockerfile facilitating reproduction. It should be reproducabl on any ARM based hardware including Raspbry Pi and in my case an Nvidia Jetson AGX Orin dev kit.

FROM nvcr.io/nvidia/l4t-pytorch:r35.2.1-pth2.0-py3
RUN apt-get update && apt-get install -y --no-install-recommends python3-pip python-is-python3 nano
RUN pip3 install -U protobuf numpy ipywidgets fastapi gradio jupyterlab
#RUN wget -O /usr/local/lib/python3.8/dist-packages/gradio/frpc_linux_aarch64_v0.2 https://cdn-media.huggingface.co/frpc-gradio-0.2/frpc_linux_aarch64
WORKDIR /app
COPY . .
ENTRYPOINT ["jupyter-lab","--allow-root","--ip=*","--no-browser"]
  1. On any ARM based host with Docker (any version) installed, build h above image
  2. Start a container using this image publishing pors 8888 and 7860
  3. access the Jupyer-lab web interface and write a trivial Gradio interface. he only requirement here is that the launch method be called with share=True
  4. Run the block, and the error and solution messaging indicated earlier will be displayed. Visit the URL, to observe he 403 error.
    It should be noted that I commented out the line in the Dockerfile that would otherwise retrieve the missing file because the file is no available at that URL and the docker image would not build with the error-yielding wget call left in.

Screenshot

No response

Logs

No response

System Info

Nvidia Jetson AGX Orin 32GB
Linux orindev 5.10.104-tegra #1 SMP PREEMPT Tue Jan 24 15:09:44 PST 2023 aarch64 aarch64 aarch64 GNU/Linux
Docker version 24.0.5, build 24.0.5-0ubuntu1~20.04.1
Python 3.8.10 (within L4T Docker image)

Gradio Environment Information:
------------------------------
Operating System: Linux
gradio version: 3.50.2
gradio_client version: 0.6.1

------------------------------------------------
gradio dependencies in your environment:

aiofiles: 23.2.1
altair: 5.1.2
fastapi: 0.104.0
ffmpy: 0.3.1
gradio-client==0.6.1 is not installed.
httpx: 0.25.0
huggingface-hub: 0.18.0
importlib-resources: 6.1.0
jinja2: 3.1.2
markupsafe: 2.1.2
matplotlib: 3.7.3
numpy: 1.24.4
orjson: 3.9.9
packaging: 23.0
pandas: 2.0.3
pillow: 9.4.0
pydantic: 2.4.2
pydub: 0.25.1
python-multipart: 0.0.6
pyyaml: 6.0.1
requests: 2.28.2
semantic-version: 2.10.0
typing-extensions: 4.8.0
uvicorn: 0.23.2
websockets: 11.0.3
authlib; extra == 'oauth' is not installed.
itsdangerous; extra == 'oauth' is not installed.


gradio_client dependencies in your environment:

fsspec: 2023.9.2
httpx: 0.25.0
huggingface-hub: 0.18.0
packaging: 23.0
requests: 2.28.2
typing-extensions: 4.8.0
websockets: 11.0.3

Severity

Blocking usage of gradio

@hillct hillct added the bug Something isn't working label Oct 21, 2023
@hillct
Copy link
Author

hillct commented Oct 21, 2023

The related code is at the top of tunneling.py
https://github.com/gradio-app/gradio/blob/main/gradio/tunneling.py#L21

Apparently the needed binaries for ARM we're never built, but presumably the existing Lenox code base can simply be cross-compiled in this case.

Very strangely, in my specific instance, execution never reached line 52 of tunneling.py which would have yielded a much more informative error message and saved me half an hour of assembling a relatively convoluted ticket with what now seems to be unneeded detail.

@abidlabs
Copy link
Member

Hi @hillct I think you're right, we don't currently have the frpc compiled for this platform. We'll look into it.

@hillct
Copy link
Author

hillct commented Oct 22, 2023

Hi @hillct I think you're right, we don't currently have the frpc compiled for this platform. We'll look into it.

@abidlabs Is h source for frpc available, such that I can compile it myself? Are there significant changes relative to FRP? ie: https://gofrp.org/en ?

I may in fact just be able to add a build stage to my Dockerfile https://github.com/fatedier/frp/blob/dev/dockerfiles/Dockerfile-for-frpc

With this in mind, I'd recommend adding FRP as a submodule to the git repository, if for no other reason than to avoid dependency confusion.

Similarly, the Gradio docs proclaim it's only dependency is Python (3.8+) but obviously there is an architecture-specific binary dependency. For what it's worth, I'd suggest distributing Gradio in architecture-specific .whl files including he frpc binary, rather than pulling the needed binary off the huggingFace CDN at runtime.

UPDATE: I see now that the switch to frp was relatively recent, so it's understandable some of the docs mightt no have been updated... GHSA-3x5j-9vwr-8rr5

@hillct
Copy link
Author

hillct commented Oct 23, 2023

@abidlabs I went ahead and attempted to install a suitable frpc binary by modifying he Dockerfile as follows:

FROM nvcr.io/nvidia/l4t-pytorch:r35.2.1-pth2.0-py3
RUN apt-get update && apt-get install -y --no-install-recommends python3-pip python-is-python3 nano iputils-ping
RUN pip3 install -U protobuf numpy ipywidgets fastapi gradio jupyterlab
#RUN wget -O /usr/local/lib/python3.8/dist-packages/gradio/frpc_linux_aarch64_v0.2 https://cdn-media.huggingface.co/frpc-gradio-0.2/frpc_linux_aarch64
RUN wget -q https://github.com/fatedier/frp/releases/download/v0.52.1/frp_0.52.1_linux_arm64.tar.gz \
        && tar zxvf frp_0.52.1_linux_arm64.tar.gz frp_0.52.1_linux_arm64/frpc \
        && mv frp_0.52.1_linux_arm64/frpc /usr/local/lib/python3.8/dist-packages/gradio/frpc_linux_aarch64_v0.2
WORKDIR /app
COPY . .
ENTRYPOINT ["jupyter-lab","--allow-root","--ip=*","--no-browser"]

This test resulted in the following error displayed in he Jupyter notebook interface:

2023/10/22 22:31:29 [W] [service.go:131] login to server failed: dial tcp: lookup 44.237.78.176:7000: no such host

First, is that the correct I address for he gradio server? It neither responds to ping or is routable via traceroute, from docker, the host server, or any of several other machines accessible o me for testing. Presumably, either the frpc config file became corrupt and his is the wrong target server, or there may be a versioning issue between frpc and frps. What version of FRPS is currently in use on the gradio server?

@abidlabs
Copy link
Member

Hi @hillct, 44.237.78.176:7000 indeed is the correct address.

The FRPS server we are using is version 1. We are planning on open-sourcing this soon -- please follow #5866 for updates

@hillct
Copy link
Author

hillct commented Nov 23, 2023

@abidlabs Just now saw the OSS release of the huggingface FRP branch. I determined that the aarm64 build of frpc works perfectly, and I recommend i's likely that you can safely push builds for all supported platforms to he hf-media CDN (contingan upon QA workflows). Referring to the upstream github workflows, https://github.com/fatedier/frp/blob/dev/.github/workflows/build-and-push-image.yml#L68 provides a potentially convenien build mechanism and would allow for publicaion of he clien builds, even if not on the HF-media CDN. Absent those builds, I resolved my issue by adding a hf-frp build stage to by development Docker container build, as follows:

FROM golang:1.19 AS building
WORKDIR /building
RUN git clone https://github.com/huggingface/frp && cd frp && make frpc
#FROM nvcr.io/nvidia/l4t-pytorch:r35.2.1-pth2.0-py3
FROM nvcr.io/nvidia/l4t-pytorch:r35.1.0-pth1.13-py3
COPY --from=building /building/frp/bin/frpc /usr/local/lib/python3.8/dist-packages/gradio/frpc_linux_aarch64_v0.2
RUN apt-get update && apt-get install -y --no-install-recommends python3-pip python-is-python3 ninja-build nano iputils-ping
RUN pip3 install -U protobuf numpy ipywidgets fastapi gradio requests>==2.31 jupyterlab && \
	pip3 install -U transformers optimum sentencepiece
WORKDIR /app
COPY . .
ENTRYPOINT ["jupyter-lab","--allow-root","--ip=*","--no-browser"]

Absent the additional platform builds, it may be worthwhile to add some version of this to the primary gradio assembly documentation so users aren' forced to follow the path through (3 or 4) github issues o arrive at this solution

@loretoparisi
Copy link

@abidlabs I got the same very issue running on Docker on local OS

root@101c6cc65e4a:/app# python server.py 
Running on local URL:  http://0.0.0.0:7860

Could not create share link. Missing file: /usr/local/lib/python3.9/site-packages/gradio/frpc_linux_aarch64_v0.2. 

Please check your internet connection. This can happen if your antivirus software blocks the download of this file. You can install manually by following these steps: 

1. Download this file: https://cdn-media.huggingface.co/frpc-gradio-0.2/frpc_linux_aarch64
2. Rename the downloaded file to: frpc_linux_aarch64_v0.2
3. Move the file to this location: /usr/local/lib/python3.9/site-packages/gradio
4. ```

@pramitchoudhary
Copy link

pramitchoudhary commented Dec 23, 2023

Had a similar issue, @hillct suggestion was helpful. However, copying frpc_linux_aarch64_v0.2 was throwing an error for some reason, so I tried symlink, and that worked. Sharing in-case helpful.

FROM python:3.8
FROM golang:1.19 AS building
WORKDIR /building
RUN git clone https://github.com/huggingface/frp && cd frp && make frpc
FROM nvcr.io/nvidia/l4t-pytorch:r35.1.0-pth1.13-py3
COPY --from=building /building/frp/bin/frpc /app/frpc_linux_aarch64_v0.2
RUN apt-get update && apt-get install -y --no-install-recommends python3.8-venv python3-pip

ARG GRADIO_SERVER_PORT=7860
ENV GRADIO_SERVER_PORT=${GRADIO_SERVER_PORT}
ENV ENABLE_PUBLIC_ACCESS=0
COPY . ./app
WORKDIR /app
RUN make setup 
RUN ls /app/frpc_linux_aarch64_v0.2
RUN ln -s /app/frpc_linux_aarch64_v0.2 /app/.venv/lib/python3.8/site-packages/gradio/frpc_linux_aarch64_v0.2
EXPOSE 7860
CMD ["./.venv/bin/python", "-u", "app.py"]

@ihubanov
Copy link

ihubanov commented Jan 30, 2024

This is how I did it:

sudo apt-get update
sudo apt-get install golang-go
git clone https://github.com/huggingface/frp
cd frp
make frpc
... wait the compile to finish...
cp bin/frpc /usr/local/lib/python3.8/dist-packages/gradio/frpc_linux_aarch64_v0.2

@Sequential-circuits
Copy link

This is how I did it:

sudo apt-get update
sudo apt-get install golang-go
git clone https://github.com/huggingface/frp
cd frp
make frpc
... wait the compile to finish...
cp bin/frpc /usr/local/lib/python3.8/dist-packages/gradio/frpc_linux_aarch64_v0.2

The "make frpc" command yields a
build github.com/fatedier/frp/cmd/frpc: cannot load embed: malformed module path "embed": missing dot in f

@abidlabs
Copy link
Member

Fixed in: #9218

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants