StyleFlow icon indicating copy to clipboard operation
StyleFlow copied to clipboard

Can not run it on Windows 10

Open FlowDownTheRiver opened this issue 3 years ago • 4 comments

I have tried to run this for almost 5 hours.I am about to give up.Any help on this?

(styleflow) C:\StyleFlow>python main.py ----------------- Options --------------- batchSize: 1 checkpoints_dir: ./checkpoints dataroot: ./data/datasetX gpu_ids: 0 max_result_snapshots: 30 model: xxxx name: XXXX network_pkl: gdrive:networks/stylegan2-ffhq-config-f.pkl only_for_test: ... phase: test ----------------- End ------------------- Loading networks from "gdrive:networks/stylegan2-ffhq-config-f.pkl"... Setting up TensorFlow plugin "fused_bias_act.cu": Preprocessing... Failed! Traceback (most recent call last): File "main.py", line 365, in ex = ExWindow(opt) File "main.py", line 40, in init self.EX = Ex(opt) File "main.py", line 70, in init self.init_deep_model(opt) File "main.py", line 105, in init_deep_model self.model = Build_model(self.opt) File "C:\StyleFlow\utils.py", line 200, in init _G, _D, Gs = pretrained_networks.load_networks(network_pkl) File "C:\StyleFlow\pretrained_networks.py", line 76, in load_networks G, D, Gs = pickle.load(stream, encoding='latin1') File "C:\StyleFlow\dnnlib\tflib\network.py", line 297, in setstate self._init_graph() File "C:\StyleFlow\dnnlib\tflib\network.py", line 154, in _init_graph out_expr = self._build_func(*self.input_templates, **build_kwargs) File "", line 491, in G_synthesis_stylegan2 File "", line 455, in layer File "", line 99, in modulated_conv2d_layer File "", line 68, in apply_bias_act File "C:\StyleFlow\dnnlib\tflib\ops\fused_bias_act.py", line 68, in fused_bias_act return impl_dict[impl](x=x, b=b, axis=axis, act=act, alpha=alpha, gain=gain) File "C:\StyleFlow\dnnlib\tflib\ops\fused_bias_act.py", line 122, in _fused_bias_act_cuda cuda_kernel = _get_plugin().fused_bias_act File "C:\StyleFlow\dnnlib\tflib\ops\fused_bias_act.py", line 16, in _get_plugin return custom_ops.get_plugin(os.path.splitext(file)[0] + '.cu') File "C:\StyleFlow\dnnlib\tflib\custom_ops.py", line 118, in get_plugin _run_cmd(_prepare_nvcc_cli('"%s" --preprocess -o "%s" --keep --keep-dir "%s"' % (cuda_file, tmp_file, tmp_dir))) File "C:\StyleFlow\dnnlib\tflib\custom_ops.py", line 63, in _run_cmd output = pipe.read() File "C:\Users\Username\anaconda3\envs\styleflow\lib\encodings\cp1254.py", line 23, in decode return codecs.charmap_decode(input,self.errors,decoding_table)[0] UnicodeDecodeError: 'charmap' codec can't decode byte 0x8d in position 28: character maps to

FlowDownTheRiver avatar Mar 25 '21 01:03 FlowDownTheRiver

try my PR repo: https://github.com/justinjohn0306/StyleFlow-Windows-10

justinjohn0306 avatar Mar 25 '21 18:03 justinjohn0306

Hi, I'd like to share my experience for making it work (at least the UI launch so far) on Windows 10. @justinjohn0306 repo helped me as I used 2 of his file for this.

