aws / amazon-sagemaker-examples

Example 📓 Jupyter notebooks that demonstrate how to build, train, and deploy machine learning models using 🧠 Amazon SageMaker.
https://sagemaker-examples.readthedocs.io
Apache License 2.0
10.14k stars 6.78k forks source link

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

Open CloudaYolla opened 3 years ago

CloudaYolla commented 3 years ago

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

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-15-4383da932aea> in <module>
      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 <module>
      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

yastasho commented 3 years ago

Not sure what was causing the issue, but I was able to run the notebook successfully end-to-end with the kernel "Python 3 (MXNet 1.8 Python 3.7 CPU Optimized)" on a t3.medium notebook instance.

To clarify, it's this notebook: https://github.com/aws/amazon-sagemaker-examples/blob/master/introduction_to_amazon_algorithms/object_detection_birds/object_detection_birds.ipynb

robmarkcole commented 3 years ago

Encountered this issue on the Python 3(Data Science) kernel