Open tnunamak opened 7 months ago
I'm facing the same issue using the codium/pr-agent deployed to a AWS Lamda function (I've also opened an issue there: https://github.com/Codium-ai/pr-agent/issues/909). Since the lamda filesystem is read-only (except for the /tmp
folder) I'm getting this error. I've tried the workaround of setting TIKTOKEN_CACHE_DIR
to /tmp
folder in the filesystem but because of the change tnunamak mentioned before is not possible because of these lines in the code that are overwriting that environment variable.
I have pretty much the same issue with litellm 1.38.11 and tiktoken 0.7.0 in my docker container.
litellm patches the env var TIKTOKEN_CACHE_DIR
, which causes tiktoken to crash:
File \"/opt/app-root/lib64/python3.11/site-packages/tiktoken/load.py\", line 74, in read_file_cached
with open(tmp_filename, \"wb\") as f:
^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 13] Permission denied: '/opt/app-root/lib64/python3.11/site-packages/litellm/llms/tokenizers/fb374d419588a4632f3f557e76b4b70aebbca790.e7ca2cd3-f9c8-438e-9f61-6e71d33173af.tmp'
watch #4119
@tnunamak @maurobender @Jonas1312
We can use environment variable CUSTOM_TIKTOKEN_CACHE_DIR
@tnunamak @maurobender @Jonas1312 #4119 released on v1.40.9 We can use environment variable
CUSTOM_TIKTOKEN_CACHE_DIR
This comment seems off, it is just TIKTOKEN_CACHE_DIR
but it doesn't override it?
@fingon Are you still having problems?
litellm/utils.py top level code
os.environ["TIKTOKEN_CACHE_DIR"] = os.getenv("CUSTOM_TIKTOKEN_CACHE_DIR", filename)
In our case, the beautiful fix was just to import litellm and set the TIKTOKEN_CACHE_DIR
afterwards so this was mostly reference to looking at code (but I might have looked at earlier version).
What happened?
litellm writes to the filesystem during initialization. I'm building a macOS application and this causes a read-only filesystem error:
Some investigation shows that it's due to this code, (original PR here).
As a workaround, perhaps this behavior could be disabled or TIKTOKEN_CACHE_DIR could be left alone if it is already set?
Relevant log output