aws / aws/amazon-sagemaker-examples

With SageMaker Studio: Object Detection Birds - ImportError: libGL.so.1: cannot open shared object file: No such file or directory

Open
#1,773 2 comments 6 reactions 0 assignees View on GitHub
Dominant language
Jupyter Notebook
Stars
11k
Forks
7k
Avg merge
8h 29m
Merged PRs (30d)
8

Description

On SageMaker Studio, you get the following error (it doesn't occur with SageMaker classic)

```
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
in
1 import pandas as pd
----> 2 import cv2
3 import boto3
4 import json
5

/opt/conda/lib/python3.7/site-packages/cv2/__init__.py in
3 import sys
4
----> 5 from .cv2 import *
6 from .data import *
7

ImportError: libGL.so.1: cannot open shared object file: No such file or directory

```

## Here's how to fix it:

> Install opencv-python-headless instead of opencv-python. Server (headless) environments do not have GUI packages installed which is why you are seeing the error. opencv-python depends on Qt which in turn depends on X11 related libraries.
Src: https://stackoverflow.com/questions/63977422/error-trying-to-import-cv2opencv-python-package

Contributor guide

Open the contributing guide

Research direction

Find the Object Detection Birds notebook and search for its cv2 import and OpenCV dependency references. Reproduce the import in SageMaker Studio, then verify that the notebook uses a headless OpenCV package and that importing cv2 no longer raises the libGL.so.1 error.

Written by the indexing model from the issue text.

Assessment

Tech stack
aws, jupyter-notebook, opencv, python
Domain
cloud, machine-learning
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.