Solve the problem of slow download speed or failure of git and huggingface projects

git clone project error

For example, use git clone to download the project:

git clone https://github.com/ChuRuaNh0/FastSam_Awsome_TensorRT.git

Sometimes the following error will be reported:

fatal: unable to access 'https://github.com/xxx.git/': Failed to connect to github.com port 443 after 21085 ms: Couldn't connect to server
Insert image description here
fatal: unable to access 'https://github.com/xxx.git/': Recv failure: Connection was reset
Insert image description here
This is an error. If a proxy is enabled, There is a high probability that there is a problem with the proxy. If the proxy is not turned on, it is a problem connecting to git. The simplest solution is to turn off the proxy if there is one. If you have not turned on the proxy, try a few more times to see if it can succeed.
Insert image description here
If you can't download it after turning it off or trying several times, you have to think of another way, such as using Code Cloud as a bridge.
Gitee is a domestic code hosting platform similar to GitHub. It provides code hosting services, project collaboration, code review, issue tracking and other functions based on Git version control.

  1. Code hosting: You can create a public or private code repository to facilitate team collaboration and version control.
  2. Project management: Provides project management tools, including issue tracking, wiki, task list, etc., to facilitate team collaboration and project management.
  3. Code quality management: Supports functions such as online code viewing, code inspection, pull request (Pull Request), etc., which helps to improve code quality and cooperative development.
  4. Permission management: You can flexibly set warehouse access permissions, member management, etc.
  5. Continuous integration and deployment (CI/CD): Supports continuous integration and automated deployment, and can integrate multiple CI/CD tools.
  6. Community and communication: Provide user communities, Q&A, forums and other communication platforms to facilitate interactive communication among developers.

First register an account. After the registration is completed, create a new warehouse:
Insert image description here
Select the import project and paste the address of the cloned project on git:

Insert image description here

Select "Import from URL" and then select Import. The import will be completed in less than a minute.
Insert image description here
After the import is completed, you can use git clone to download the project code:
Insert image description here

git clone https://gitee.com/matt45m/human.git

Download speed takes off directly:
Insert image description here

Problem with huggingface not being able to connect to the server

fatal: unable to access ‘https://huggingface.co/csukuangfj/xxxxxx/’: Failed to connect to huggingface.co port 443 after 21054 ms: Couldn’t connect to server
Insert image description here

Code download

Install dependencies

pip install pycrawlers

Write code

from pycrawlers import huggingface

hg = huggingface()

# 1.批量下载
urls = ['https://huggingface.co/csukuangfj/sherpa-ncnn-conv-emformer-transducer-2022-12-06',
        'xxxx']
           
# 默认保存位置在当前脚本所在文件夹 ./
hg.get_batch_data(urls)

# 2.单个下载
url = 'https://huggingface.co/csukuangfj/sherpa-ncnn-conv-emformer-transducer-2022-12-06'

hg.get_data(url)

Download directly
You can also download directly from the huggingface address of the model:
Insert image description here

command line agent

If you use magic to access the Internet, you can use the command line code to solve all the problems of the command line being unable to connect to the external network:

#建议socks5 和http 都配置一下

#配置socks5
git config --global http.proxy socks5 127.0.0.1:xxxx
git config --global https.proxy socks5 127.0.0.1:xxxx

#配置http
git config --global http.proxy 127.0.0.1:xxxx
git config --global https.proxy 127.0.0.1:xxxx

# 主机号 127.0.0.1是使用的魔法上网的主机号
# 端口号 xxxx 指魔法上网的端口号,软件设置里查看,在魔法上网的配置里面可以找到

Insert image description here

View settings:

git config --global --get http.proxy
git config --global --get https.proxy

Insert image description here

Cancellation method:

git config --global --unset http.proxy
git config --global --unset https.proxy

Insert image description here

Guess you like

Origin blog.csdn.net/matt45m/article/details/134637475