Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when run "bash run.sh" #37

Closed
eltonnuness opened this issue Apr 15, 2020 · 27 comments
Closed

Error when run "bash run.sh" #37

eltonnuness opened this issue Apr 15, 2020 · 27 comments

Comments

@eltonnuness
Copy link

eltonnuness commented Apr 15, 2020

Hi,

I pull the last commit, executed again the install.sh and tryed run:

bash run.sh

But this error occours:

(avatarify) eltonnunes@eltonnunes-home:~/Repository/others/avatarify$ bash run.sh
0: ./avatars/einstein.jpg
1: ./avatars/eminem.jpg
2: ./avatars/jobs.jpg
3: ./avatars/mona.jpg
4: ./avatars/obama.jpg
5: ./avatars/potter.jpg
6: ./avatars/ronaldo.png
7: ./avatars/schwarzenegger.png
load checkpoints..
cam_fomm.py:34: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
config = yaml.load(f)
Traceback (most recent call last):
File "cam_fomm.py", line 231, in
stream = pyfakewebcam.FakeWebcam(f'/dev/video{opt.virt_cam}', frame.shape[1], frame.shape[0])
File "/home/eltonnunes/.conda/envs/avatarify/lib/python3.8/site-packages/pyfakewebcam/pyfakewebcam.py", line 54, in init
fcntl.ioctl(self._video_device, _v4l2.VIDIOC_S_FMT, self._settings)
OSError: [Errno 22] Invalid argument

Anyone can help ?

My OS: Linux Mint 19.3 Cinnamon

@alievk
Copy link
Owner

alievk commented Apr 15, 2020

Something wrong with the virtual cam. Please show v4l2-ctl --list-devices output and CAMID_VIRT value.

@eltonnuness
Copy link
Author

eltonnuness commented Apr 15, 2020

v4l2-ctl --list-devices

avatarify (platform:v4l2loopback-000):
/dev/video9

C922 Pro Stream Webcam (usb-0000:00:14.0-10):
/dev/video0
/dev/video1

echo $CAMID_VIRT
9

@alievk
Copy link
Owner

alievk commented Apr 15, 2020

Your setup looks ok, but pyfakewebcam can’t open the virtual cam for some reason.

This is related issue jremmons/pyfakewebcam#7

@barabanshek
Copy link

barabanshek commented Apr 16, 2020

Exactly, the issue was in the v4l2loopback driver.

You need to change the line 2095 in the file https://github.com/umlaeute/v4l2loopback/blob/master/v4l2loopback.c#L2096 to #if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) and build, re-install the driver. This worked just fine for me.

More info here: umlaeute/v4l2loopback#172

@alievk
Copy link
Owner

alievk commented Apr 16, 2020

Added fix branch. Do:

# remove apt package
sudo modprobe -r v4l2loopback
sudo apt remove v4l2loopback-dkms

# build v4l2loopback from source
# from avatarify directory:
git pull
git checkout fix_v4l2loopback
bash scripts/install.sh

@alievk
Copy link
Owner

alievk commented Apr 16, 2020

Please write back if it works.

@eltonnuness
Copy link
Author

It works ! 👍

Thanks @alievk and @Prockuror

@bwanaaa
Copy link

bwanaaa commented Apr 18, 2020

I am having a similar 'pyfakewebcam.py' issue.

v4l2-ctl --list-devices
avatarify (platform:v4l2loopback-000):
   /dev/video9

HD Webcam C615 (usb-0000:06:00.0-1.2):
   /dev/video0
   /dev/video1

(avatarify) stefan@stefan-4930:~/Downloads/avatarify$ echo $CAMID_VIRT

So I set CAMID_VIRT myself in the command line with

$ CAMID_VIRT=9
before running 'run.sh'
and got this:

