Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: cuda() got an unexpected keyword argument 'device_id' #26

Closed
ilei00 opened this issue Dec 17, 2017 · 10 comments
Closed

TypeError: cuda() got an unexpected keyword argument 'device_id' #26

ilei00 opened this issue Dec 17, 2017 · 10 comments

Comments

@ilei00
Copy link

ilei00 commented Dec 17, 2017

When I run train.py in command line,I meet this problem. What shold I do?

(E:\programs\Anaconda\envs\python) D:\cv2\DeblurGAN-master>python train.py --dataroot blurred_sharp/ --continue_train
------------ Options -------------
batchSize: 1
beta1: 0.5
checkpoints_dir: ./checkpoints
continue_train: True
dataroot: blurred_sharp/
dataset_mode: aligned
display_freq: 100
display_id: 1
display_port: 8097
display_single_pane_ncols: 0
display_winsize: 256
epoch_count: 1
fineSize: 256
gan_type: wgan-gp
gpu_ids: [0]
identity: 0.0
input_nc: 3
isTrain: True
lambda_A: 100.0
lambda_B: 10.0
learn_residual: False
loadSizeX: 640
loadSizeY: 360
lr: 0.0001
max_dataset_size: inf
model: content_gan
nThreads: 2
n_layers_D: 3
name: experiment_name
ndf: 64
ngf: 64
niter: 150
niter_decay: 150
no_dropout: False
no_flip: False
no_html: False
norm: instance
output_nc: 3
phase: train
pool_size: 50
print_freq: 100
resize_or_crop: resize_and_crop
save_epoch_freq: 5
save_latest_freq: 5000
serial_batches: False
which_direction: AtoB
which_epoch: latest
which_model_netD: basic
which_model_netG: resnet_9blocks
-------------- End ----------------
CustomDatasetDataLoader
dataset [AlignedDataset] was created
Traceback (most recent call last):
File "train.py", line 56, in
model = create_model(opt)
File "D:\cv2\DeblurGAN-master\models\models.py", line 11, in create_model
model.initialize(opt)
File "D:\cv2\DeblurGAN-master\models\conditional_gan_model.py", line 34, in initialize
opt.which_model_netG, opt.norm, not opt.no_dropout, self.gpu_ids, use_parallel, opt.learn_residual)
File "D:\cv2\DeblurGAN-master\models\networks.py", line 52, in define_G
netG.cuda(device_id=gpu_ids[0])
TypeError: cuda() got an unexpected keyword argument 'device_id'

@ilei00
Copy link
Author

ilei00 commented Dec 18, 2017

when I made a change in network.py ,as following:
if len(gpu_ids) > 0:
print(gpu_ids[0])
netG.cuda(gpu_ids[0]) ########################device_id=gpu_ids[0]

Errors are like this:
THCudaCheck FAIL file=d:\pytorch\pytorch\torch\lib\thc\generic/THCTensorMath.cu line=15 error=48 : no kernel image is available
for execution on the device
Traceback (most recent call last):
File "test.py", line 22, in
model = create_model(opt)
File "D:\cv2\DeblurGAN-master\models\models.py", line 11, in create_model
model.initialize(opt)
File "D:\cv2\DeblurGAN-master\models\test_model.py", line 19, in initialize
opt.learn_residual)
File "D:\cv2\DeblurGAN-master\models\networks.py", line 54, in define_G
netG.apply(weights_init)
File "E:\programs\Anaconda\envs\python\lib\site-packages\torch\nn\modules\module.py", line 198, in apply
module.apply(fn)
File "E:\programs\Anaconda\envs\python\lib\site-packages\torch\nn\modules\module.py", line 198, in apply
module.apply(fn)
File "E:\programs\Anaconda\envs\python\lib\site-packages\torch\nn\modules\module.py", line 199, in apply
fn(self)
File "D:\cv2\DeblurGAN-master\models\networks.py", line 17, in weights_init
m.bias.data.fill_(0)
RuntimeError: cuda runtime error (48) : no kernel image is available for execution on the device at d:\pytorch\pytorch\torch\lib
\thc\generic/THCTensorMath.cu:15

So I really dont't know how to run this code properly on Windows 10 X64 with cuda 8.0,cudnn6, python 3.6.1,torch0.3.0 after many times' attempts

@KupynOrest
Copy link
Owner

Hello,
It seems that your GPU might not be compatible with the software, which GPU are you trying to use?

@ilei00
Copy link
Author

ilei00 commented Dec 22, 2017

NVIDIA Geforce GT 750M. It's not so good,but i just want to have a try.Do you mean that this cuda version does not support my GPU?

@WenjunDing
Copy link

I met the same problem ,have you solved this?

@hust-lidelong
Copy link

In base_model.py and models.py : change from " device_id" to "device"

@ilei00
Copy link
Author

ilei00 commented Dec 27, 2017

To: hust-lidelong ,It can solve the first problem,but the second error occured!

@magnificGH
Copy link

I just modified the code in networks.py ,netG.cuda(device_id=gpu_ids[0])-->netG.cuda(gpu_ids[0])

@ilei00
Copy link
Author

ilei00 commented Dec 30, 2017

To magnificGH : It still doesn't work now!

@WilliamWang1994
Copy link

how about now ?It still exiting?

@WilliamWang1994
Copy link

#11 JUST DO,NO THANKS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants