orpatashnik / StyleCLIP

Official Implementation for "StyleCLIP: Text-Driven Manipulation of StyleGAN Imagery" (ICCV 2021 Oral)
MIT License
3.93k stars 553 forks source link

Running inference on a CPU #18

Open AK391 opened 3 years ago

AK391 commented 3 years ago

is it possible to run on cpu for inference, specifically the gui shown in the youtube video

betterze commented 3 years ago

Dear AK391,

Thank you for your interest in our project. Currently, we load the pretrained model from Stylegan2 which is trained using GPU. We can not even do Gs.print_layers() without GPU. Maybe try our colab which utilizes google gpu.

We will release a pure pythorch version in the future, which may run properly with just CPU.

Best Wishes,

Zongze

AK391 commented 3 years ago

@betterze could anycost gan help with this https://github.com/mit-han-lab/anycost-gan

elenacliu commented 1 year ago

Dear AK391,

Thank you for your interest in our project. Currently, we load the pretrained model from Stylegan2 which is trained using GPU. We can not even do Gs.print_layers() without GPU. Maybe try our colab which utilizes google gpu.

We will release a pure pythorch version in the future, which may run properly with just CPU.

Best Wishes,

Zongze

Just a little question, why can not the tf-version code run on CPU?

Currently, we load the pretrained model from Stylegan2 which is trained using GPU.

I'm fresh in this field. Can't we load it using CPU and its memory?

elenacliu commented 1 year ago

I change the tf.configProto to unuse GPU, but the code under global_directions runs into error, which says:

tensorflow.python.framework.errors_impl.InvalidArgumentError: No OpKernel was registered to support Op 'FusedBiasAct' used by node G_synthesis_1/4x4/Conv/FusedBiasAct (defined at <string>:104) with these attrs: [T=DT_FLOAT, axis=1, grad=0, alpha=0, clamp=-1, act=1, gain=1]
Registered devices: [CPU, XLA_CPU, XLA_GPU]
Registered kernels:
  device='GPU'; T in [DT_HALF]
  device='GPU'; T in [DT_FLOAT]

         [[G_synthesis_1/4x4/Conv/FusedBiasAct]]

Errors may have originated from an input operation.
Input Source operations connected to node G_synthesis_1/4x4/Conv/FusedBiasAct:
 G_synthesis_1/4x4/Conv/mul_2 (defined at <string>:67)
 G_synthesis_1/4x4/Conv/Const (defined at ./global_directions/dnnlib/tflib/ops/fused_bias_act.py:115)
 G_synthesis_1/4x4/Conv/MatMul (defined at <string>:46)

A similar quesion: https://discuss.tensorflow.org/t/tensorflow-inference-on-cpu-after-training-model-on-gpu-with-amp-and-xla/12731