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

install for windows #50

Open
luoww1992 opened this issue Feb 23, 2023 · 17 comments
Open

install for windows #50

luoww1992 opened this issue Feb 23, 2023 · 17 comments

Comments

@luoww1992
Copy link

some one share the steps for installing to win ?

@luoww1992
Copy link
Author

now it is sucessful in win10.
Thanks for his help: @vitacon

step1:
install VS2022 buildtools.
https://aka.ms/vs/17/release/vs_BuildTools.exe
download it and i choose to install these:
vs2022_1
vs2022_2

Don't forget add the cl.exe into %PATH%
my path is C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.35.32215\bin\Hostx64\x64
step2:
install cuda11.7.1 and cudnn8.5.0 in real main env (the step is to install nvcc)

step3:
create conda env
conda create --name vtoon_env python=3.9
conda activate vtoon_env
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia -c conda-forge
conda install libfaiss=1.7.1 -c conda-forge
conda install _libgcc_mutex=0.1 ca-certificates=2022.2.1 certifi=2021.10.8
conda install faiss=1.7.1 m2-libedit libfaiss-avx2=1.7.1 -c conda-forge
conda install libffi=3.2.1 -c conda-forge
conda install matplotlib-base=3.3.4
conda install python-lmdb=1.2.1
conda install setuptools
conda install pip
conda install pillow

pip install cmake matplotlib ninja numpy opencv-python==4.5.3.56 scipy tqdm wget
conda install dlib=19.21

step4:
after activate conda env
cd the project path and run python style_transfer.py --scale_image

@williamyang1991
Copy link
Owner

Wow, I will add a link to this solution in README to help other win users :)

@ZanePoe
Copy link

ZanePoe commented Mar 5, 2023

I followed these steps to make the installation successfully,but there was an error when the program ran。
File "E:\code\github\AI\VToonify\style_transfer.py", line 11, in <module> from model.vtoonify import VToonify File "E:\code\github\AI\VToonify\model\vtoonify.py", line 5, in <module> from model.stylegan.model import ConvLayer, EqualLinear, Generator, ResBlock File "E:\code\github\AI\VToonify\model\stylegan\model.py", line 11, in <module> from model.stylegan.op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix File "E:\code\github\AI\VToonify\model\stylegan\op\__init__.py", line 1, in <module> from .fused_act import FusedLeakyReLU, fused_leaky_relu File "E:\code\github\AI\VToonify\model\stylegan\op\fused_act.py", line 11, in <module> fused = load( File "C:\Users\xx\.conda\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1284, in load return _jit_compile( File "C:\Users\xx\.conda\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1508, in _jit_compile _write_ninja_file_and_build_library( File "C:\Users\xx\.conda\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1623, in _write_ninja_file_and_build_library _run_ninja_build( File "C:\Users\xx\.conda\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1915, in _run_ninja_build message += f": {error.output.decode(*SUBPROCESS_DECODE_ARGS)}" # type: ignore[union-attr] File "C:\Users\xx\.conda\envs\vtoon_env\lib\encodings\oem.py", line 15, in decode return oem_decode(input, errors, True) UnicodeDecodeError: 'cp1' codec can't decode bytes in position 0--1: No mapping for the Unicode character exists in the target code page.
My environment is:win10,cuda11.8. cudnn8.7.0 ;

@vitacon
Copy link

vitacon commented Mar 5, 2023

No mapping for the Unicode character exists in the target code page.

Maybe some non-ANSI characters in path?

@luoww1992
Copy link
Author

your env with conda install xxx is compatible with the cuda version in real env?

@ZanePoe
Copy link

ZanePoe commented Mar 9, 2023

I know the reason now。Because my CMD window is utf-8 encoding,After modified to GBK, is ok。Thanks!

@qinmingyu134
Copy link

D:\anaconda\lib\site-packages\torch\utils\cpp_extension.py:304: UserWarning: Error checking compiler version for cl: [WinError 2]
系统找不到指定的文件。
warnings.warn(f'Error checking compiler version for {compiler}: {error}')
信息: 用提供的模式无法找到文件。
Traceback (most recent call last):
File "finetune_stylegan.py", line 14, in
from util import data_sampler, requires_grad, accumulate, sample_data, d_logistic_loss, d_r1_loss, g_nonsaturating_loss, g_pa
th_regularize, make_noise, mixing_noise, set_grad_none
File "E:\CycleGAN\DualStyleGAN-main\util.py", line 10, in
from model.stylegan.op import conv2d_gradfix
File "E:\CycleGAN\DualStyleGAN-main\model\stylegan\op_init_.py", line 1, in
from .fused_act import FusedLeakyReLU, fused_leaky_relu
File "E:\CycleGAN\DualStyleGAN-main\model\stylegan\op\fused_act.py", line 15, in
os.path.join(module_path, "fused_bias_act_kernel.cu"),
File "D:\anaconda\lib\site-packages\torch\utils\cpp_extension.py", line 1091, in load
keep_intermediates=keep_intermediates)
File "D:\anaconda\lib\site-packages\torch\utils\cpp_extension.py", line 1302, in _jit_compile
is_standalone=is_standalone)
File "D:\anaconda\lib\site-packages\torch\utils\cpp_extension.py", line 1400, in _write_ninja_file_and_build_library
is_standalone=is_standalone)
File "D:\anaconda\lib\site-packages\torch\utils\cpp_extension.py", line 1833, in _write_ninja_file_to_build_library
with_cuda=with_cuda)
File "D:\anaconda\lib\site-packages\torch\utils\cpp_extension.py", line 1948, in _write_ninja_file
'cl']).decode().split('\r\n')
File "D:\anaconda\lib\subprocess.py", line 411, in check_output
**kwargs).stdout
File "D:\anaconda\lib\subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['where', 'cl']' returned non-zero exit status 1.
Killing subprocess 27436
Traceback (most recent call last):
File "D:\anaconda\lib\runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "D:\anaconda\lib\runpy.py", line 85, in _run_code
exec(code, run_globals)
File "D:\anaconda\lib\site-packages\torch\distributed\launch.py", line 340, in
main()
File "D:\anaconda\lib\site-packages\torch\distributed\launch.py", line 326, in main
sigkill_handler(signal.SIGTERM, None) # not coming back
File "D:\anaconda\lib\site-packages\torch\distributed\launch.py", line 301, in sigkill_handler
raise subprocess.CalledProcessError(returncode=last_return_code, cmd=cmd)
subprocess.CalledProcessError: Command '['D:\anaconda\python.exe', '-u', 'finetune_stylegan.py', '--local_rank=0', '--iter', '600', '--batch', '1', '--ckpt', './chec
kpoint/stylegan2-ffhq-config-f.pt', '--style', 'cartoon', '--augment', './data/cartoon/lmdb/']' returned non-zero exit status 1.

@luoww1992
Copy link
Author

@qinmingyu134,
have you added the cl.exe into %PATH% ?

@qinmingyu134
Copy link

Yes, I added the cl.exe into %PATH%.

@weweho
Copy link

weweho commented Jun 24, 2023

(vtoon_env) E:\VToonify-main\VToonify-main>python style_transfer.py --scale_image
Load options
backbone: dualstylegan
batch_size: 4
ckpt: ./checkpoint/vtoonify_d_cartoon/vtoonify_s_d.pt
color_transfer: False
content: ./data/077436.jpg
cpu: False
exstyle_path: ./checkpoint/vtoonify_d_cartoon\exstyle_code.npy
faceparsing_path: ./checkpoint/faceparsing.pth
output_path: ./output/
padding: [200, 200, 200, 200]
parsing_map_path: None
scale_image: True
style_degree: 0.5
style_encoder_path: ./checkpoint/encoder.pt
style_id: 26
video: False


Traceback (most recent call last):
File "E:\VToonify-main\VToonify-main\style_transfer.py", line 63, in
vtoonify.load_state_dict(torch.load(args.ckpt, map_location=lambda storage, loc: storage)['g_ema'])
File "E:\Anaconda3\envs\vtoon_env\lib\site-packages\torch\serialization.py", line 791, in load
with _open_file_like(f, 'rb') as opened_file:
File "E:\Anaconda3\envs\vtoon_env\lib\site-packages\torch\serialization.py", line 271, in _open_file_like
return _open_file(name_or_buffer, mode)
File "E:\Anaconda3\envs\vtoon_env\lib\site-packages\torch\serialization.py", line 252, in init
super().init(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: './checkpoint/vtoonify_d_cartoon/vtoonify_s_d.pt'
I don‘t konw how to do

@weweho
Copy link

weweho commented Jun 24, 2023

maybe i forget to download training modals

@Alone-Monkey
Copy link

For help, I also followed the instructions, but what is the problem with reporting this error?

(vtoon_env) I:\pycharm_project\VToonify>python style_transfer.py --scale_image

e:\anaconda\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py(120)find_cuda_home()
-> if cuda_home and not torch.cuda.is_available():
(Pdb) c
No CUDA runtime is found, using CUDA_HOME='C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.7'
Traceback (most recent call last):
File "I:\pycharm_project\VToonify\style_transfer.py", line 11, in
from model.vtoonify import VToonify
File "I:\pycharm_project\VToonify\model\vtoonify.py", line 5, in
from model.stylegan.model import ConvLayer, EqualLinear, Generator, ResBlock
File "I:\pycharm_project\VToonify\model\stylegan\model.py", line 11, in
from model.stylegan.op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix
File "I:\pycharm_project\VToonify\model\stylegan\op_init
.py", line 1, in
from .fused_act import FusedLeakyReLU, fused_leaky_relu
File "I:\pycharm_project\VToonify\model\stylegan\op\fused_act.py", line 11, in
fused = load(
File "E:\Anaconda\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1310, in load
return _jit_compile(
File "E:\Anaconda\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1712, in _jit_compile
_write_ninja_file_and_build_library(
File "E:\Anaconda\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1812, in _write_ninja_file_and_build_library
_write_ninja_file_to_build_library(
File "E:\Anaconda\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 2201, in _write_ninja_file_to_build_library
cuda_flags = common_cflags + COMMON_NVCC_FLAGS + _get_cuda_arch_flags()
File "E:\Anaconda\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1982, in _get_cuda_arch_flags
arch_list[-1] += '+PTX'
IndexError: list index out of range

@Langjudy
Copy link

How to handle this issue,”Traceback (most recent call last):
File "C:\Users\23267\Desktop\grop\VToonify-main\style_transfer.py", line 11, in
from model.vtoonify import VToonify
File "C:\Users\23267\Desktop\grop\VToonify-main\model\vtoonify.py", line 5, in
from model.stylegan.model import ConvLayer, EqualLinear, Generator, ResBlock
File "C:\Users\23267\Desktop\grop\VToonify-main\model\stylegan\model.py", line 11, in
from model.stylegan.op import FusedLeakyReLU, fused_leaky_relu, upfirdn2d, conv2d_gradfix
File "C:\Users\23267\Desktop\grop\VToonify-main\model\stylegan\op_init_.py", line 1, in
from .fused_act import FusedLeakyReLU, fused_leaky_relu
File "C:\Users\23267\Desktop\grop\VToonify-main\model\stylegan\op\fused_act.py", line 11, in
fused = load(
File "C:\Users\23267\anaconda3\envs\vtoon_env1\lib\site-packages\torch\utils\cpp_extension.py", line 1308, in load
return _jit_compile(
File "C:\Users\23267\anaconda3\envs\vtoon_env1\lib\site-packages\torch\utils\cpp_extension.py", line 1736, in _jit_compile
return _import_module_from_library(name, build_directory, is_python_module)
File "C:\Users\23267\anaconda3\envs\vtoon_env1\lib\site-packages\torch\utils\cpp_extension.py", line 2136, in _import_module_from_library
module = importlib.util.module_from_spec(spec)
ImportError: DLL load failed while importing fused:“

@williamyang1991
Copy link
Owner

@liuhongs If you have a problem regarding the cpp extention (fused and upfirdn2d), please refer to https://github.com/williamyang1991/VToonify/tree/main/model/stylegan/op_cpu#readme

@itwasnoteasy
Copy link

itwasnoteasy commented Feb 9, 2024

Received following error after following the instructions from this youtube video - Vtoonify who nicely followed these instructions and got it working 6 months before.
File "C:\Users\V\miniconda3\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1306, in load return _jit_compile( File "C:\Users\V\miniconda3\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1710, in _jit_compile _write_ninja_file_and_build_library( File "C:\Users\V\miniconda3\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1800, in _write_ninja_file_and_build_library extra_ldflags = _prepare_ldflags( File "C:\Users\V\miniconda3\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 1887, in _prepare_ldflags extra_ldflags.append(f'/LIBPATH:{_join_cuda_home("lib", "x64")}') File "C:\Users\V\miniconda3\envs\vtoon_env\lib\site-packages\torch\utils\cpp_extension.py", line 2407, in _join_cuda_home raise OSError('CUDA_HOME environment variable is not set. ' OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root.

After some research installed the pytorch archived version from this pytorch page

For me v2.0.1 worked

CUDA 11.7

conda install pytorch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2 pytorch-cuda=11.7 -c pytorch -c nvidia

After this I also had to download this resnet file manually and copy it to my .cache folder because it seemed to forcibly stop the download for some reason.
https://download.pytorch.org/models/resnet18-5c106cde.pth
C:\Users\$USER_NAME\.cache\torch\hub\checkpoints\

@shiyeling
Copy link

Two issues when installing on windows 10:
#1 when running the default style transfer python script, it reports error:
" 报错:ImportError: DLL load failed while importing _imaging: 找不到指定的模块"
resolved by downgrade pillow to version 8.0.0

#2 torch complaining for no CUDA_HOME enviroment variable :
"OSError: CUDA_HOME environment variable is not set. Please set it to your CUDA install root."

although, I have hte CUDA_HOME enviroment variable as below:
CUDA_HOME C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4

could not figure out why

@vitacon
Copy link

vitacon commented Apr 9, 2024

although, I have hte CUDA_HOME enviroment variable as below: CUDA_HOME C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4

That's rather strange syntax. What about some quotes?

set CUDA_HOME="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4"

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

10 participants