So if i remember (sorry didn't write my step, I tell from head)

  1. You need anaconda for windows : https://www.anaconda.com/products/individual

  2. Launch Anaconda PowerShell Prompt (a shortcut is create when installing, if you don't find it, here is mine for example %windir%\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy ByPass -NoExit -Command "& 'E:\IA\anaconda3\shell\condabin\conda-hook.ps1' ; conda activate 'E:\IA\anaconda3' ", with E:\IA\ is where I installed Anaconda on step 1) )

  3. from anaconda prompt (you should see something like(base) PS C:\Users\[your_username]>) type : cd [wherever you clone styleflow git] You should see something like : (base) PS [whereever you clone styleflow git] (for me for example : (base) PS E:\IA\StyleFlow>)

  4. before running conda create env, you have to get 2 files from @justinjohn0306 repo : https://github.com/justinjohn0306/StyleFlow-Windows-10/blob/master/env_windows.yml and https://github.com/justinjohn0306/StyleFlow-Windows-10/blob/master/dnnlib/tflib/custom_ops.py and copy paste them on you StyleFlow git clone (replace custom_ops.py with new, you can make a bakeup if you want)

  5. I had other issue myself involving modifing this 2 files even more :

  • a) For env_windows.yml I had to add this under pip dependency : - brotli==1.0.9

    • bis) and change this file too : [wherever you installed anaconda]\anaconda3\Lib\site-packages\pip\_vendor\urllib3\response.py Comment line 389 + 390 : # if brotli is not None: #DECODER_ERROR_CLASSES += (brotli.error,)
  • b) For custom_ops.py, as I have a non-ascii username, I ended up adding this workaround in the script : https://stackoverflow.com/questions/67954898/how-to-get-temp-directory-in-python-with-a-non-ascii-windows-username (adding the _getutempdir() in the script, and call it on begin of get_plugin(cuda_file) function : tempdir = _getutempdir(). Then inside this function below, there are 2 time you can see with tempfile.TemporaryDirectory() as tmp_dir: (line 126 and 162 on @justinjohn0306 script version). You just have to replace after tmp_dir with my "non-ascii" tempdir version : tmp_dir = tempdir

  • c) I manage to get my VS 2019 compiler to work by modifying custom_ops.py again (may need some clean up, didn't test yet a cleanup version) : compiler_bindir_search_path = [ 'C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.14.26428/bin/Hostx64/x64', r'C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30037\bin\Hostx64\x64', 'C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64', 'C:/Program Files (x86)/Microsoft Visual Studio 14.0/vc/bin', ] on line 31. Especially pay attention that the version number under [...]/Tools/MSVC/14.XX.YYYYY/bin/Hostx64/x64 math the one YOU have on your computer (just check via windows explorer the correponding MSVC folder).

  • d) As I ended up with another error with universal C runtime ( missing corecrt.h, for Qt ui I guess), I have to lauch Visual Studio Installer, choose Modify and add : [Individual Component]

    • Windows Universal C Runtime
    • Windows 10 SDK Kit
    • Windows Universal CRT SDK
    • MSVC v142 - VS 2019 C++ x64/x86 Build Tools
  1. Now you can get back to you conda PS prompt and type conda env create -f env_windows.yml

  2. when finished swith to the new env create : conda activate styleflow

  • bis) if ever you still have brotli error (now or after when execution main.py script I'm not sure), modify by commenting like above this 2 lines on [wherever you installed anaconda]\anaconda3\envs\styleflow\lib\site-packages\pip\_vendor\urllib3\response.py Comment line 376 + 377 : # if brotli is not None: #DECODER_ERROR_CLASSES += (brotli.error,)

Or any other response.py file that the prompt will yell at you.

  1. Now like @justinjohn0306 explain on his repo type conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch

  2. Finally run python main.py

Sorry for this out of my head, and not a precise guide, but I hope it may help some of you after having myself stuck on this last days.

elTRexx avatar Jun 15 '21 00:06 elTRexx

내 PR 리포지토리 시도: https://github.com/justinjohn0306/StyleFlow-Windows-10

I took a good look at your repo. However, I do not understand the docker part while following the installation. It would be of great help if you explain how to install nvidia-docker2 on Windows. Thank you.

leeisack avatar Oct 28 '21 04:10 leeisack

“Installation (Docker)” is another way of installation??? or it is necessary.

675492062 avatar Jan 13 '22 08:01 675492062