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

Wondering #5

Open
wetfox opened this issue Mar 12, 2024 · 17 comments
Open

Wondering #5

wetfox opened this issue Mar 12, 2024 · 17 comments

Comments

@wetfox
Copy link

wetfox commented Mar 12, 2024

Is there ANY way to run this on a Windows? For the love of me I can't get make commands to work in windows, and i've tried Linux Lite on a flash drive but couldn't get the NVidia drivers running.
If you could give me any pointers I'd be so grateful

@Dunky-Z
Copy link

Dunky-Z commented Mar 16, 2024

Because this project requires Nvidia driver support, if your computer doesn’t have an NVIDIA graphics card, then I might not be able to help you. If you solve the graphics card issue, you can use WSL2 to run this project on Windows. I just successfully ran this project on WSL2 yesterday, so I can offer some advice.

  1. Because Docker support is required, you need to install Docker Desktop on Windows. After downloading the repository, you can compile the docker image with make build. The final image is quite large, about 17GB, so please be patient while it builds.
  2. There are some minor issues in the project, such as incorrect arguments for the get_languages function, lack of support for displaying Chinese characters, incorrect versions of OpenAI's PyPI package, etc., and I will submit some PRs (pull requests) to fix these issues later on.

If you also plan to use WSL2 for running the project and encounter any problems during deployment, feel free to reply to this ISSUE. Maybe I have come across similar issues before.

@wetfox
Copy link
Author

wetfox commented Mar 16, 2024

Thank you so much man! I've struggled with this for 20+ hours and have gotten far, but now I'm really locked on this current error..
I've built the docker desktop and docker image, have NVIDIA and WSL2, made the build. But the docker container makes an error and closes after 15 sec because of the "incorrect versions of OpenAI's PyPI package" that you are referring to. I can post the error code but I think this is the one you're talking about.
How did you fix that one?

@wetfox
Copy link
Author

wetfox commented Mar 16, 2024

"ImportError: cannot import name 'OpenAi' from 'openai' (/usr/local/lib/python3.10/dist-packages/openai/init.py)"

@Dunky-Z
Copy link

Dunky-Z commented Mar 16, 2024

Hahaha, I've encountered this problem. The default installed version of openai is the 0.1x.x version, which is too outdated, as the latest versions are already at 1.14.x. There's a significant difference between the default installation and the current versions. I manually upgraded openai in the Dockerfile:

RUN pip install -r requirements.txt
RUN pip install "git+https://github.com/facebookresearch/detectron2.git"
# Added this line
RUN pip uninstall openai -y && pip install openai --upgrade

Perhaps you could also modify requirements.txt to specify the version to solve the issue, but I haven't tried that.

openai==1.14.1

@wetfox
Copy link
Author

wetfox commented Mar 17, 2024

Huh. I've just tried both those methods and it comes up with the same error. Is there any other way to do it?

@Dunky-Z
Copy link

Dunky-Z commented Mar 17, 2024

After you modified the Dockerfile, did you run make build again? I've reviewed all my changes and there's no alteration elsewhere. Normally, after upgrading the openai package, the error should not occur anymore.

There might be one thing that is slightly different because I am in China, I usually switch the PyPI registry to one within China. This might differ from your registry since different registries might have different versions of packages available. Can you confirm if the version of the openai package after upgrading is 1.14?

  1. How to confirm the package version?
    If you can enter the container, you can query it with a command: pip show openai. Since I couldn't find a way to enter the container – because it automatically exits after each run or doesn't allow access to the command line – I can only verify during the docker image build process. My method is to require a confirmation input y when installing openai; I don't provide the -y parameter so the image build will fail, prompting me the current version and the upgraded version.
RUN pip uninstall openai && pip install openai --upgrade
  1. How to change the registry

You can search for an available registry and add a pip.conf file in the root directory of the current project.

# pip.conf
[global]
index = http://xxx
index-url = http://xxx/simple
trusted-host =  xxx

Then modify the docker image’s PyPi registry:

COPY pip.conf /etc/pip.conf
COPY pip.conf /root/.pip/pip.conf

@wetfox
Copy link
Author

wetfox commented Mar 19, 2024

Hmm, now I'm getting this error in docker?

