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

How do I fix this error? '_cuda_setDevice' #360

Closed
ArchitectTaeyoon opened this issue Aug 31, 2018 · 15 comments
Closed

How do I fix this error? '_cuda_setDevice' #360

ArchitectTaeyoon opened this issue Aug 31, 2018 · 15 comments

Comments

@ArchitectTaeyoon
Copy link

ArchitectTaeyoon commented Aug 31, 2018

Hello,

I have been following the instruction up to the training stage, where I got stuck.

#!./scripts/train_cyclegan.sh
python train.py --dataroot ./datasets/maps --name maps_cyclegan --model cycle_gan

And I get the following error;

Traceback (most recent call last):
  File "train.py", line 8, in <module>
    opt = TrainOptions().parse()
  File "/Users/taeyoonkim/Documents/ML/pix2pix/pytorch-CycleGAN-and-pix2pix/options/base_options.py", line 116, in parse
    torch.cuda.set_device(opt.gpu_ids[0])
  File "/Users/taeyoonkim/anaconda2/lib/python2.7/site-packages/torch/cuda/__init__.py", line 262, in set_device
    torch._C._cuda_setDevice(device)
AttributeError: 'module' object has no attribute '_cuda_setDevice'

Seems like this is a popular question, and after looking at the previous answers, I have been trying to install different versions of Pytorch, but didn't succeed. I couldn't figure out how to run it on the CPU like the other answer suggests. (--gpu_ids 0)

Running on Mac OS High Sierra 10.13.3
Python 2.7 version.
Installed : pip, anaconda2, pytorch (python2.7, CUDA 9.2), visdom, dominate, brew, bash, wget, CUDA developer toolkit, cuDNN

I also installed python3 using brew, but switching the path became problematic, so I stuck to 2.7 versions. I have tried installing pytorch 0.4.0, although the terminal seems to be using 0.4.1
I tried downgrading to pytorch 0.3.1 and the same error appears. (#267)

@junyanz
Copy link
Owner

junyanz commented Aug 31, 2018

The current code only supports PyTorch 0.4+. See Q & A for more details.

@ArchitectTaeyoon
Copy link
Author

yup I tried the latest versions (0.4+) first. Same error.

@junyanz
Copy link
Owner

junyanz commented Aug 31, 2018

Hmm, do you have an NVIDIA GPU on your Mac? If not, you can set --gpu_ids -1 to use CPU mode.

@ArchitectTaeyoon
Copy link
Author

ArchitectTaeyoon commented Aug 31, 2018

yes I have an NVIDIA GPU.
I would like to use the GPU, since it is much faster..

I tried the CPU mode command anyway, but it won't work.
Am I meant to insert --gpu_ids -1 line into .profile ?

Thank you for answering my questions! :)

screen shot 2018-08-31 at 22 54 47

@junyanz
Copy link
Owner

junyanz commented Aug 31, 2018

add --gpu_ids -1 to your python command.
I am not sure if your issue is caused by this repo. You may want to run some PyTorch official examples and see if your PyTorch is installed correctly.

@ArchitectTaeyoon
Copy link
Author

okay thanks! I will try the examples and come back :)

@ssnl
Copy link
Collaborator

ssnl commented Sep 1, 2018

The PyTorch binary for osx does not support CUDA. So if you run with gpu_ids not -1, you will see such error. You can build from pytorch github source to support CUDA.

@ArchitectTaeyoon
Copy link
Author

Oh I see! Thank you for the feedback.
I’m not so sure how I can build the support for CUDA - I will also try the same setup with python 3.7 on a linux environment using docker on a Windows laptop.

@ssnl
Copy link
Collaborator

ssnl commented Sep 1, 2018

Both linux and windows binaries work with CUDA. Have fun!

@ArchitectTaeyoon
Copy link
Author

Thank you ! :)

@dsy199610
Copy link

--gpu_ids -1

where should I type this command?

@junyanz
Copy link
Owner

junyanz commented Jan 17, 2019

You add it when you call python.py...

@QasimWani
Copy link

i'm having the same issue as @ArchitectTaeyoon with python3.8.
@ArchitectTaeyoon how were u able to solve/fix your error?

@RoyceDavison
Copy link

RoyceDavison commented Apr 22, 2021

i'm having the same issue as @ArchitectTaeyoon with python3.8.
@ArchitectTaeyoon how were u able to solve/fix your error?

An example will be like (suppose I want to apply a pre-trained model):
python ./test.py --dataroot ./datasets/monet2photo/testA/ --name monet2photo_pretrained --model test --no_dropout --gpu_ids -1
Just add --gpu_ids -1 to your python command.

@aktaseren
Copy link

Hmm, do you have an NVIDIA GPU on your Mac? If not, you can set --gpu_ids -1 to use CPU mode.

That worked for me as well. Thank you.

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

7 participants