XingangPan / GAN2Shape

Code for GAN2Shape (ICLR2021 oral)
https://arxiv.org/abs/2011.00844
MIT License
571 stars 104 forks source link

RuntimeError: CUDA error: invalid argument #10

Open mathXin112 opened 3 years ago

mathXin112 commented 3 years ago

Excuse me, I am interested in this work, and try to run this code. But I meet some problems, the main is : RuntimeError: CUDA error: invalid argument. The detail such as: Traceback (most recent call last): File "run.py", line 34, in trainer.train() File "/home/dylanfan/Desktop/huxin/GAN2Shape-main/gan2shape/trainer.py", line 169, in train m = self.model.forward() File "/home/dylanfan/Desktop/huxin/GAN2Shape-main/gan2shape/model.py", line 743, in forward m = self.forward_step2() File "/home/dylanfan/Desktop/huxin/GAN2Shape-main/gan2shape/model.py", line 618, in forward_step2 self.proj_im, offset = self.gan_invert(self.pseudo_im) File "/home/dylanfan/Desktop/huxin/GAN2Shape-main/gan2shape/model.py", line 611, in gan_invert gan_ims, offsets = gan_invert_sub(image) File "/home/dylanfan/Desktop/huxin/GAN2Shape-main/gan2shape/model.py", line 599, in gan_invert_sub truncation=self.truncation, randomize_noise=False) File "/home/dylanfan/program/anaconda3/envs/gan2shap/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, kwargs) File "/home/dylanfan/Desktop/huxin/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/model.py", line 603, in forward out = conv2(out, latent[:, i + 1], noise=noise2) File "/home/dylanfan/program/anaconda3/envs/gan2shap/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, *kwargs) File "/home/dylanfan/Desktop/huxin/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/model.py", line 358, in forward out = self.conv(input, style) File "/home/dylanfan/program/anaconda3/envs/gan2shap/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(input, kwargs) File "/home/dylanfan/Desktop/huxin/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/model.py", line 261, in forward style = self.modulation(style).view(batch, 1, in_channel, 1, 1) File "/home/dylanfan/program/anaconda3/envs/gan2shap/lib/python3.7/site-packages/torch/nn/modules/module.py", line 547, in call result = self.forward(*input, *kwargs) File "/home/dylanfan/Desktop/huxin/GAN2Shape-main/gan2shape/stylegan2/stylegan2-pytorch/model.py", line 172, in forward input, self.weight self.scale, bias=self.bias * self.lr_mul RuntimeError: CUDA error: invalid argument

Some versions of my enviroment is: Ubuntu 18.04, cuda: 10.1, cudnn: 8.0.61, pytorch 1.2, cudatoolkit: 9.2. In another computer, my enviroment is : Ubuntu 18.04, cuda 11.1, pytorch 1.2, cudatoolkit: 9.2, and I get problem : RuntimeError: CUDA error: invalid device function, like this: Load config from yml file: configs/car.yml Loading configs from configs/car.yml {'checkpoint_dir': 'results/car', 'save_checkpoint_freq': 500, 'keep_num_checkpoint': 2, 'use_logger': True, 'log_freq': 100, 'joint_train': False, 'independent': False, 'reset_weight': True, 'save_results': True, 'num_stage': 4, 'flip1_cfg': [False, False, False, False], 'flip3_cfg': [False, False, False, False], 'stage_len_dict': {'step1': 700, 'step2': 700, 'step3': 600}, 'stage_len_dict2': {'step1': 200, 'step2': 500, 'step3': 400}, 'image_size': 128, 'load_gt_depth': False, 'img_list_path': 'data/car/list.txt', 'img_root': 'data/car', 'latent_root': 'data/car/latents', 'model_name': 'gan2shape_car', 'category': 'car', 'share_weight': True, 'relative_enc': False, 'use_mask': True, 'add_mean_L': True, 'add_mean_V': True, 'min_depth': 0.9, 'max_depth': 1.1, 'xyz_rotation_range': 60, 'xy_translation_range': 0.1, 'z_translation_range': 0, 'collect_iters': 100, 'batchsize': 8, 'lr': 0.0001, 'lam_perc': 0.5, 'lam_smooth': 0.01, 'lam_regular': 0.01, 'view_mvn_path': 'checkpoints/view_light/view_mvn.pth', 'light_mvn_path': 'checkpoints/view_light/light_mvn.pth', 'rand_light': [-1, 1, -0.2, 0.8, -0.1, 0.6, -0.6], 'channel_multiplier': 2, 'gan_size': 512, 'gan_ckpt': 'checkpoints/stylegan2/stylegan2-car-config-f.pt', 'F1_d': 2, 'rot_center_depth': 1.0, 'fov': 10, 'tex_cube_size': 2, 'config': 'configs/car.yml', 'seed': 0, 'num_workers': 4, 'distributed': False} Setting up Perceptual loss... Loading model from: /content/GAN2Shape/gan2shape/stylegan2/stylegan2-pytorch/lpips/weights/v0.1/vgg.pth ...[net-lin [vgg]] initialized ...Done Traceback (most recent call last): File "run.py", line 31, in trainer = Trainer(cfgs, GAN2Shape) File "/content/GAN2Shape/gan2shape/trainer.py", line 23, in init self.model = model(cfgs) File "/content/GAN2Shape/gan2shape/model.py", line 92, in init self.renderer = Renderer(cfgs, self.image_size) File "/content/GAN2Shape/gan2shape/renderer/renderer.py", line 46, in init self.inv_K = self.inv_K_origin.clone() RuntimeError: CUDA error: invalid device function

I pay grate effort for this, and I really do not konw what wrong with this. Looking forward to your reply, thank you!