0: ./avatars/einstein.jpg
1: ./avatars/eminem.jpg
2: ./avatars/jobs.jpg
3: ./avatars/mona.jpg
4: ./avatars/obama.jpg
5: ./avatars/potter.jpg
6: ./avatars/ronaldo.png
7: ./avatars/schwarzenegger.png
load checkpoints..
cam_fomm.py:34: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  config = yaml.load(f)
Traceback (most recent call last):
  File "cam_fomm.py", line 230, in <module>
    stream = pyfakewebcam.FakeWebcam(f'/dev/video{opt.virt_cam}', frame.shape[1], frame.shape[0])
  File "/home/stefan/miniconda3/envs/avatarify/lib/python3.8/site-packages/pyfakewebcam/pyfakewebcam.py", line 54, in __init__
    fcntl.ioctl(self._video_device, _v4l2.VIDIOC_S_FMT, self._settings)
OSError: [Errno 22] Invalid argument

line 54 in pyfakewebcam is this:

  fcntl.ioctl(self._video_device, _v4l2.VIDIOC_S_FMT, self._settings)

on ubuntu 18.04.4
running last linux kernel

uname -r
5.3.0-42-generic

help?

@alievk
Copy link
Owner

alievk commented Apr 18, 2020

@bwanaaa does it help compiling v4l2loopback from source? #37 (comment)

@bwanaaa
Copy link

bwanaaa commented Apr 18, 2020

it seems thie issue here persists
umlaeute/v4l2loopback#172

the line 2098 in the repo is still

#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 20, 0)

whereas the closed issue indicates it should be

#if LINUX_VERSION_CODE >= KERNEL_VERSION(3,7,0)

@bwanaaa
Copy link

bwanaaa commented Apr 18, 2020

There are so many references to 'KERNEL_VERSION' I dont know which to change to the '>' from the existing '<'

@alievk
Copy link
Owner

alievk commented Apr 18, 2020

Did you try #37 (comment)? I've already changed that line.

@bwanaaa
Copy link

bwanaaa commented Apr 18, 2020

I followed comment 37 to this point 'git pull' and got

$git pull
remote: Enumerating objects: 10, done.
remote: Counting objects: 100% (10/10), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 10 (delta 5), reused 6 (delta 4), pack-reused 0
Unpacking objects: 100% (10/10), done.
From https://github.com/alievk/avatarify
   3daa19c..a5aabda  master     -> origin/master
Updating 3daa19c..a5aabda
Fast-forward
 .gitmodules                 |  3 +++
 README.md                   | 50 ++++++++++++++++++++++++++-------------------
 fomm                        |  1 +
 scripts/install.sh          |  2 +-
 scripts/install_mac.sh      |  4 ++--
 scripts/install_windows.bat |  2 +-
 6 files changed, 37 insertions(+), 25 deletions(-)
 create mode 100644 .gitmodules
 create mode 160000 fomm
(base) stefan@stefan-4930:~/Downloads/avatarify$ git checkout fix_v4l2loopback
warning: unable to rmdir 'fomm': Directory not empty
M	run.sh
Branch 'fix_v4l2loopback' set up to track remote branch 'fix_v4l2loopback' from 'origin'.
Switched to a new branch 'fix_v4l2loopback'
(base) stefan@stefan-4930:~/Downloads/avatarify$ 

@bwanaaa
Copy link

bwanaaa commented Apr 18, 2020

I did compile the latest v4l2loopback from source and did install it first.

@bwanaaa
Copy link

bwanaaa commented Apr 18, 2020

and now it works. thank you.

@serg-zh
Copy link

serg-zh commented Apr 18, 2020

had the same issue, #37 (comment) helped

@nathaniel-brough
Copy link

I have the same issue but comment #37 did not solve my problem.

Relevant output from bash scripts/install.sh

Cloning into 'v4l2loopback'...
remote: Enumerating objects: 89, done.
remote: Counting objects: 100% (89/89), done.
remote: Compressing objects: 100% (54/54), done.
remote: Total 1795 (delta 43), reused 63 (delta 29), pack-reused 1706
Receiving objects: 100% (1795/1795), 819.71 KiB | 288.00 KiB/s, done.
Resolving deltas: 100% (1006/1006), done.
Building v4l2-loopback driver...
make -C /lib/modules/`uname -r`/build M=/home/user/projects/avatarify/v4l2loopback modules
make[1]: Entering directory '/usr/src/linux-headers-5.3.0-46-generic'
  CC [M]  /home/user/projects/avatarify/v4l2loopback/v4l2loopback.o
  Building modules, stage 2.
  MODPOST 1 modules
  CC      /home/user/projects/avatarify/v4l2loopback/v4l2loopback.mod.o
  LD [M]  /home/user/projects/avatarify/v4l2loopback/v4l2loopback.ko
