Closed sf-pear closed 1 year ago
I am trying YOLOv8 in an environment similar to yours.
Please try apt-get install -y libgl1-mesa-dev
.
Next you will get libgthread-2.0.so.0: cannot open shared object file: No such file or directory
,
try apt-get install -y libglib2.0-0
Did you get it to work @titq2022? I managed to fix that with sudo apt-get install ffmpeg libsm6 libxext6
. But now I'm getting another error that's proven impossible to fix.
Could not load library libcudnn_cnn_infer.so.8. Error: libcuda.so: cannot open shared object file: No such file or directory
I get the same error trying to use YOLOv5 as well.
Same here, same error when trying to deploy the model in a Docker Container in Azure Machine Learning.
Same here, same error when trying to deploy the model in a Docker Container in Azure Machine Learning.
What version of Ubuntu are you in? I just downgraded to 20.04 and it's finally working.
What version of Ubuntu are you in? I just downgraded to 20.04 and it's finally working
I also have that version, but my problem is that when you pip install ultralytics
, it installs by default opencv-python
, and I cannot seem to bypass it.
Is there a resolution to this? AWS Lambda and idk what to do...
👋 hi, thanks for letting us know about this possible problem with YOLO 🚀. We've created a few short guidelines below to help users provide what we need in order to start investigating a possible problem.
When asking a question, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This is referred to by community members as creating a minimum reproducible example. Your code that reproduces the problem should be:
For Ultralytics to provide assistance your code should also be:
git pull
or pip install -U ultralytics
to ensure your problem has not already been solved in the latest code version.If you believe your problem meets all the above criteria, please close this issue and raise a new one using the 🐛 Bug Report template with a minimum reproducible example to help us better understand and diagnose your problem.
Thank you! 😃
I had the same errors just by running from ultralytics import YOLO
and fixed them by installing the opencv-python-headless package. I was running it in a container image on openshift that had pytorch (you also need pytorch>=1.7) and python installed already.
pip install ultralytics
pip install opencv-python-headless
import cv2
After that I was able to run the examples no problem.
@kaitlynabdo thank you for sharing your experience and solution with us!
It is great to hear that installing the opencv-python-headless package has resolved the error that you were experiencing when using YOLOv8.
To complete your instructions, you mentioned that you already had pytorch (≥1.7) and python installed but it is worth noting that installing pytorch is a requirement for YOLOv8. So for those who have not installed pytorch, please make sure you install it by following the instructions on https://pytorch.org/get-started/locally/
Once that is done, you can then install the missing opencv-python-headless package via pip install opencv-python-headless
.
After the installation process, running import cv2
without any errors would have confirmed that the installation of opencv-python-headless package was successful. You should now also be able to from ultralytics import YOLO
and run your YOLOv8 model.
We hope this helps anyone else who encounters the same issue. Let us know if you have any more questions.
I meet the same problem~ Can we use the opencv-python-headless version instead of normal opencv-python in requrements.txt by default? In some environments users don't have permission to install the system library.
@darouwan thank you for reaching out regarding the installation of the opencv-python-headless package as an alternative to the normal opencv-python package for YOLOv8.
While it may be possible to use the opencv-python-headless package in place of opencv-python, we cannot recommend making such a change by default as this may have unintended effects on other functionality within YOLOv8.
However, it is understandable that some environments may have restrictions that prevent users from installing system libraries, and we will keep this in mind for future updates. In the meantime, we recommend that users continue to follow the existing installation instructions for YOLOv8, and if they encounter any issues related to system library installation, that they consult their system administrator or IT support staff for assistance.
@glenn-jocher: Found this ticket by reading through past issues. A question.
My understanding is that Cloud Functions also only allow installation via pip
, and that OpenCV as installed by pip
only performs on these platforms when installed headless i.e., opencv-python-headless
. My understanding is that ultralytics
does not support an ultralytics[headless]
extra at this time, and that pip
installing opencv-python-headless
before or after ultralytics
does not replace the import structure of ultralytics
(or a similar package) sufficiently that libGL.so
is required (and does not prevent the ImportError: libGL.so
). Does this mean that ultralytics
does not currently support itself on Cloud Functions of IaaS w/o Docker?
Happy to roll up the button-down sleeves and PR if there is a one-day solution.
My problem statement was importing pytorch and other libraries like cv2 from aws EFS to aws Lambda but facing error ImportError: libGL.so.1: cannot open shared object file: No such file or directory due to cv2 import .
pip install opencv-python-headless import cv2
After that I was able to run the examples no problem.
@vishalsinghdhami hi,
From your description, it seems like you've resolved the issue by using opencv-python-headless
instead of opencv-python
. That's great to hear!
The error ImportError: libGL.so.1: cannot open shared object file: No such file or directory
typically occurs when cv2 (which is a part of opencv-python) tries to access graphics libraries that aren't available in your environment.
opencv-python-headless
is a version of opencv-python that doesn't include the GUI features, which means it also doesn't depend on the graphics libraries that were causing the problem, so it's a good solution for setups that don't have a full graphical environment (like AWS Lambda).
If you face any other issues in the future, feel free to reach out. Good luck with your project!
Did you get it to work @titq2022? I managed to fix that with
sudo apt-get install ffmpeg libsm6 libxext6
. But now I'm getting another error that's proven impossible to fix.Could not load library libcudnn_cnn_infer.so.8. Error: libcuda.so: cannot open shared object file: No such file or directory
I get the same error trying to use YOLOv5 as well.
I once fixed that by sudo apt install nvidia-cuda-toolkit
, even I don't have any cuda hardware available.
@vishalsinghdhami hi,
From your description, it seems like you've resolved the issue by using
opencv-python-headless
instead ofopencv-python
. That's great to hear!The error
ImportError: libGL.so.1: cannot open shared object file: No such file or directory
typically occurs when cv2 (which is a part of opencv-python) tries to access graphics libraries that aren't available in your environment.
opencv-python-headless
is a version of opencv-python that doesn't include the GUI features, which means it also doesn't depend on the graphics libraries that were causing the problem, so it's a good solution for setups that don't have a full graphical environment (like AWS Lambda).If you face any other issues in the future, feel free to reach out. Good luck with your project!
@glenn-jocher FYI my understanding is that this solution does not resolve the stated inquiry. My understanding of the installation flow of YOLO
is that YOLO
will install opencv
and that upon import YOLO
will search out the full opencv
version and not the headless version. I had not needed to investigate this matter directly since your last comment, and the original poster has not continued to follow up. Have you investigated this? You had mentioned a pull request to improve the setup.py
to include a headless install option. Is that still of interest to YOLO
? It opens up Cloud.
Hi @davidbernat, thank you for contributing to the conversation.
You've made a good point about the installation flow of YOLOv8 and the potential for it to default to the full opencv version even when the headless version is installed. I understand this could cause issues in environments without a full graphical interface, such as cloud-based platforms.
Regarding the use of opencv-python-headless, its incorporation into the official requirement of YOLOv8 is not trivial due to varying user needs and environments. Some users may require the full opencv version for certain GUI features.
Your suggestion about having a headless install option during setup is very interesting. While we cannot make any promises, we appreciate the suggestion and will consider this possibility for future versions of YOLOv8.
We are always listening to community feedback and continually look for opportunities to improve our library and its usability for our users.
Again, thank you for your input and please feel free to contribute further if you have additional suggestions or inquiries.
@glenn-jocher Not the important kernel of the question. Installation process provided to previous user not valid. Cloud limitations depend on nature of cloud platform. Should my group provide a solution for the previous user we will post here to keep the community aware. We will continue to seek preferable platforms elsewhere. Hard to fathom this industry: Amazon bought into HuggingFace for $235M+. All systems are limited by same companies.
Hi @davidbernat,
Your input has been very helpful and we appreciate your contribution to our ongoing discussions. The installation challenges that arise due to varying cloud platform infrastructures are indeed complex. We recognize and understand these challenges can vary depending on the nature of each cloud platform.
With respect to your team's pursuit of a solution to the previous user's issue, we would greatly appreciate your sharing any findings to help maintain community awareness. This will indeed contribute positively to our collaborative learning and improvement effort.
About your observations on the industry trends and large-scale investments, it's certainly a dynamic and rapidly changing landscape with different limiting factors. We aim to strike a balance and offer robust, flexible solutions within these constraints.
We greatly value your perspective and look forward to any further insights you may wish to share with us. Your active participation in our discussions enhances the value of our collective work. Thank you!
I had the same errors just by running from
ultralytics import YOLO
and fixed them by installing the opencv-python-headless package. I was running it in a container image on openshift that had pytorch (you also need pytorch>=1.7) and python installed already.pip install ultralytics pip install opencv-python-headless import cv2
After that I was able to run the examples no problem.
Thank you @kaitlynabdo Your answer help me resolved my issue on Jetson device
This doesn't work with the latest release (4.9.0.80) as of 09/01/2024. However it still works with version 4.8.1.78
pip install ultralytics
pip install opencv-python-headless==4.8.1.78
import cv2
@cantonioupao hi there,
Thank you for sharing your experience. It's valuable to know that the workaround with opencv-python-headless
version 4.8.1.78
is effective, while the latest release seems to have compatibility issues. We'll take note of this and investigate further. In the meantime, sticking with the version that works for your setup is a good approach. Your feedback helps us improve, so we appreciate it! 🙌
I would prefer this to be fixed by having only ultralytics in requirements.txt. It gives the same error ImportError: libGL.so.1: cannot open shared object file: No such file or directory. These are my packages I am installing, in a OpenShift environment:
-f https://download.pytorch.org/whl/torch_stable.html torch==2.0.1+cpu torchaudio==2.0.2+cpu torchvision==0.15.2+cpu transformers~=4.28.1 pytorch-lightning~=1.6.5 timm~=0.6.7 nltk~=3.8.1 Flask~=2.3.2 Flask-Cors~=3.0.10 gunicorn~=20.1.0 gevent~=22.10.2 ultralytics opencv-python opencv-python-headless
It also does not work when removing either of the opencv packages.
@JonathanFL hey there! 👋
Thanks for reaching out with your issue. It seems like the libGL.so.1
error can be quite persistent in environments without a full GUI support. Since you're in an OpenShift environment, installing opencv-python-headless
should ideally resolve this, as it doesn't require GUI packages.
Given your setup, it looks like you've included both opencv-python
and opencv-python-headless
in your requirements. Having both might cause some conflicts. Could you try removing opencv-python
and only keeping opencv-python-headless
? Here's a revised snippet of your requirements:
-f https://download.pytorch.org/whl/torch_stable.html
torch==2.0.1+cpu
torchaudio==2.0.2+cpu
torchvision==0.15.2+cpu
transformers~=4.28.1
pytorch-lightning~=1.6.5
timm~=0.6.7
nltk~=3.8.1
Flask~=2.3.2
Flask-Cors~=3.0.10
gunicorn~=20.1.0
gevent~=22.10.2
ultralytics
opencv-python-headless
If you've already tried this without success, it might be worth ensuring that your environment variables are correctly set, especially if libGL.so.1
is indeed available on your system but not found due to path issues.
Let us know how it goes! We're here to help. 😊
Got it to work by using Python 3.9.
@JonathanFL that's fantastic news! 🎉 I'm glad to hear you got it working with Python 3.9. If you encounter any more issues or have questions, feel free to reach out. Happy coding!
This soloution worked fine for me :- https://docs.streamlit.io/knowledge-base/dependencies/libgl
Tested on both python version in Streamlit
:- 3.9 and 3.10
My requirements.txt
file :-
# opencv-python==4.9.0.80
opencv-python-headless==4.8.1.78
opencv-contrib-python==4.8.1.78
create new file naming packages.txt
libgl1
@Viddesh1 great to hear the solution worked out for you, and thanks for sharing your setup details! 😊 Your approach with specifying opencv-python-headless
and opencv-contrib-python
versions alongside the packages.txt
for the libgl1
dependency is super helpful for Streamlit environments. This can definitely assist others facing similar issues. Keep up the good work! 👍
for me the fix was
sudo apt install libgl1-mesa-glx
@computervisionpro thanks for sharing your solution! Installing libgl1-mesa-glx
is indeed a common fix for the libGL.so.1
error, especially in environments where GUI libraries are not pre-installed. This can be particularly useful for users running into similar issues on Linux-based systems.
For those who might still face issues, ensuring that you have the latest versions of your packages and providing a reproducible example can help us diagnose and resolve any remaining problems. You can find more information on creating a minimum reproducible example here.
If you have any further questions or run into other issues, feel free to ask. We're here to help! 😊
Issue is still present when using the latest wsl. The suggested fixes above work.
Still facing the same issue with Alpine/Apko environment.
Thank you for your feedback. Please ensure you're using the latest version of the Ultralytics package. For Alpine/Apko environments, installing libgl1-mesa-glx
or adding libgl1
to your packages.txt
file can resolve the libGL.so.1
error. If the issue persists, consider switching to a more compatible environment like Ubuntu. Let us know if you need further assistance.
Search before asking
YOLOv8 Component
Training
Bug
This one is quite strange. The first time I ran the code, it worked. But the venv timed out in the first epoch so I changed the training parameters and re-ran the code. But now I keep getting this error no matter what I do:
Environment
Minimal Reproducible Example
Additional
Any ideas of what this could be? Or how I can fix it?
Are you willing to submit a PR?