eliza icon indicating copy to clipboard operation
eliza copied to clipboard

Installation failed on node-llama-cpp postscript

Open salacoste opened this issue 11 months ago • 13 comments

installation process stucks during quick start guide steps, installation node-llama-cpp failed and then it stuck on node_modules/@discordjs/opus: Running install script...

Used node 23.3.0

The commit version is 77b5b7d8 v0.1.7-alpha.1

 77b5b7d8 v0.1.7-alpha.1 ● ?  pnpm install --no-frozen-lockfile  ✔  10161  21:41:18 Scope: all 47 workspace projects client |  WARN  Installing a dependency from a non-existent directory: /Users/r2d2/Documents/Code_Projects/eliza/client/@tanstack/router-plugin/vite packages/adapter-redis |  WARN  deprecated @types/[email protected] packages/client-discord |  WARN  deprecated @discordjs/[email protected] packages/client-slack |  WARN  deprecated @slack/[email protected] packages/core |  WARN  deprecated @types/[email protected] packages/plugin-node |  WARN  deprecated @cliqz/[email protected] packages/plugin-story |  WARN  deprecated @pinata/[email protected] packages/plugin-trustdb |  WARN  deprecated @types/[email protected]  WARN  34 deprecated subdependencies found: @cliqz/[email protected], @cliqz/[email protected], @cliqz/[email protected], @humanwhocodes/[email protected], @humanwhocodes/[email protected], @motionone/[email protected], @simplewebauthn/[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected]  WARN  Issues with peer dependencies found client ├─┬ @vitejs/plugin-react 4.3.3 │ └── ✕ unmet peer vite@"^4.2.0 || ^5.0.0": found 0.0.0 ├─┬ vite-plugin-top-level-await 1.4.4 │ └── ✕ unmet peer vite@>=2.8: found 0.0.0 └─┬ vite-plugin-wasm 3.3.0 └── ✕ unmet peer vite@"^2 || ^3 || ^4 || ^5": found 0.0.0

packages/client-lens └─┬ @lens-protocol/client 2.2.0 └─┬ @lens-protocol/gated-content 0.5.1 └─┬ @lit-protocol/node-client 2.1.62 ├─┬ @walletconnect/ethereum-provider 2.17.3 │ └─┬ @walletconnect/modal 2.7.0 │ ├─┬ @walletconnect/modal-core 2.7.0 │ │ └─┬ valtio 1.11.2 │ │ ├── ✕ missing peer react@>=16.8 │ │ └─┬ use-sync-external-store 1.2.0 │ │ └── ✕ missing peer react@"^16.8.0 || ^17.0.0 || ^18.0.0" │ └─┬ @walletconnect/modal-ui 2.7.0 │ └─┬ @walletconnect/modal-core 2.7.0 │ └── ✕ missing peer react@>=16.8 └─┬ @lit-protocol/auth-browser 2.1.62 └─┬ @walletconnect/ethereum-provider 2.17.3 └── ✕ missing peer react@>=16.8 Peer dependencies that should be installed: react@">=16.8.0 <17.0.0 || >=17.0.0 <18.0.0 || >=18.0.0 <19.0.0"

packages/core └─┬ @langchain/core 0.3.26 └─┬ zod-to-json-schema 3.24.1 └── ✕ unmet peer zod@^3.24.1: found 3.23.8

packages/plugin-0g └─┬ @0glabs/0g-ts-sdk 0.2.1 └── ✕ unmet peer [email protected]: found 6.13.4

packages/plugin-goat ├─┬ @goat-sdk/wallet-viem 0.1.3 │ └── ✕ unmet peer @goat-sdk/[email protected]: found 0.3.8 └─┬ @goat-sdk/plugin-coingecko 0.1.4 ├── ✕ unmet peer @goat-sdk/[email protected]: found 0.3.8 └── ✕ unmet peer [email protected]: found 2.21.53

Packages: +4705 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Progress: resolved 4088, reused 3922, downloaded 0, added 4705, done node_modules/@swc/core: Running postinstall script... node_modules/canvas: Running install script... node_modules/node-llama-cpp: Running postinstall script, failed in 1.6s node_modules/node-llama-cpp postinstall$ node ./dist/cli/cli.js postinstall └─ Failed in 1.6s at /Users/r2d2/Documents/Code_Projects/eliza/node_modules/node-llama-cpp node_modules/@discordjs/opus: Running install script...

salacoste avatar Dec 27 '24 18:12 salacoste

