本文主要是介绍本地运行JoJoGAN踩坑(更新中……),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
网页试玩版本根据网上的帖子可以运行,也尝试了一些自定义风格图片,感觉效果不错。由于Colab提供的GPU太少,不能持续试玩网页版,因此想在本地运行JoJoGAN。
一、ubuntu系统下载JoJoGAN代码
https://github.com/mchong6/JoJoGAN
git clone https://github.com/mchong6/JoJoGAN.git
cd JoJoGAN
二、根据stylize.ipynb中的代码逐渐改写成py文件
第一段下载部分均用命令行安装,没有报错
接下来执行代码
import torch
torch.backends.cudnn.benchmark = True
from torchvision import transforms, utils
from util import *
from PIL import Image
import math
import random
import osimport numpy as np
from torch import nn, autograd, optim
from torch.nn import functional as F
from tqdm import tqdm
import lpips
import wandb
from model import *
from e4e_projection import projection as e4e_projectionfrom google.colab import files
from copy import deepcopy
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentialsos.makedirs('inversion_codes', exist_ok=True)
os.makedirs('style_images', exist_ok=True)
os.makedirs('style_images_aligned', exist_ok=True)
os.makedirs('models', exist_ok=True)
nvcc报错:
RuntimeError: Error building extension 'fused': [1/2] :/usr/local/cuda-11.2/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/cpz/anaconda3/lib/python3.8/site-packages/torch/include -isystem /home/cpz/anaconda3/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -isystem /home/cpz/anaconda3/lib/python3.8/site-packages/torch/include/TH -isystem /home/cpz/anaconda3/lib/python3.8/site-packages/torch/include/THC -isystem :/usr/local/cuda-11.2/include -isystem /home/cpz/anaconda3/include/python3.8 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --compiler-options '-fPIC' -std=c++14 -c /home/cpz/work/Code/JoJoGAN/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o
FAILED: fused_bias_act_kernel.cuda.o
:/usr/local/cuda-11.2/bin/nvcc -DTORCH_EXTENSION_NAME=fused -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -isystem /home/cpz/anaconda3/lib/python3.8/site-packages/torch/include -isystem /home/cpz/anaconda3/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -isystem /home/cpz/anaconda3/lib/python3.8/site-packages/torch/include/TH -isystem /home/cpz/anaconda3/lib/python3.8/site-packages/torch/include/THC -isystem :/usr/local/cuda-11.2/include -isystem /home/cpz/anaconda3/include/python3.8 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 --compiler-options '-fPIC' -std=c++14 -c /home/cpz/work/Code/JoJoGAN/op/fused_bias_act_kernel.cu -o fused_bias_act_kernel.cuda.o
/bin/sh: :/usr/local/cuda-11.2/bin/nvcc: 没有那个文件或目录
ninja: build stopped: subcommand failed.
解决办法:先确定 cuda 是否安装成功
nvcc -V
安装成功的话直接在命令行里输入
export CUDA_HOME=/usr/local/cuda
报错解除,继续。
一些模块缺失的问题可以通过pip install的方式安装解决。
周末继续……
这篇关于本地运行JoJoGAN踩坑(更新中……)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!