AWS Lambda & wandb

I have the following codes in my AWS lambda function and the error logs below. Error went away when wandb.init() is commented out.

I am using wandb 0.16.2 (as lambda layer) and python 3.11. I configured the environment variables printed below. I also tried 0.15.5 but resulted the same errors.

Any idea how to solve this?
Is there a working sample hello world on wandb + AWS lambda?

import wandb
import sys
import os

def lambda_handler(event, context):

print("sys.executable = " + sys.executable)
print("WANDB__EXECUTABLE = " + os.environ['WANDB__EXECUTABLE'])
print("WANDB_CACHE_DIR = " + os.environ['WANDB_CACHE_DIR'])
print("WANDB_CONFIG_DIR = " + os.environ['WANDB_CONFIG_DIR'])
print("WANDB_DIR = " + os.environ['WANDB_DIR'])
print("WANDB_SILENT = " + os.environ['WANDB_SILENT'])



Function Logs
START RequestId: 77bbec50-e984-4339-a7ba-dd2b2b49df95 Version: $LATEST
sys.executable = /var/lang/bin/python3.11
WANDB__EXECUTABLE = /var/lang/bin/python3.11
WANDB_DIR = /tmp/
wandb: WARNING Path /var/task/wandb/ wasn’t writable, using system temp directory.
/var/lang/bin/python3.11: No module named wandb
[ERROR] ServiceStartProcessError: The wandb service process exited with 1. Ensure that sys.executable is a valid python interpreter. You can override it with the _executable setting or with the WANDB__EXECUTABLE environment variable.
Traceback (most recent call last):
File “/var/task/”, line 45, in lambda_handler
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/”, line 1195, in init
raise e
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/”, line 1172, in init
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/”, line 189, in setup
self._wl = wandb_setup.setup(settings=setup_settings)
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/”, line 327, in setup
ret = _setup(settings=settings)
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/”, line 320, in _setup
wl = _WandbSetup(settings=settings)
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/”, line 303, in init
_WandbSetup._instance = _WandbSetup__WandbSetup(settings=settings, pid=pid)
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/”, line 114, in init
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/”, line 250, in _setup
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/”, line 277, in _setup_manager
self._manager = wandb_manager._Manager(settings=self._settings)
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/”, line 139, in init
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/service/”, line 237, in start
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/service/”, line 231, in _launch_server
File “/opt/python/lib/python3.11/site-packages/wandb/analytics/”, line 154, in reraise
raise exc.with_traceback(sys.exc_info()[2])
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/service/”, line 229, in _launch_server
self._wait_for_ports(fname, proc=internal_proc)
File “/opt/python/lib/python3.11/site-packages/wandb/sdk/service/”, line 107, in _wait_for_ports
raise ServiceStartProcessError(END RequestId: 77bbec50-e984-4339-a7ba-dd2b2b49df95
REPORT RequestId: 77bbec50-e984-4339-a7ba-dd2b2b49df95 Duration: 845.17 ms Billed Duration: 846 ms Memory Size: 256 MB Max Memory Used: 228 MB Init Duration: 5442.98 ms

Hello! This looks like an older issue that has resurfaced when running wandb in an AWS Lambda function. Could you try the suggestion here in order to try to alleviate the issue?

Thanks! I will try and update here…

Sounds good! Let me know once you are able to try!