/usr/local/lib/python3.10/dist-packages/onnxruntime/capi/onnxruntime_inference_collection.py:69: UserWarning: Specified provider 'CUDAExecutionProvider' is not in available provider names.Available providers: 'AzureExecutionProvider, CPUExecutionProvider'
2024-03-19 15:50:17 warnings.warn(
2024-03-19 15:50:18 Traceback (most recent call last):
2024-03-19 15:50:18 File "/app/server.py", line 249, in
2024-03-19 15:50:18 translate_api = TranslateApi()
2024-03-19 15:50:18 File "/app/server.py", line 77, in init
2024-03-19 15:50:18 gradioapp = create_gradio_app(translator.get_languages())
2024-03-19 15:50:18 TypeError: TranslateOpenAIGPT.get_languages() takes 0 positional arguments but 1 was given

@Dunky-Z
Copy link

Dunky-Z commented Mar 19, 2024

Modify according to the following diff content, and there is no need to recompile the docker image. After modification, just make run

--- a/modules/translate/openai_gpt.py
+++ b/modules/translate/openai_gpt.py
@@ -97,11 +97,12 @@ langs = [
 class TranslateOpenAIGPT(TranslateBase):
     def init(self, cfg: dict):
         self.client = OpenAI(api_key=cfg['openai_api_key'])
-    def get_languages():
+    def get_languages(self):

@wetfox
Copy link
Author

wetfox commented Mar 19, 2024

Dude you are amazing, thank you so much.
Now the docker exits because of this error, did you encounter that as well?
File "/app/modules/translate/openai_gpt.py", line 108, in translate
2024-03-20 00:44:38 response = openai.Completion.create(
2024-03-20 00:44:38 File "/usr/local/lib/python3.10/dist-packages/openai/lib/_old_api.py", line 39, in call
2024-03-20 00:44:38 raise APIRemovedInV1(symbol=self._symbol)
2024-03-20 00:44:38 openai.lib._old_api.APIRemovedInV1:
2024-03-20 00:44:38
2024-03-20 00:44:38 You tried to access openai.Completion, but this is no longer supported in openai>=1.0.0 - see the README at https://github.com/openai/openai-python for the API.
2024-03-20 00:44:38
2024-03-20 00:44:38 You can run openai migrate to automatically upgrade your codebase to use the 1.0.0 interface.

@Dunky-Z
Copy link

Dunky-Z commented Mar 20, 2024

You must have modified the source code, as the openai package you're using is different from mine; thus, I haven't encountered the program error that you mentioned, sorry.
This is the interface that I'm using, which differs from yours. You still need to consider resolving the issue with the version of the openai python package.

response = self.client.chat.completions.create

@wetfox
Copy link
Author

wetfox commented Mar 25, 2024

Dunky you are the MVP. I didn't get to use it on Windows, can't get it to work. But I've installed ubuntu and now it's running.
Thank you so much for your help, truly appreciated.

Some pages are making a ZeroDivisionError: Division by zero though, so it's not flawless. I only get it on some pages, so I'm guessing it's something with this:
font_size = height / line_cnt

@Dunky-Z
Copy link

Dunky-Z commented Mar 25, 2024

I've also encountered this ZeroDivisionError. You can add a simple check before the code font_size = height / line_cnt. If line_cnt is 0, then just return the default font configuration.

if line_cnt == 0:
    return 'TimesNewRoman.ttf', font_size, ygain
font_size = height / line_cnt

@wetfox
Copy link
Author

wetfox commented Mar 25, 2024

You are literally the man (or woman)!
It's a bit weird that it exports to pictures with no text that can be edited - how do you process the file after for errors and stuff? Another image OCR and then export or..

@Dunky-Z
Copy link

Dunky-Z commented Mar 26, 2024

Thank you, I'm glad I could help. I'm male by the way. Currently, my need is simply for reading the literature; there is no requirement to edit the text. If editing were necessary, then using another OCR tool would indeed be the only option.

@spookey0188
Copy link

spookey0188 commented Apr 15, 2024

Because this project requires Nvidia driver support, if your computer doesn’t have an NVIDIA graphics card, then I might not be able to help you. If you solve the graphics card issue, you can use WSL2 to run this project on Windows. I just successfully ran this project on WSL2 yesterday, so I can offer some advice.

  1. Because Docker support is required, you need to install Docker Desktop on Windows. After downloading the repository, you can compile the docker image with make build. The final image is quite large, about 17GB, so please be patient while it builds.
  2. There are some minor issues in the project, such as incorrect arguments for the get_languages function, lack of support for displaying Chinese characters, incorrect versions of OpenAI's PyPI package, etc., and I will submit some PRs (pull requests) to fix these issues later on.

If you also plan to use WSL2 for running the project and encounter any problems during deployment, feel free to reply to this ISSUE. Maybe I have come across similar issues before.

Hey Dunky. I'm encountering this error/warning when translating a PDF file from Arabic to English on Windows WSL Kali linux distro build on a RTX 4070 after following all the necessary steps. The error I get is this:

unknown: figure
232it [05:15,  1.34s/it]/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:460: UserWarning: torch.utils.checkpoint: please pass in use_reentrant=True or use_reentrant=False explicitly. The default value of use_reentrant will be updated to be False in the future. To maintain current behavior, pass use_reentrant=True. It is recommended that you use use_reentrant=False. Refer to docs for more details on the differences between the two variants.
  warnings.warn(
/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:90: UserWarning: None of the inputs have requires_grad=True. Gradients will be None
  warnings.warn(
0it [00:00, ?it/s]
0it [00:00, ?it/s]
233it [05:17,  1.34s/it]/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:460: UserWarning: torch.utils.checkpoint: please pass in use_reentrant=True or use_reentrant=False explicitly. The default value of use_reentrant will be updated to be False in the future. To maintain current behavior, pass use_reentrant=True. It is recommended that you use use_reentrant=False. Refer to docs for more details on the differences between the two variants.
  warnings.warn(
/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:90: UserWarning: None of the inputs have requires_grad=True. Gradients will be None
  warnings.warn(
1it [00:00, 48210.39it/s]
1it [00:00, 91180.52it/s]
0it [00:00, ?it/s]

Have you encountered this warning? What's the cause of this and is there a fix?

@Dunky-Z
Copy link

Dunky-Z commented Apr 15, 2024

Sorry, I have not encountered this error before and may not be able to help you. Could you please provide more error logs to facilitate troubleshooting?

# This line is the reason for the error, but with only one line it cannot be determined.
# Please check the logs above this line.
unknown: figure

# The following lines are warning messages, 
# and will not cause the program to terminate. 
# However, in conjunction with the error message "unknown: figure", 
# there may be an issue with processing images in the PDF.
232it [05:15,  1.34s/it]/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:460: UserWarning: torch.utils.checkpoint: please pass in use_reentrant=True or use_reentrant=False explicitly. The default value of use_reentrant will be updated to be False in the future. To maintain current behavior, pass use_reentrant=True. It is recommended that you use use_reentrant=False. Refer to docs for more details on the differences between the two variants.
  warnings.warn(
/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:90: UserWarning: None of the inputs have requires_grad=True. Gradients will be None
  warnings.warn(
0it [00:00, ?it/s]
0it [00:00, ?it/s]
233it [05:17,  1.34s/it]/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:460: UserWarning: torch.utils.checkpoint: please pass in use_reentrant=True or use_reentrant=False explicitly. The default value of use_reentrant will be updated to be False in the future. To maintain current behavior, pass use_reentrant=True. It is recommended that you use use_reentrant=False. Refer to docs for more details on the differences between the two variants.
  warnings.warn(
/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:90: UserWarning: None of the inputs have requires_grad=True. Gradients will be None
  warnings.warn(
1it [00:00, 48210.39it/s]
1it [00:00, 91180.52it/s]
0it [00:00, ?it/s]

@spookey0188
Copy link

Sorry, I have not encountered this error before and may not be able to help you. Could you please provide more error logs to facilitate troubleshooting?

# This line is the reason for the error, but with only one line it cannot be determined.
# Please check the logs above this line.
unknown: figure

# The following lines are warning messages, 
# and will not cause the program to terminate. 
# However, in conjunction with the error message "unknown: figure", 
# there may be an issue with processing images in the PDF.
232it [05:15,  1.34s/it]/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:460: UserWarning: torch.utils.checkpoint: please pass in use_reentrant=True or use_reentrant=False explicitly. The default value of use_reentrant will be updated to be False in the future. To maintain current behavior, pass use_reentrant=True. It is recommended that you use use_reentrant=False. Refer to docs for more details on the differences between the two variants.
  warnings.warn(
/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:90: UserWarning: None of the inputs have requires_grad=True. Gradients will be None
  warnings.warn(
0it [00:00, ?it/s]
0it [00:00, ?it/s]
233it [05:17,  1.34s/it]/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:460: UserWarning: torch.utils.checkpoint: please pass in use_reentrant=True or use_reentrant=False explicitly. The default value of use_reentrant will be updated to be False in the future. To maintain current behavior, pass use_reentrant=True. It is recommended that you use use_reentrant=False. Refer to docs for more details on the differences between the two variants.
  warnings.warn(
/home/kali/pdf_translator/lib/python3.11/site-packages/torch/utils/checkpoint.py:90: UserWarning: None of the inputs have requires_grad=True. Gradients will be None
  warnings.warn(
1it [00:00, 48210.39it/s]
1it [00:00, 91180.52it/s]
0it [00:00, ?it/s]

My only guess is in trying to translate a short pdf file from Arabic to English. I guess it doesn't recognize the Arabic hence the unknown figure error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants