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

Inference (test.py) not working on CPU #70

Open
wottpal opened this issue Oct 18, 2018 · 4 comments
Open

Inference (test.py) not working on CPU #70

wottpal opened this issue Oct 18, 2018 · 4 comments

Comments

@wottpal
Copy link

wottpal commented Oct 18, 2018

Hey there,
currently when trying to execute test.py without having a GPU or Cuda installed it throws the following error (even when setting --gpu_ids to -1):

Traceback (most recent call last):
  File "test.py", line 61, in <module>
    generated = model.inference(data['label'], data['inst'])
  File "/Users/wottpal/Developer/melanoma-classification/pix2pixHD/models/pix2pixHD_model.py", line 197, in inference
    input_label, inst_map, _, _ = self.encode_input(Variable(label), Variable(inst), infer=True)
  File "/Users/wottpal/Developer/melanoma-classification/pix2pixHD/models/pix2pixHD_model.py", line 115, in encode_input
    input_label = label_map.data.cuda()
RuntimeError: Cannot initialize CUDA without ATen_cuda library. PyTorch splits its backend into two shared libraries: a CPU library and a CUDA library; this error has occurred because you are trying to use some CUDA functionality, but the CUDA library has not been loaded by the dynamic linker for some reason.  The CUDA library MUST be loaded, EVEN IF you don't directly use any symbols from the CUDA library! One common culprit is a lack of -Wl,--no-as-needed in your link arguments; many dynamic linkers will delete dynamic library dependencies if you don't depend on any of their symbols.  You can check if this has occurred by using ldd on your binary to see if there is a dependency on *_cuda.so library.

A quick fix could be replacing line 115 in models/pix2pixHD_model.py with something like:

if not self.gpu_ids: 
    input_label = label_map.data
else: 
    input_label = label_map.data.cuda()

Regards from Germany,
Dennis

@Rubiel1
Copy link

Rubiel1 commented Mar 23, 2020

In the current version there are several lines on the file pix2pixHD_model.py that need to be modified, all of them have the .cuda() and all of them can be replace by an if statement like above.

@blaine141
Copy link

I am also experiencing this issue. It appears pull requests #121 and #122 will solve this issue. Can somebody pull these in?

@missyoudaisy
Copy link

I am also experiencing this issue. It appears pull requests #121 and #122 will solve this issue. Can somebody pull these in?

Hello! I modify my code like #121 and #122, but meet "Segmentation fault (core dumped)" in docker , did you meet this problem?

@shnamin
Copy link

shnamin commented Jul 24, 2023

Has there been a solution?

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

5 participants