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

Client exception when working with pytorch. #90

Open
saurabhmahra91 opened this issue May 16, 2024 · 0 comments
Open

Client exception when working with pytorch. #90

saurabhmahra91 opened this issue May 16, 2024 · 0 comments

Comments

@saurabhmahra91
Copy link

from dotenv import load_dotenv
import torch
from mistralai.client import MistralClient

print(torch.tensor([1, 2, 3]))

load_dotenv()
mistral = MistralClient()

print("hello world")

The code above would raise an exception. The program is executed successfully but at the end the program meets an exception. I assume that this exception is coming during python's internal memory management.

Here is the output of the above program I get

tensor([1, 2, 3])
hello world
Exception ignored in: <function MistralClient.__del__ at 0x11015cc20>
Traceback (most recent call last):
  File "/Users/saurabhmahra/Experiments/pii_mapper/venv/lib/python3.12/site-packages/mistralai/client.py", line 46, in __del__
  File "/Users/saurabhmahra/Experiments/pii_mapper/venv/lib/python3.12/site-packages/httpx/_client.py", line 1258, in close
  File "/Users/saurabhmahra/Experiments/pii_mapper/venv/lib/python3.12/site-packages/httpx/_transports/default.py", line 240, in close
  File "/Users/saurabhmahra/Experiments/pii_mapper/venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 313, in close
  File "/Users/saurabhmahra/Experiments/pii_mapper/venv/lib/python3.12/site-packages/httpcore/_sync/connection_pool.py", line 303, in _close_connections
TypeError: 'NoneType' object is not callable

I can get rid of the issue by just removing the pytorch part of the code.

from dotenv import load_dotenv
# import torch
from mistralai.client import MistralClient

# print(torch.tensor([1, 2, 3]))

load_dotenv()
mistral = MistralClient()

print("hello world")

My understanding of the error is that becuase of pytorch, the httpx client somehow become None and then the error appears because the during the memory management mistral_client object's _client attribute (httpx client) is None.

More info about my system
Python version 3.12.3
mistralai==0.1.8
torch==2.3.0
I am running a macbook air M2 2022 - 8GB with macOS version Sonoma 14.4.1

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

1 participant