lllyasviel / Fooocus

Focus on prompting and generating
GNU General Public License v3.0
40.23k stars 5.58k forks source link

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

Closed mihirgarg01 closed 8 months ago

mihirgarg01 commented 8 months ago

Read Troubleshoot

[x] I admit that I have read the Troubleshoot before making this issue.

Describe the problem Running WSL Ubuntu 22.04 (WSL Version 2) on Windows with a 1660 ti Mobile (6gb VRAM) using Python 3.10.12 Got an import error. Solved by running sudo apt update then sudo apt install libgl1.

Full Console Log Paste full console log here. You will make our job easier if you give a full log. File "/usr/lib/python3.10/threading.py", line 1016, in _bootstrap_inner self.run() File "/usr/lib/python3.10/threading.py", line 953, in run self._target(*self._args, **self._kwargs) File "/home/hepmihir/Fooocus/modules/async_worker.py", line 31, in worker import extras.preprocessors as preprocessors File "/home/hepmihir/Fooocus/extras/preprocessors.py", line 1, in import cv2 File "/home/hepmihir/Fooocus/fooocus_env/lib/python3.10/site-packages/cv2/init.py", line 181, in bootstrap() File "/home/hepmihir/Fooocus/fooocus_env/lib/python3.10/site-packages/cv2/init.py", line 153, in bootstrap native_module = importlib.import_module("cv2") File "/usr/lib/python3.10/importlib/init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) ImportError: libGL.so.1: cannot open shared object file: No such file or directory

mihirgarg01 commented 8 months ago

For anyone wondering why I'm using Windows Subsystem for Linux (WSL), the windows instillation wasn't working for me for some reason. Using WSL does work, but you need some setup. Specifically you need to have the correct nvidia driver and you need to be using WSL2. I also had to setup a .wslconfig file, because by default WSL only 25% of your system memory for a swap file (If your system memory is 16gb RAM, WSL allocates 4gb of swap).

  1. Nvidia Cuda WSL documentation
  2. Download the right driver here
  3. Refer to section 1.1 Row 1 of the documentation. WSL2 is required, but WSL1 is usually given by default
  4. Open PowerShell as an administrator
  5. Run wsl --install (Defaults to downloading Ubuntu)
  6. Check if your distro is version 1 or version 2: wsl -l -v
  7. Upgrade to version 2: wsl --set-version <distro name> 2 (use wsl -l -v to find your distro name)
  8. Enable the virtual machine component dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart
  9. Restart your computer
  10. Confirm you're on WSL2 by running wsl -l -v
  11. Add a .wslconfig to add more swap confusing documentation useful blog guide
  12. In a WSL terminal, Check how much memory and swap you have currently free -m
  13. Shutdown WSL wsl --shutdown
  14. Create a .wslconfig file in your home directory (Ex: C:\Users\.wslconfig)`
  15. Use the template below No more than 50% of your system memory to WSL!
  16. Allocate an amount for swap (I did 32 gb)

WSL Upgrade Guide


# Settings apply across all Linux distros running on WSL 2
# Can see memory in wsl2 with "free -m"
# Goes in windows home directory as .wslconfig
[wsl2]

# Limits VM memory to use no more than 48 GB, defaults to 50% of ram
memory=8GB

# Sets the VM to use 6 virtual processors (Amount of cores your CPU has)
processors=6

# Sets the amount of swap storage space to 8GB, default is 25% of available RAM
swap=32GB
MyKEms commented 6 months ago

I experienced the same issue on the latest Win11 WSL2 (Ubuntu 22.04). The solution for me was to install cuda-toolkit as described by @mihirgarg01