rosinality / stylegan2-pytorch

Implementation of Analyzing and Improving the Image Quality of StyleGAN (StyleGAN 2) in PyTorch
MIT License
2.74k stars 623 forks source link

GPU out of memory Error when using convert_weight.py? #275

Open aesanchezgh opened 2 years ago

aesanchezgh commented 2 years ago

Hello,

When using convert_weight.py to convert stylegan weights I get the following error:

Message=CUDA out of memory. Tried to allocate 514.00 MiB (GPU 0; 24.00 GiB total capacity; 395.62 MiB already allocated; 281.16 MiB free; 668.00 MiB reserved in total by PyTorch) Source=P:\stylegan2-pytorch\op\conv2d_gradfix.py StackTrace: File "P:\stylegan2-pytorch\op\conv2d_gradfix.py", line 74, in conv_transpose2d groups=groups, File "P:\stylegan2-pytorch\model.py", line 278, in forward (Current frame) input, weight, padding=0, stride=2, groups=batch File "P:\stylegan2-pytorch\model.py", line 361, in forward out = self.conv(input, style) File "P:\stylegan2-pytorch\model.py", line 558, in forward out = conv1(out, latent[:, i], noise=noise1) File "P:\stylegan2-pytorch\convert_weight.py", line 289, in randomize_noise=False,

I am using a Titan RTX with 24GB of RAM. Does anyone know how to prevent this from happening?

Here are additional logs:

Setting up TensorFlow plugin "upfirdn_2d.cu": Preprocessing... 2021-12-14 17:39:25.785649: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1640] Found device 0 with properties: name: TITAN RTX major: 7 minor: 5 memoryClockRate(GHz): 1.77 pciBusID: 0000:b3:00.0 2021-12-14 17:39:25.786020: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check. 2021-12-14 17:39:25.786662: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1763] Adding visible gpu devices: 0 2021-12-14 17:39:25.787415: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1181] Device interconneLoading... ct StreamExecutor with strength 1 edge matrix: 2021-12-14 17:39:25.788295: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1187] 0 2021-12-14 17:39:25.788465: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1200] 0: N 2021-12-14 17:39:25.788879: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1326] Created TensorFlow device (/device:GPU:0 with 18528 MB memory) -> physical GPU (device: 0, name: TITAN RTX, pci bus id: 0000:b3:00.0, compute capability: 7.5) Done. P:\stylegan2-pytorch\op\conv2d_gradfix.py:89: UserWarning: conv2d_gradfix not supported on PyTorch 1.9.0+cu102. Falling back to torch.nn.functional.conv2d(). f"conv2d_gradfix not supported on PyTorch {torch.version}. Falling back to torch.nn.functional.conv2d()."

rosinality commented 2 years ago

It is just for the sanity check, and converted checkpoint is created. So you can ignore this step.