neuralchen / SimSwap

An arbitrary face-swapping framework on images and videos with one single trained model!

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

sm_86 is not compatible and code error

HMSMohamed opened this issue · comments

Hi,
I value your support to help me fix the issue I am having to be able to try the Simswap
Here is what I tried

  1. Following the as is preparation I get “RTX 4080 with CUDA capability sm_86 is not compatible with the current PyTorch installation” to fix it I tried updating the CUDA.
    After multiple tried and way I used the below line instead of the similar preparation installation line “conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge”

Now I am getting the below error, which I need your help with (I tried deleting the .patch files with no different

“C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.parallel.data_parallel.DataParallel' has changed. Saved a reverse patch to DataParallel.patch. Run patch -p0 < DataParallel.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.conv.Conv2d' has changed. Saved a reverse patch to Conv2d.patch. Run patch -p0 < Conv2d.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm2d' has changed. Saved a reverse patch to BatchNorm2d.patch. Run patch -p0 < BatchNorm2d.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.activation.PReLU' has changed. Saved a reverse patch to PReLU.patch. Run patch -p0 < PReLU.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.MaxPool2d' has changed. Saved a reverse patch to MaxPool2d.patch. Run patch -p0 < MaxPool2d.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.container.Sequential' has changed. Saved a reverse patch to Sequential.patch. Run patch -p0 < Sequential.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.pooling.AdaptiveAvgPool2d' has changed. Saved a reverse patch to AdaptiveAvgPool2d.patch. Run patch -p0 < AdaptiveAvgPool2d.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.linear.Linear' has changed. Saved a reverse patch to Linear.patch. Run patch -p0 < Linear.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.activation.Sigmoid' has changed. Saved a reverse patch to Sigmoid.patch. Run patch -p0 < Sigmoid.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.dropout.Dropout' has changed. Saved a reverse patch to Dropout.patch. Run patch -p0 < Dropout.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py:656: SourceChangeWarning: source code of class 'torch.nn.modules.batchnorm.BatchNorm1d' has changed. Saved a reverse patch to BatchNorm1d.patch. Run patch -p0 < BatchNorm1d.patch to revert your changes.
warnings.warn(msg, SourceChangeWarning)
C:\Users#########\anaconda3\envs\simswap\lib\site-packages\torch\nn\functional.py:3455: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details.
"See the documentation of nn.Upsample for details.".format(mode)”

when trying the sample run listed under usage wither I am getting the above error or the below one, please help
"Traceback (most recent call last):
File "test_video_swapmulti.py", line 58, in
app = Face_detect_crop(name='antelope', root='./insightface_func/models')
File "C:\SimSwap\insightface_func\face_detect_crop_multi.py", line 47, in init
assert 'detection' in self.models
AssertionError
"

commented

Same issue

tested on RTX4070 with torch 2.1.1+cu121 torchaudio 2.1.1+cu121 torchvision 0.16.1+cu121 and the training process just worked fine.
At first I tried to follow the advised virtual environment and it just can't work. At last I did it in my base env and worked, such a big relief. So you can just ignore the environment requirements maybe. But pay attention that the version of timm is restricted, higher versions will result in error.

@LindiaC Can you paste your complete install code for me here, I am also using a 4070 and I cannot get it to install. Everything was fine on my 1070 card but for some reason the 4070 i'm having issues.

Here's what I've put together so far:

Download and install cuda 12.1 from https://developer.nvidia.com/cuda-12-1-0-download-archive?target_os=Windows&target_arch=x86_64&target_version=11&target_type=exe_network

And then run:
conda create -n simswap python=3.8
conda activate simswap

But instead of:
conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=10.2 -c pytorch

I ran:
pip3 install torch==2.1.1+cu121 torchvision==0.16.1+cu121 torchaudio==2.1.1+cu121 -f https://download.pytorch.org/whl/torch_stable.html

Which all went through fine. Then when I come to actually swap a video:

Traceback (most recent call last):
File "test_video_swapsingle.py", line 55, in
model = create_model(opt)
File "S:\code\python\models\models.py", line 18, in create_model
model.initialize(opt)
File "S:\code\python\models\fs_model.py", line 67, in initialize
netArc_checkpoint = torch.load(netArc_checkpoint) if torch.cuda.is_available() else torch.load(netArc_checkpoint, map_location=torch.device('cpu'))
File "C:\Users\chud3\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py", line 1028, in load
return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
File "C:\Users\chud3\anaconda3\envs\simswap\lib\site-packages\torch\serialization.py", line 1256, in _legacy_load
result = unpickler.load()
File "C:\Users\chud3\anaconda3\envs\simswap\lib\site-packages\torch\optim\sgd.py", line 29, in setstate
super().setstate(state)
File "C:\Users\chud3\anaconda3\envs\simswap\lib\site-packages\torch\optim\optimizer.py", line 295, in setstate
self.defaults.setdefault('differentiable', False)
AttributeError: 'SGD' object has no attribute 'defaults'

ChatGPT suggests this is something to do with the checkpoints, as they may be different with a different pytorch version.
Any suggestions as to what Is going wrong here?

@chud37 Glad to help, I used
python 3.11.5
torch 2.1.1+cu121 torchaudio 2.1.1+cu121 torchvision 0.16.1+cu121
insightface 0.2.1
opencv-python 4.8.1.78
pillow 10.1.0
numpy 1.24.3
moviepy 1.0.3
timm 0.5.4
imageio 2.26.0
Moreover, for this specific problem, I found previous closed issue here. It says that arcface_checkpoint.tar has been updated this April.