PromtEngineer / localGPT

Chat with your documents on your local device using GPT models. No data leaves your device and 100% private.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

name 'compute_device' is not defined when --device_type cpu on Linux

g1ra opened this issue · comments

commented

I'm on Linux , desktop PC.
ingest.py is throwing me an error but I'm specifying the CPU as computing device . :

git clone https://github.com/PromtEngineer/localGPT
cd localGPT/
conda create -n localGPT python=3.10.0
conda activate localGPT
pip install -r requirements.txt
python ingest.py
python ingest.py --device_type cpu
(localGPT) myuser@dmini:~/AI/localGPT/localGPT$ python run_localGPT.py --show_sources                                        
2024-02-03 12:49:31,795 - INFO - run_localGPT.py:265 - Running on: cpu                                                    
2024-02-03 12:49:31,795 - INFO - run_localGPT.py:266 - Display Source Documents set to: True                              
2024-02-03 12:49:31,795 - INFO - run_localGPT.py:267 - Use history set to: False                                          
Traceback (most recent call last):                                                                                        
  File "/home/myuser/AI/localGPT/localGPT/run_localGPT.py", line 306, in <module>                                            
    main()                                                                                                                
  File "/home/myuser/anaconda3/envs/localGPT/lib/python3.10/site-packages/click/core.py", line 1157, in __call__             
    return self.main(*args, **kwargs)                                                                                     
  File "/home/myuser/anaconda3/envs/localGPT/lib/python3.10/site-packages/click/core.py", line 1078, in main                 
    rv = self.invoke(ctx)                                                                                                 
  File "/home/myuser/anaconda3/envs/localGPT/lib/python3.10/site-packages/click/core.py", line 1434, in invoke               
    return ctx.invoke(self.callback, **ctx.params)                                                                        
  File "/home/myuser/anaconda3/envs/localGPT/lib/python3.10/site-packages/click/core.py", line 783, in invoke                
    return __callback(*args, **kwargs)                                                                                    
  File "/home/myuser/AI/localGPT/localGPT/run_localGPT.py", line 273, in main                                                
    qa = retrieval_qa_pipline(device_type, use_history, promptTemplate_type=model_type)                                   
  File "/home/myuser/AI/localGPT/localGPT/run_localGPT.py", line 132, in retrieval_qa_pipline                                
    model_kwargs={"device": compute_device},                                                                              
NameError: name 'compute_device' is not defined                                                                           
(localGPT) myuser@dmini:~/AI/localGPT/localGPT$ python ingest.py --device_type cpu                                           
2024-02-03 12:49:37,607 - INFO - ingest.py:144 - Loading documents from /home/myuser/AI/localGPT/localGPT/SOURCE_DOCUMENTS   
Importing: sV_EN8.pdf                                                                                    
2024-02-03 12:49:37,614 - INFO - ingest.py:44 - Loading document batch                                                    
/home/myuser/AI/localGPT/localGPT/SOURCE_DOCUMENTS/sV_EN8.pdf loaded.                                       
                                                                                                                          
2024-02-03 12:49:39,148 - INFO - <frozen importlib._bootstrap>:241 - pikepdf C++ to Python logger bridge initialized      
2024-02-03 12:49:40,856 - INFO - ingest.py:153 - Loaded 1 documents from /home/myuser/AI/localGPT/localGPT/SOURCE_DOCUMENTS  
2024-02-03 12:49:40,856 - INFO - ingest.py:154 - Split into 11 chunks of text                                             
Traceback (most recent call last):                                                                                        
  File "/home/myuser/AI/localGPT/localGPT/ingest.py", line 198, in <module>                                                  
    main()                                                                                                                
  File "/home/myuser/anaconda3/envs/localGPT/lib/python3.10/site-packages/click/core.py", line 1157, in __call__             
    return self.main(*args, **kwargs)                                                                                     
  File "/home/myuser/anaconda3/envs/localGPT/lib/python3.10/site-packages/click/core.py", line 1078, in main                 
    rv = self.invoke(ctx)                                                                                                 
  File "/home/myuser/anaconda3/envs/localGPT/lib/python3.10/site-packages/click/core.py", line 1434, in invoke               
    return ctx.invoke(self.callback, **ctx.params)                                                                        
  File "/home/myuser/anaconda3/envs/localGPT/lib/python3.10/site-packages/click/core.py", line 783, in invoke                
    return __callback(*args, **kwargs)                                                                                    
  File "/home/myuser/AI/localGPT/localGPT/ingest.py", line 166, in main                                                      
    model_kwargs={"device": compute_device},                                                                              
NameError: name 'compute_device' is not defined                                                                           

You can change the compute_device into device_type in ingest.py and run_localGPT.py files.

model_kwargs={"device": compute_device}, to model_kwargs={"device": device_type}, everywhere

You can change the compute_device into device_type in ingest.py and run_localGPT.py files.

model_kwargs={"device": compute_device}, to model_kwargs={"device": device_type}, everywhere

Changing compute_device to device_type works for me, thanks @daniellefisla !

Glad it worked out, but it does make me question the quality of code in the main branch. 🤞

commented

thanks @daniellefisla worked for me too . I'm also wondering when compute_device introduced and why has not changed .

An issue should be filed for this, the commit 747a9b4 that implemented this change introduced some error to the codebase.

It was a bug, should be fixed now.