make[1]: Leaving directory '/usr/src/linux-headers-5.3.0-46-generic'
make -C /lib/modules/`uname -r`/build M=/home/user/projects/avatarify/v4l2loopback modules_install
make[1]: Entering directory '/usr/src/linux-headers-5.3.0-46-generic'
  INSTALL /home/user/projects/avatarify/v4l2loopback/v4l2loopback.ko
At main.c:160:
- SSL error:02001002:system library:fopen:No such file or directory: ../crypto/bio/bss_file.c:72
- SSL error:2006D080:BIO routines:BIO_new_file:no such file: ../crypto/bio/bss_file.c:79
sign-file: certs/signing_key.pem: No such file or directory
  DEPMOD  5.3.0-46-generic
Warning: modules_install: missing 'System.map' file. Skipping depmod.
make[1]: Leaving directory '/usr/src/linux-headers-5.3.0-46-generic'

SUCCESS (if you got 'SSL errors' above, you can safely ignore them)

Output from bash run.sh

Creating virtual camera /dev/video9 (sudo privelege required)
modprobe: ERROR: could not insert 'v4l2loopback': Operation not permitted
0: ./avatars/einstein.jpg
1: ./avatars/eminem.jpg
2: ./avatars/jobs.jpg
3: ./avatars/mona.jpg
4: ./avatars/obama.jpg
5: ./avatars/potter.jpg
6: ./avatars/ronaldo.png
7: ./avatars/schwarzenegger.png
load checkpoints..
cam_fomm.py:34: YAMLLoadWarning: calling yaml.load() without Loader=... is deprecated, as the default Loader is unsafe. Please read https://msg.pyyaml.org/load for full details.
  config = yaml.load(f)

--- Make sure the v4l2loopback kernel module is loaded ---
sudo modprobe v4l2loopback devices=1

Traceback (most recent call last):
  File "cam_fomm.py", line 230, in <module>
    stream = pyfakewebcam.FakeWebcam(f'/dev/video{opt.virt_cam}', frame.shape[1], frame.shape[0])
  File "/home/user/miniconda3/envs/avatarify/lib/python3.8/site-packages/pyfakewebcam/pyfakewebcam.py", line 31, in __init__
    raise FileNotFoundError('device does not exist: {}'.format(video_device))
FileNotFoundError: device does not exist: /dev/video9

Output from uname -r

5.3.0-46-generic

Running on latest kernel from ubuntu 18.04

@alievk
Copy link
Owner

alievk commented Apr 20, 2020

Looks like this bug is officially fixed umlaeute/v4l2loopback@7dced0f

@pedrodiamel
Copy link

pedrodiamel commented Apr 20, 2020

Ubuntu 18.04
Linux 5.3.0-46-generic

#remove apt package
sudo modprobe -r v4l2loopback
sudo apt remove v4l2loopback-dkms

#install aux
sudo apt-get install linux-generic
sudo apt install dkms

#install v4l2loopback from the repository
https://github.com/umlaeute/v4l2loopback.git
cd v4l2loopback
make

#instal mod
sudo cp -R . /usr/src/v4l2loopback-1.1
sudo dkms add -m v4l2loopback -v 1.1
sudo dkms build -m v4l2loopback -v 1.1
sudo dkms install -m v4l2loopback -v 1.1
sudo reboot

@basemdabbour
Copy link

The first bash run worked with me and got the virtual camper working with zoom, but when I closed it, I made a restart and reopened again, it showed the same messages error like anybody here. I tried may time to remove v4l2loopback and reinitiate everything but I keep getting the same error, even I tried on another ubuntu 16.0.4 machine and the same thing happened!!!. I don't know what happened in the first bash run command, I installed all dependencies again (pandas, NumPy, cv2 .... etc) and then worked without any virtual camera error. anybody solved it or know what is the problem and possible solution?

@alievk
Copy link
Owner

alievk commented Apr 21, 2020

@basemdabbour not sure I understood it completely. did you manage to run it without error?
Do you have latest version of code?

@basemdabbour
Copy link

