Skip to content

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

Description

@wottpal

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions