aws-samples / amazon-bedrock-workshop

This is a workshop designed for Amazon Bedrock a foundational model service.
https://catalog.us-east-1.prod.workshops.aws/workshops/a4bdb007-5600-4368-81c5-ff5b4154f518/en-US/20-intro
MIT No Attribution
1.38k stars 591 forks source link

"apt-get update && apt-get install g++ -y" in bedrock_boto3_setup.jpynb returned error when using latest JupyterLab app in SageMaker Studio #161

Closed kai-zhu-aws closed 5 months ago

kai-zhu-aws commented 8 months ago

SageMaker recently announced new SageMaker Studio. It has new app type called JupyterLab. I cloned the repo in a JupyterLab app. When run the below code, it returned error.

%%bash
apt-get update && apt-get install g++ -y

Reading package lists...

E: Could not open lock file /var/lib/apt/lists/lock - open (13: Permission denied)
E: Unable to lock directory /var/lib/apt/lists/

---------------------------------------------------------------------------
CalledProcessError                        Traceback (most recent call last)
Cell In[6], line 1
----> 1 get_ipython().run_cell_magic('bash', '', 'apt-get update && apt-get install g++ -y\n')

File /opt/conda/lib/python3.10/site-packages/IPython/core/interactiveshell.py:2515, in InteractiveShell.run_cell_magic(self, magic_name, line, cell)
   2513 with self.builtin_trap:
   2514     args = (magic_arg_s, cell)
-> 2515     result = fn(*args, **kwargs)
   2517 # The code below prevents the output from being displayed
   2518 # when using magics with decorator @output_can_be_silenced
   2519 # when the last Python token in the expression is a ';'.
   2520 if getattr(fn, magic.MAGIC_OUTPUT_CAN_BE_SILENCED, False):

File /opt/conda/lib/python3.10/site-packages/IPython/core/magics/script.py:154, in ScriptMagics._make_script_magic.<locals>.named_script_magic(line, cell)
    152 else:
    153     line = script
--> 154 return self.shebang(line, cell)

File /opt/conda/lib/python3.10/site-packages/IPython/core/magics/script.py:314, in ScriptMagics.shebang(self, line, cell)
    309 if args.raise_error and p.returncode != 0:
    310     # If we get here and p.returncode is still None, we must have
    311     # killed it but not yet seen its return code. We don't wait for it,
    312     # in case it's stuck in uninterruptible sleep. -9 = SIGKILL
    313     rc = p.returncode or -9
--> 314     raise CalledProcessError(rc, cell)

CalledProcessError: Command 'b'apt-get update && apt-get install g++ -y\n'' returned non-zero exit status 100.
awsarippa commented 8 months ago

Screenshot 2024-01-05 at 6 13 12 PM The issue occurs in SageMaker Notebook instance - JupyterLab.

weklund commented 8 months ago

+1

Also running into this, and prefixed with sudo as well

weklund commented 8 months ago

I was able to get past this with sudo -s before apt-get update && apt-get install g++ -y @awsarippa

w601sxs commented 5 months ago

Closing this; please refer to the latest bedrock workshop update and reopen if still relevant