lucidrains / denoising-diffusion-pytorch

Implementation of Denoising Diffusion Probabilistic Model in Pytorch
MIT License
8.31k stars 1.03k forks source link

Failed to load image Python extension: '[WinError 127] 找不到指定的程序 #302

Open Liuwuyang1026 opened 7 months ago

Liuwuyang1026 commented 7 months ago

warnings.warn( 0%| | 0/700000 [00:00<?, ?it/s]C:\Users\29125\anaconda3\envs\pytorch\lib\site-packages\torchvision\io\image.py:13: UserWarning: Failed to load image Python extension: '[WinError 127] 找不到指定的程序。'If you don't plan on using image functionality from torchvision.io, you can ignore this warning. Otherwise, there might be something wrong with your environment. Did you have libjpeg or libpng installed before building torchvision from source? warn( C:\Users\29125\anaconda3\envs\pytorch\lib\site-packages\accelerate\accelerator.py:432: FutureWarning: Passing the following arguments to Accelerator is deprecated and will be removed in version 1.0 of Accelerate: dict_keys(['split_batches']). Please pass an accelerate.DataLoaderConfiguration instead: dataloader_config = DataLoaderConfiguration(split_batches=True) warnings.warn( 0%| | 0/700000 [00:00<?, ?it/s] Traceback (most recent call last): File "", line 1, in File "C:\Users\29125\anaconda3\envs\pytorch\lib\multiprocessing\spawn.py", line 116, in spawn_main exitcode = _main(fd, parent_sentinel) File "C:\Users\29125\anaconda3\envs\pytorch\lib\multiprocessing\spawn.py", line 125, in _main prepare(preparation_data) File "C:\Users\29125\anaconda3\envs\pytorch\lib\multiprocessing\spawn.py", line 236, in prepare _fixup_main_from_path(data['init_main_from_path']) File "C:\Users\29125\anaconda3\envs\pytorch\lib\multiprocessing\spawn.py", line 287, in _fixup_main_from_path main_content = runpy.run_path(main_path, File "C:\Users\29125\anaconda3\envs\pytorch\lib\runpy.py", line 288, in run_path return _run_module_code(code, init_globals, run_name, File "C:\Users\29125\anaconda3\envs\pytorch\lib\runpy.py", line 97, in _run_module_code _run_code(code, mod_globals, init_globals, File "C:\Users\29125\anaconda3\envs\pytorch\lib\runpy.py", line 87, in _run_code exec(code, run_globals) File "D:\29125\PYcharm\keyanmodule\denoising-diffusion\denoising-diffusion-pytorch-main\train.py", line 28, in trainer.train() File "D:\29125\PYcharm\keyanmodule\denoising-diffusion\denoising-diffusion-pytorch-main\denoising_diffusion_pytorch\denoising_diffusion_pytorch.py", line 1028, in train data = next(self.dl).to(device) File "D:\29125\PYcharm\keyanmodule\denoising-diffusion\denoising-diffusion-pytorch-main\denoising_diffusion_pytorch\denoising_diffusion_pytorch.py", line 60, in cycle for data in dl: File "C:\Users\29125\anaconda3\envs\pytorch\lib\site-packages\accelerate\data_loader.py", line 449, in iter dataloader_iter = super().iter() File "C:\Users\29125\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 439, in iter return self._get_iterator() File "C:\Users\29125\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 387, in _get_iterator return _MultiProcessingDataLoaderIter(self) File "C:\Users\29125\anaconda3\envs\pytorch\lib\site-packages\torch\utils\data\dataloader.py", line 1040, in init w.start() File "C:\Users\29125\anaconda3\envs\pytorch\lib\multiprocessing\process.py", line 121, in start self._popen = self._Popen(self) File "C:\Users\29125\anaconda3\envs\pytorch\lib\multiprocessing\context.py", line 224, in _Popen return _default_context.get_context().Process._Popen(process_obj) File "C:\Users\29125\anaconda3\envs\pytorch\lib\multiprocessing\context.py", line 327, in _Popen return Popen(process_obj) File "C:\Users\29125\anaconda3\envs\pytorch\lib\multiprocessing\popen_spawn_win32.py", line 45, in init prep_data = spawn.get_preparation_data(process_obj._name) File "C:\Users\29125\anaconda3\envs\pytorch\lib\multiprocessing\spawn.py", line 154, in get_preparation_data _check_not_importing_main() File "C:\Users\29125\anaconda3\envs\pytorch\lib\multiprocessing\spawn.py", line 134, in _check_not_importing_main raise RuntimeError(''' RuntimeError: An attempt has been made to start a new process before the current process has finished its bootstrapping phase.

    This probably means that you are not using fork to start your
    child processes and you have forgotten to use the proper idiom
    in the main module:

        if __name__ == '__main__':
            freeze_support()
            ...

    The "freeze_support()" line can be omitted if the program
    is not going to be frozen to produce an executable.

windows 11 pytorch 2.2.1

Liuwuyang1026 commented 7 months ago

Help me please,I REALLY need your help!

juny-park-95 commented 4 weeks ago

hey bro you should include your code with main function like this:

from denoising_diffusion_pytorch import Unet, GaussianDiffusion, Trainer

if __name__ == '__main__': # <------- THIS IS IMPORTANT STUFF
    model = Unet(
        dim = 64,
        dim_mults = (1, 2, 4, 8),
        flash_attn = True
    )

    diffusion = GaussianDiffusion(
        model,
        image_size = 128,
        timesteps = 1000,           # number of steps
        sampling_timesteps = 250    # number of sampling timesteps (using ddim for faster inference [see citation for ddim paper])
    )

    trainer = Trainer(
        diffusion,
        r"F:\project\medical\dataset\128\OTE",
        train_batch_size = 32,
        train_lr = 8e-5,
        train_num_steps = 700000,         # total training steps
        gradient_accumulate_every = 2,    # gradient accumulation steps
        ema_decay = 0.995,                # exponential moving average decay
        amp = True,                       # turn on mixed precision
        calculate_fid = True              # whether to calculate fid during training
    )

    trainer.train()