xiezhy6 / PASTA-GAN

Official code for NeurIPS 2021 paper "Towards Scalable Unpaired Virtual Try-On via Patch-Routed Spatially-Adaptive GAN"
81 stars 23 forks source link

Cant run on windows #4

Open hamaadtahiir opened 2 years ago

hamaadtahiir commented 2 years ago

When I try to run the inference it gives the following error:

Loading networks from "data/network-snapshot-004000.pkl"... Loading custom kernel... Traceback (most recent call last): File "test.py", line 159, in generate_images() # pylint: disable=no-value-for-parameter File "g:\c-vton\pfafn\lib\site-packages\click\core.py", line 1128, in call return self.main(args, kwargs) File "g:\c-vton\pfafn\lib\site-packages\click\core.py", line 1053, in main rv = self.invoke(ctx) File "g:\c-vton\pfafn\lib\site-packages\click\core.py", line 1395, in invoke return ctx.invoke(self.callback, ctx.params) File "g:\c-vton\pfafn\lib\site-packages\click\core.py", line 754, in invoke return __callback(args, *kwargs) File "g:\c-vton\pfafn\lib\site-packages\click\decorators.py", line 26, in new_func return f(get_current_context(), args, **kwargs) File "test.py", line 93, in generate_images G = legacy.load_network_pkl(f)['G_ema'].to(device) # type: ignore File "G:\c-vton\PASTA-GAN\legacy.py", line 21, in load_network_pkl data = _LegacyUnpickler(f).load() File "G:\c-vton\PASTA-GAN\torch_utils\persistence.py", line 191, in _reconstruct_persistent_obj module = _src_to_module(meta.module_src) File "G:\c-vton\PASTA-GAN\torch_utils\persistence.py", line 227, in _src_to_module exec(src, module.dict) # pylint: disable=exec-used File "", line 2243, in NameError: name 'os' is not defined

Now os module is obviously installed and importable in python

ghost commented 2 years ago

Ensure you have properly followed the installation instructions. Make sure you are running the script from inside the virtual environment, and that you have the specified version of torch installed.

miibotree commented 2 years ago

I think the problem is the cuda version on your environment is not equal to the requirement 11.0. See Line1204-1225 on networks.py:

from torch.autograd import Function
from torch.utils.cpp_extension import load

def is_custom_kernel_supported():
    version_str = str(torch.version.cuda).split(".")
    major = version_str[0]
    minor = version_str[1]
    return int(major) >= 10 and int(minor) >= 1

if is_custom_kernel_supported():
    print("Loading custom kernel...")
    module_path = os.path.dirname(__file__)
    upfirdn2d_op = load(
        'upfirdn2d',
        sources=[
            os.path.join(module_path, 'upfirdn2d.cpp'),
            os.path.join(module_path, 'upfirdn2d_kernel.cu'),
        ],
        verbose=True
    )

use_custom_kernel = is_custom_kernel_supported()

if your cuda version satisfied with the condition : int(major) >= 10 and int(minor) >= 1, will go to the above codes. However, cuda version 11.0 not satisfied with the condition and thus not go to the above codes. By the way, @alexlevenston2021 I didn't find file upfirdn2d_kernel.cu in the source code? Do I miss compile any thing?

omking commented 2 years ago

@miibotree please rename PASTA-GAN-main/torch_utils/ops/upfirdn2d.cu to upfirdn2d_kernel.cu it will solve your issue

after solving this issue I stuck in RuntimeError: Error building extension 'upfirdn2d'

any able to run full code for test?