@alievk yes, I did without any errors after installing dependencies in my condo environment, I used the same code in repo, it worked with me by following the same steps. but only one time :). but when I restarted my OS and tried to run "bash run.sh" again, I got the same error here and couldn't fix it till now.

now I am getting the follwoing error:

(avatarify) stefan@stefan-XPS-15-9550:~/Desktop/avatarify$ bash run.sh
Creating virtual camera /dev/video9 (sudo privelege required)
modprobe: FATAL: Module v4l2loopback not found in directory /lib/modules/4.4.0-177-generic
0: ./avatars/einstein.jpg
1: ./avatars/eminem.jpg
2: ./avatars/jobs.jpg
3: ./avatars/mona.jpg
4: ./avatars/obama.jpg
5: ./avatars/potter.jpg
6: ./avatars/ronaldo.png
7: ./avatars/schwarzenegger.png
load checkpoints..
Traceback (most recent call last):
File "cam_fomm.py", line 219, in
generator, kp_detector = load_checkpoints(config_path=opt.config, checkpoint_path=opt.checkpoint, device=device)
File "cam_fomm.py", line 45, in load_checkpoints
checkpoint = torch.load(checkpoint_path, map_location=device)
File "/home/stefan/miniconda3/envs/avatarify/lib/python3.8/site-packages/torch/serialization.py", line 529, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "/home/stefan/miniconda3/envs/avatarify/lib/python3.8/site-packages/torch/serialization.py", line 702, in _legacy_load
result = unpickler.load()
File "/home/stefan/miniconda3/envs/avatarify/lib/python3.8/site-packages/torch/serialization.py", line 665, in persistent_load
deserialized_objects[root_key] = restore_location(obj, location)
File "/home/stefan/miniconda3/envs/avatarify/lib/python3.8/site-packages/torch/serialization.py", line 737, in restore_location
return default_restore_location(storage, map_location)
File "/home/stefan/miniconda3/envs/avatarify/lib/python3.8/site-packages/torch/serialization.py", line 156, in default_restore_location
result = fn(storage, location)
File "/home/stefan/miniconda3/envs/avatarify/lib/python3.8/site-packages/torch/serialization.py", line 136, in _cuda_deserialize
return storage_type(obj.size())
File "/home/stefan/miniconda3/envs/avatarify/lib/python3.8/site-packages/torch/cuda/init.py", line 480, in _lazy_new
return super(_CudaBase, cls).new(cls, *args, **kwargs)
RuntimeError: CUDA out of memory. Tried to allocate 20.00 MiB (GPU 0; 1.96 GiB total capacity; 743.02 MiB already allocated; 7.31 MiB free; 750.00 MiB reserved in total by PyTorch)

@basemdabbour
Copy link

@basemdabbour not sure I understood it completely. did you manage to run it without error?
Do you have the latest version of code?

@alievk, I got two windows, one is cam and the other one is avatarify with Einstein's face. also worked integrating it with zoom like you did in the video. I stopped and rerun "bah run.sh" many times and it worked. but suddenly it stopped working and now I got again the same error :

FileNotFoundError: device does not exist: /dev/video9
FATAL: exception not rethrown
run.sh: line 17: 19128 Aborted

@basemdabbour
Copy link

@alievk Finally, it worked with me and using the GPU.
I just changed my operating system to use Fedora instead of ubuntu and everything went just perfect without asking me about any missing modules or CUDA problems. but unfortunately, I have a low VRAM and the streaming was not clear enough to do a call :)
1111

@alievk
Copy link
Owner

alievk commented Apr 22, 2020

Glad to hear you get it through :)
There are lots of exceptions happening, it's hard to make it run on all the diversity of platforms and distributions..

@basemdabbour
Copy link

Glad to hear you get it through :)
There are lots of exceptions happening, it's hard to make it run on all the diversity of platforms and distributions.

@alievk yea you are right it's a pretty good project and I think there is a new bug in the zoom or skype where it allows you to add virtual camper to their application!. This project is just highlights the possibility of doing it. But how can I change the avatar? to Elon musk for example?.

@alievk
Copy link
Owner

alievk commented Apr 24, 2020

@alievk alievk closed this as completed Apr 24, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants