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

Cannot install package behind network proxy #1138

Open
1 of 5 tasks
jnzw opened this issue Jan 6, 2025 · 2 comments
Open
1 of 5 tasks

Cannot install package behind network proxy #1138

jnzw opened this issue Jan 6, 2025 · 2 comments
Labels
bug Something isn't working

Comments

@jnzw
Copy link

jnzw commented Jan 6, 2025

System Info

transformers v3.1.1
node v18.17.0

Environment/Platform

  • Website/web-app
  • Browser extension
  • Server-side (e.g., Node.js, Deno, Bun)
  • Desktop app (e.g., Electron)
  • Other (e.g., VSCode extension)

Description

Hi, I was trying to install chat-ui, which depends on @huggingface/transformers (v3.1.1) but encountered this issue related to network proxy settings.

$ npm install @huggingface/transformers
npm ERR! code 1
npm ERR! path /home/test/node_modules/onnxruntime-node
npm ERR! command failed
npm ERR! command sh -c node ./script/install
npm ERR! Downloading "https://github.com/microsoft/onnxruntime/releases/download/v1.20.1/onnxruntime-linux-x64-gpu-1.20.1.tgz"...
npm ERR! node:internal/deps/undici/undici:11576
npm ERR!     Error.captureStackTrace(err, this);
npm ERR!           ^
npm ERR!
npm ERR! TypeError: fetch failed
npm ERR!     at Object.fetch (node:internal/deps/undici/undici:11576:11)
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
npm ERR!   cause: ConnectTimeoutError: Connect Timeout Error
npm ERR!       at onConnectTimeout (node:internal/deps/undici/undici:8522:28)
npm ERR!       at node:internal/deps/undici/undici:8480:50
npm ERR!       at Immediate._onImmediate (node:internal/deps/undici/undici:8511:13)
npm ERR!       at process.processImmediate (node:internal/timers:476:21) {
npm ERR!     code: 'UND_ERR_CONNECT_TIMEOUT'
npm ERR!   }
npm ERR! }
npm ERR!
npm ERR! Node.js v18.17.0

The issue is due to onnxruntime-node (v1.20.1) not using HTTP_PROXY and HTTPS_PROXY environment variables in the post installation script, and it has been fixed in this PR: microsoft/onnxruntime#23232. User can set the GLOBAL_AGENT_HTTP_PROXY and GLOBAL_AGENT_HTTPS_PROXY env var to make the script use network proxy after the fix. Please update the dependency when new version of onnxruntime-node is released. Thanks

Reproduction

  1. Behind network proxy
  2. npm install @huggingface/transformers
@jnzw jnzw added the bug Something isn't working label Jan 6, 2025
@WenjiaoYue
Copy link

I am still encountering this problem despite setting the GLOBAL_AGENT_HTTP_PROXY, GLOBAL_AGENT_HTTPS_PROXY, https_proxy, and http_proxy environment variables. I have also tried installing the latest version, but the issue persists. Is there any way to resolve this? Thanks a lot!

@dmenezesgabriel
Copy link

Here is what have worked for me:

  1. Install onnxruntime-node
npm install onnxruntime-node --onnxruntime-node-install-cuda=skip
  1. Install huggingface/transformers.js
npm i @huggingface/transformers
  1. Download the binaries
ORT_VERSION=1.20.1
https://github.com/microsoft/onnxruntime/releases/download/v${ORT_VERSION}/onnxruntime-linux-x64-gpu-${ORT_VERSION}.tgz
  1. Extract the following binaries to "node_modules/onnxruntime-node/bin/napi-v3/
    linux/x64:
    • libonnxruntime_providers_tensorrt.so
    • libonnxruntime_providers_shared.so
    • libonnxruntime.so.${ORT_VERSION}
    • libonnxruntime_providers_cuda.so
import { ProxyAgent, setGlobalDispatcher } from "undici";
import { pipeline } from "@huggingface/transformers";
import "dotenv/config";

if (process.env.PROXY) {  //http://my-proxy:8080
  const token = `Basic ${btoa(`${process.env.USERNAME}:${process.env.PASSWORD}`)}`;

  const proxyAgent = new ProxyAgent({
    uri: env.PROXY,
    token,
    requestTls: { rejectUnauthorized: false },
  });

  setGlobalDispatcher(proxyAgent);
}

const pipe = await pipeline("sentiment-analysis");
const out = pipe("I love transformers!");

console.log(out);

References

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

3 participants