h2ogpt
h2ogpt copied to clipboard
SyntaxError: invalid syntax
Hi there,
I installed everything with the CPU method on my Linux 20 server.
After
python generate.py --base_model =gptj --score_model=None
I received:
File "generate.py", line 50 load_8bit: bool = False, ^ SyntaxError: invalid syntax
The PC is headless with a build in graphic card. Mybe that is the reason? Or do I miss something? I am new to all of that and doing copy&paste :-)
Thanks Meiko
Hi @bibi-b , it must be something super basic, but I cannot tell from above what was done.
But roughly speaking, sounds like you didn't install any python environment, at least not a python 3.10 one we require.
Perhaps this will help? https://github.com/h2oai/h2ogpt/blob/main/INSTALL.md#install-python-environment
Thanks. I started from scratch, installed the python environment as linked above and am now running into this issue:
Failed to build hnswlib pycocotools ERROR: Could not build wheels for hnswlib, pycocotools, which is required to install pyproject.toml-based projects
(when executing pip install -r reqs_optional/requirements_optional_langchain.txt)
I already tried: conda install -c conda-forge hnswlib and conda install -c conda-forge pycocotools
Any ideas?
Thanks
@bibi-b Can you share the full error? The lines you shared only say what the final error was, not why, while the rest may indicate why.
@pseudotensor Sure and thanks!
Building wheels for collected packages: hnswlib, pycocotools Building wheel for hnswlib (pyproject.toml) ... error error: subprocess-exited-with-error
× Building wheel for hnswlib (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [21 lines of output] running bdist_wheel running build running build_ext creating tmp x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.8 -c /tmp/tmpd8t0f1vv.cpp -o tmp/tmpd8t0f1vv.o -std=c++14 x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/usr/include/python3.8 -c /tmp/tmp_6sq4r51.cpp -o tmp/tmp_6sq4r51.o -fvisibility=hidden building 'hnswlib' extension creating build creating build/temp.linux-x86_64-cpython-38 creating build/temp.linux-x86_64-cpython-38/python_bindings x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/pip-build-env-wwzl3pw9/overlay/lib/python3.8/site-packages/pybind11/include -I/tmp/pip-build-env-wwzl3pw9/overlay/lib/python3.8/site-packages/numpy/core/include -I./hnswlib/ -I/usr/include/python3.8 -c ./python_bindings/bindings.cpp -o build/temp.linux-x86_64-cpython-38/./python_bindings/bindings.o -O3 -march=native -fopenmp -DVERSION_INFO="0.7.0" -std=c++14 -fvisibility=hidden In file included from /tmp/pip-build-env-wwzl3pw9/overlay/lib/python3.8/site-packages/pybind11/include/pybind11/detail/../attr.h:13, from /tmp/pip-build-env-wwzl3pw9/overlay/lib/python3.8/site-packages/pybind11/include/pybind11/detail/class.h:12, from /tmp/pip-build-env-wwzl3pw9/overlay/lib/python3.8/site-packages/pybind11/include/pybind11/pybind11.h:13, from /tmp/pip-build-env-wwzl3pw9/overlay/lib/python3.8/site-packages/pybind11/include/pybind11/functional.h:12, from ./python_bindings/bindings.cpp:2: /tmp/pip-build-env-wwzl3pw9/overlay/lib/python3.8/site-packages/pybind11/include/pybind11/detail/../detail/common.h:266:10: fatal error: Python.h: No such file or directory 266 | #include <Python.h> | ^~~~~~~~~~ compilation terminated. error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1 [end of output]
note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for hnswlib Building wheel for pycocotools (pyproject.toml) ... error error: subprocess-exited-with-error
× Building wheel for pycocotools (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [62 lines of output] running bdist_wheel running build running build_py creating build creating build/lib.linux-x86_64-cpython-38 creating build/lib.linux-x86_64-cpython-38/pycocotools copying pycocotools/mask.py -> build/lib.linux-x86_64-cpython-38/pycocotools copying pycocotools/init.py -> build/lib.linux-x86_64-cpython-38/pycocotools copying pycocotools/cocoeval.py -> build/lib.linux-x86_64-cpython-38/pycocotools copying pycocotools/coco.py -> build/lib.linux-x86_64-cpython-38/pycocotools running build_ext cythoning pycocotools/_mask.pyx to pycocotools/_mask.c building 'pycocotools._mask' extension creating build/temp.linux-x86_64-cpython-38 creating build/temp.linux-x86_64-cpython-38/common creating build/temp.linux-x86_64-cpython-38/pycocotools x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/pip-build-env-c5vz_r7y/overlay/lib/python3.8/site-packages/numpy/core/include -I./common -I/usr/include/python3.8 -c ./common/maskApi.c -o build/temp.linux-x86_64-cpython-38/./common/maskApi.o -Wno-cpp -Wno-unused-function -std=c99 ./common/maskApi.c: In function ‘rleToBbox’: ./common/maskApi.c:151:32: warning: unused variable ‘xp’ [-Wunused-variable] 151 | uint h, w, xs, ys, xe, ye, xp, cc; siz j, m; | ^~ ./common/maskApi.c: In function ‘rleFrPoly’: ./common/maskApi.c:197:3: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 197 | for(j=0; j<k; j++) x[j]=(int)(scalexy[j2+0]+.5); x[k]=x[0]; | ^~~ ./common/maskApi.c:197:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 197 | for(j=0; j<k; j++) x[j]=(int)(scalexy[j2+0]+.5); x[k]=x[0]; | ^ ./common/maskApi.c:198:3: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation] 198 | for(j=0; j<k; j++) y[j]=(int)(scalexy[j2+1]+.5); y[k]=y[0]; | ^~~ ./common/maskApi.c:198:54: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’ 198 | for(j=0; j<k; j++) y[j]=(int)(scalexy[j2+1]+.5); y[k]=y[0]; | ^ ./common/maskApi.c: In function ‘rleToString’: ./common/maskApi.c:243:7: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 243 | if(more) c |= 0x20; c+=48; s[p++]=c; | ^~ ./common/maskApi.c:243:27: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 243 | if(more) c |= 0x20; c+=48; s[p++]=c; | ^ ./common/maskApi.c: In function ‘rleFrString’: ./common/maskApi.c:251:3: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation] 251 | while( s[m] ) m++; cnts=malloc(sizeof(uint)*m); m=0; | ^~~~~ ./common/maskApi.c:251:22: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’ 251 | while( s[m] ) m++; cnts=malloc(sizeof(uint)*m); m=0; | ^~~~ ./common/maskApi.c:259:5: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] 259 | if(m>2) x+=(long) cnts[m-2]; cnts[m++]=(uint) x; | ^~ ./common/maskApi.c:259:34: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ 259 | if(m>2) x+=(long) cnts[m-2]; cnts[m++]=(uint) x; | ^~~~ x86_64-linux-gnu-gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -I/tmp/pip-build-env-c5vz_r7y/overlay/lib/python3.8/site-packages/numpy/core/include -I./common -I/usr/include/python3.8 -c pycocotools/_mask.c -o build/temp.linux-x86_64-cpython-38/pycocotools/_mask.o -Wno-cpp -Wno-unused-function -std=c99 pycocotools/_mask.c:6:10: fatal error: Python.h: No such file or directory 6 | #include "Python.h" | ^~~~~~~~~~ compilation terminated. /tmp/pip-build-env-c5vz_r7y/overlay/lib/python3.8/site-packages/Cython/Compiler/Main.py:369: FutureWarning: Cython directive 'language_level' not set, using 2 for now (Py2). This will change in a later release! File: /tmp/pip-install-8us9fayn/pycocotools_58d312b7d46f4a32b49df050222d27b9/pycocotools/_mask.pyx tree = Parsing.p_module(s, pxd, full_module_name) error: command '/usr/bin/x86_64-linux-gnu-gcc' failed with exit code 1 [end of output]
note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for pycocotools Failed to build hnswlib pycocotools ERROR: Could not build wheels for hnswlib, pycocotools, which is required to install pyproject.toml-based projects
Hi @bibi-b , a couple things are off:
- The above refers to python 3.8, while we require python 3.10
- The above uses system python in
/usr/include/python3.8
and other places, while normal instructions use an isolated conda environment
It's like you are still not using the actual conda environment from https://github.com/h2oai/h2ogpt/blob/main/docs/INSTALL.md#install-python-environment
Can you confirm the outputs mentioned there, like from python --version
and python -c "import os, sys ; print('hello world')"
?
Hi @pseudotensor , thanks a lot for your help. Here are some outputs:
` meiko@SERVER-LINUX:~$ conda activate
(base) meiko@SERVER-LINUX:~$ python -V Python 3.10.11
(base) meiko@SERVER-LINUX:~$ python -c "import os, sys ; print('hello world')" hello world
(base) meiko@SERVER-LINUX:~$ which python /home/meiko/miniconda3/bin/python
(base) meiko@SERVER-LINUX:~$ conda activate h2ogpt
(h2ogpt) meiko@SERVER-LINUX:~$ which python /home/meiko/miniconda3/envs/h2ogpt/bin/python
(h2ogpt) meiko@SERVER-LINUX:~$ python -c "import os, sys ; print('hello world')" hello world `
@pseudotensor Ha! The solution is to use pip3 instead. So
pip3 install -r reqs_optional/requirements_optional_langchain.txt
is working. ;-)
Hmm, interesting. In every system I've been on, installing python=3.10 would mean "pip" would be from that environment, not some random environment. Maybe your $PATH has some system stuff as higher priority than conda.
I'll add to docs this suggestion.