i was able sucessfully installed this release on old intel based mac, but struggle to make it works on Apple silicon (that's the one difference between these 2 systems, the rest like node version, pnpm and the rest were the same).

pnpm 9.15.1 were used for both, node 23+.

I'm keen to make it work on my main mac (Apple silicon), still curious if we can solve it.

salacoste avatar Dec 28 '24 16:12 salacoste

i have researched the question about cpp and found out the following:

npx --no node-llama-cpp inspect gpu

(node:46665) ExperimentalWarning: CommonJS module /Users/r2d2/.nvm/versions/node/v23.3.0/lib/node_modules/npm/node_modules/debug/src/node.js is loading ES Module /Users/r2d2/.nvm/versions/node/v23.3.0/lib/node_modules/npm/node_modules/supports-color/index.js using require().
Support for loading ES Module in require() is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
OS: macOS 22.3.0 (x64)
Node: 23.3.0 (x64)
TypeScript: 5.6.3
node-llama-cpp: 3.1.1

Metal: not supported by llama.cpp on Intel Macs
[1]    46665 illegal hardware instruction  npx --no node-llama-cpp inspect GPU

I have M2 Chip

salacoste avatar Dec 30 '24 13:12 salacoste

I have exactly the same problem

bkotrys avatar Dec 30 '24 15:12 bkotrys

I have a M4 machine and it works perfectly on my device with pnpm version being 9.15.0 and node version being 23.3.0. I was not able to reproduce the problem here.

Noveleader avatar Dec 30 '24 18:12 Noveleader

The problem seems to be explicitly related to M2 machines.

bkotrys avatar Dec 30 '24 22:12 bkotrys

have you found a solution?

haskell-monad avatar Jan 01 '25 16:01 haskell-monad

image_2025-01-01_13-45-03 guys helped me to catch an initial root cause of the problem, nvm installs x64 versions of nodeJs to arm system. They work fine unless some certain cpp methods and calls which were caused by this mismatch.

You need to check that you have the proper node version in your system otherwise

node -e "console.log(process.platform, process.arch)"                   
darwin arm64

I have reinstalled nodejs package natively in the system, remove nvm usage as it didn't support arm version of node.

but later I encountered with bunch of problems the package compatibility as some of them support only x64 architecture: like esbuild, rollup, sharp...

I was able to fix them by changing dependencies in package.json(s) on arm supported versions or sometimes just updated their versions up to the most recent.

But I'm stuck at sharp package with the following logs:


npm start      
 WARN  Unsupported engine: wanted: {"node":"23.3.0"} (current: {"node":"v23.5.0","pnpm":"9.15.1"})

> eliza@ start /Users/r2d2/Documents/Code_Projects/eliza
> pnpm --filter "@elizaos/agent" start --isRoot

.                                        |  WARN  Unsupported engine: wanted: {"node":"23.3.0"} (current: {"node":"v23.5.0","pnpm":"9.14.4"})
docs                                     |  WARN  Unsupported engine: wanted: {"node":"23.3.0"} (current: {"node":"v23.5.0","pnpm":"9.14.4"})

> @elizaos/[email protected] start /Users/r2d2/Documents/Code_Projects/eliza/agent
> node --loader ts-node/esm src/index.ts "--isRoot"

(node:8415) ExperimentalWarning: `--experimental-loader` may be removed in the future; instead use `register()`:
--import 'data:text/javascript,import { register } from "node:module"; import { pathToFileURL } from "node:url"; register("ts-node/esm", pathToFileURL("./"));'
(Use `node --trace-warnings ...` to show where the warning was created)
(node:8415) [DEP0180] DeprecationWarning: fs.Stats constructor is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
[ElizaLogger] Initializing with:
            isNode: true
            verbose: false
            VERBOSE env: undefined
            NODE_ENV: undefined
        
 ℹ INFORMATIONS
   Loading embedding settings: 
   {"OLLAMA_EMBEDDING_MODEL":"mxbai-embed-large"} 

 ℹ INFORMATIONS
   Loading character settings: 
   {"ARGV":["/usr/local/bin/node","/Users/r2d2/Documents/Code_Projects/eliza/agent/src/index.ts","--isRoot"],"CWD":"/Users/r2d2/Documents/Code_Projects/eliza/agent"} 

 ℹ INFORMATIONS
   Parsed settings: 
   {"USE_OPENAI_EMBEDDING_TYPE":"undefined","USE_OLLAMA_EMBEDDING_TYPE":"undefined","OLLAMA_EMBEDDING_MODEL":"mxbai-embed-large"} 

using deprecated parameters for the initialization function; pass a single object instead
/Users/r2d2/Documents/Code_Projects/eliza/node_modules/sharp/lib/sharp.js:113
  throw new Error(help.join('\n'));
        ^

**_Error: Could not load the "sharp" module using the darwin-arm64 runtime
Possible solutions:
- Ensure optional dependencies can be installed:
    npm install --include=optional sharp
- Ensure your package manager supports multi-platform installation:
    See https://sharp.pixelplumbing.com/install#cross-platform
- Add platform-specific dependencies:
    npm install --os=darwin --cpu=arm64 sharp_**
- Consult the installation documentation:
    See https://sharp.pixelplumbing.com/install
    at Object.<anonymous> (/Users/r2d2/Documents/Code_Projects/eliza/node_modules/sharp/lib/sharp.js:113:9)
    at Module._compile (node:internal/modules/cjs/loader:1740:14)
    at Object..js (node:internal/modules/cjs/loader:1905:10)
    at Module.load (node:internal/modules/cjs/loader:1474:32)
    at Function._load (node:internal/modules/cjs/loader:1286:12)
    at TracingChannel.traceSync (node:diagnostics_channel:322:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:234:24)
    at Module.require (node:internal/modules/cjs/loader:1496:12)
    at require (node:internal/modules/helpers:135:16)
    at Object.<anonymous> (/Users/r2d2/Documents/Code_Projects/eliza/node_modules/sharp/lib/constructor.js:10:1)

Node.js v23.5.0
/Users/r2d2/Documents/Code_Projects/eliza/agent:
 ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @elizaos/[email protected] start: `node --loader ts-node/esm src/index.ts "--isRoot"`
Exit status 1
 ELIFECYCLE  Command failed with exit code 1.

I tried different options and things to come over the problem but was unsuccessful so far.

Any ideas on that though?

by the way,it worth to make the package list more compatible across different platforms. some versions were used old one which doesn't have such compatability.

salacoste avatar Jan 01 '25 20:01 salacoste

Same problem here with a M2 Pro chip

deblanco avatar Jan 05 '25 17:01 deblanco

The new apple silicon is ARM based so very different from the intel one. Anyway i run on both M2 and M4 the main repo with no issues is even better than on Linux. Think is worth investigate but is not a bug of the repo. I keep it open and i wait your feedback on it.

AIFlowML avatar Jan 06 '25 07:01 AIFlowML

I'm also encountering this illegal hardware instruction issue on an M1 darwin arm64 I've tried running in Rosetta x86_64 arch as well

brittanylcrocker avatar Jan 06 '25 11:01 brittanylcrocker

Without using Rosetta the installation and build works but then it won't start because it says it needs x86_64 and even if I turn Rosetta back on it still says it needs x86_64 (because if the installation with arm I guess)

creazy231 avatar Jan 07 '25 10:01 creazy231

I'm using an M1 Mac and was able to install the dependencies and build the repo using arm64

Steps: Confirm you are using arm

arch
expected output -> arm64

Reinstall node for arm64

nvm install stable

Confirm arm version of node is installed

node -e 'console.log(process.arch)’
expected output -> arm64
rm -rf node_modules
rm -rf pnpm-lock.yaml

I had to reinstall pnpm after reinstalling node

brew install pnpm

Then proceed to install deps and build

 pnpm install --no-frozen-lockfile  
pnpm build

I also followed the steps here - https://node-llama-cpp.withcat.ai/guide/Metal

Hope this helps someone!

brittanylcrocker avatar Jan 07 '25 11:01 brittanylcrocker

I had the same issue with my M1 Pro which was always getting stuck on llama installation failed. Steps to fix it -

  • Check your arch ( probably you are on rosetta ) Go to your terminal and type

arch

If it returns I386 it means it's on rosetta and installation might be giving issues because of that.

Change your architecture to arm by using this command

$env /usr/bin/arch -arm64 /bin/zsh ---login

if you type arch again it should give your arm64 now instead of i386

Now, next step is to install NVM for it -

nvm install stable

then

nvm use stable

then make sure you are using correct nvm by using this command

node -e 'console.log(process.arch)'

it should return arm64 so it means you are on correct nvm now.

now you can go to the codebase and use rm -rf node_modules rm -rf pnpm-lock.yaml

And then install packages by using pnpm install --no-frozen-lockfile

Make sure you have xcode command line tools installed as a perquisite.

mohs1n avatar Jan 08 '25 12:01 mohs1n

This problem seems to be gone for me, maybe they updated the dep. Now I'm stuck in this new one when I run pnpm build 😓

CLI Target: node18
@elizaos/core:build: CLI Cleaning output folder
@elizaos/core:build: ESM Build start
@elizaos/core:build: ✘ [ERROR] Could not resolve "@huggingface/transformers"
@elizaos/core:build: 
@elizaos/core:build:     src/generation.ts:17:30:
@elizaos/core:build:       17 │ import { AutoTokenizer } from "@huggingface/transformers";
@elizaos/core:build:          ╵                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~
@elizaos/core:build: 
@elizaos/core:build:   The Yarn Plug'n'Play manifest forbids importing "@huggingface/transformers" here because it's not
@elizaos/core:build:   listed as a dependency of this package:
@elizaos/core:build: 
@elizaos/core:build:     ../../../../.pnp.cjs:48:31:
@elizaos/core:build:       48 │         "packageDependencies": [\
@elizaos/core:build:          ╵                                ~~
@elizaos/core:build: 
@elizaos/core:build:   You can mark the path "@huggingface/transformers" as external to exclude it from the bundle, which
@elizaos/core:build:   will remove this error and leave the unresolved path in the bundle.
@elizaos/core:build: 
@elizaos/core:build: ESM Build failed
@elizaos/core:build: Error: Build failed with 1 error:
@elizaos/core:build: src/generation.ts:17:30: ERROR: Could not resolve "@huggingface/transformers"
image

Help please

deblanco avatar Jan 10 '25 23:01 deblanco

I completely uninstalled my M1 homebrew (based on x86), reinstalled an arm version of homebrew, then reinstalled the arm version of node, and then configured iTerm2 to use arm startup (install the latest version of iTerm2, which is arm by default), Then I can successfully build eliza

haskell-monad avatar Jan 11 '25 01:01 haskell-monad

I did nothing like that and i installed on all macs. I think all have serioues permission problems.

AIFlowML avatar Jan 12 '25 11:01 AIFlowML

This problem seems to be gone for me, maybe they updated the dep. Now I'm stuck in this new one when I run pnpm build 😓

CLI Target: node18
@elizaos/core:build: CLI Cleaning output folder
@elizaos/core:build: ESM Build start
@elizaos/core:build: ✘ [ERROR] Could not resolve "@huggingface/transformers"
@elizaos/core:build: 
@elizaos/core:build:     src/generation.ts:17:30:
@elizaos/core:build:       17 │ import { AutoTokenizer } from "@huggingface/transformers";
@elizaos/core:build:          ╵                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~
@elizaos/core:build: 
@elizaos/core:build:   The Yarn Plug'n'Play manifest forbids importing "@huggingface/transformers" here because it's not
@elizaos/core:build:   listed as a dependency of this package:
@elizaos/core:build: 
@elizaos/core:build:     ../../../../.pnp.cjs:48:31:
@elizaos/core:build:       48 │         "packageDependencies": [\
@elizaos/core:build:          ╵                                ~~
@elizaos/core:build: 
@elizaos/core:build:   You can mark the path "@huggingface/transformers" as external to exclude it from the bundle, which
@elizaos/core:build:   will remove this error and leave the unresolved path in the bundle.
@elizaos/core:build: 
@elizaos/core:build: ESM Build failed
@elizaos/core:build: Error: Build failed with 1 error:
@elizaos/core:build: src/generation.ts:17:30: ERROR: Could not resolve "@huggingface/transformers"
image Help please

I have the exact same error when trying to run pnpm build on the latest branch. At time of writing I'm on v0.1.8+build.1

michaelgreen06 avatar Jan 13 '25 07:01 michaelgreen06

Hey, 3 days later, I ended up fixing it. I removed from my user root folder the file .pnp.cjs, it seems that it does some conflict with "yarn berry"

rm -rf ~/.pnp.cjs

after it, on the Eliza folder:

rm -rf node_modules/ && pnpm install --no-frozen-lockfile && pnpm build

and voilá, it compiled, and I was able to start the project

Happy coding!

deblanco avatar Jan 13 '25 15:01 deblanco

So I had the same issue:

node_modules/node-llama-cpp postinstall$ node ./dist/cli/cli.js postinstall
└─ Failed in 1.6s at /Applications/ccc/thing/bot/node_modules/node-llama-cpp
OS: macOS 24.1.0 (x64)
Node: 23.6.0 (x64)
TypeScript: 5.7.3
node-llama-cpp: 3.1.1

Metal: not supported by llama.cpp on Intel Macs

CPU model: Apple M2 Max

But I was able to fix the issue by following the directions in this comment: https://github.com/elizaOS/eliza/issues/1503#issuecomment-2575003206

In particular the issue was that the arm version of node wasn't running.

jbelelieu avatar Jan 16 '25 15:01 jbelelieu

rm -rf ~/.pnpn.cjs

@deblanco there is no ~/.pnpn.cjs file in error, maybe ~/.pnp.cjs ?

correct commands

rm -rf ~/.pnp.cjs

then

rm -rf node_modules/ && pnpm install --no-frozen-lockfile && pnpm build

and it compiled successfully ✅

veebull avatar Jan 18 '25 11:01 veebull

rm -rf ~/.pnpn.cjs

@deblanco there is no ~/.pnpn.cjs file in error, maybe ~/.pnp.cjs ?

correct commands

rm -rf ~/.pnp.cjs then

rm -rf node_modules/ && pnpm install --no-frozen-lockfile && pnpm build

yes, you are right!

deblanco avatar Jan 18 '25 11:01 deblanco